changeset 377:a465b5dbfecf

Tabs and line length.
author cmlenz
date Tue, 24 Jul 2007 14:37:04 +0000
parents 05c684ceb8c6
children c75d00307a64
files bitten/master.py bitten/model.py bitten/queue.py bitten/recipe.py bitten/slave.py bitten/util/beep.py
diffstat 6 files changed, 79 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -164,7 +164,8 @@
             self.channel.send_rpy(msgno, beep.Payload(xml))
 
     def send_initiation(self, queue, build):
-	log.info('Initiating build of %d ("%s" as of [%s]) on slave %s', build.id, build.config, build.rev, self.name) 
+        log.info('Initiating build of %d ("%s" as of [%s]) on slave %s',
+                 build.id, build.config, build.rev, self.name)
 
         build.slave = self.name
         build.slave_info.update(self.info)
@@ -246,15 +247,17 @@
                     raise beep.ProtocolError(500)
                 elem = xmlio.parse(payload.body)
 
-		# verify that the build hasn't been modified out from
-		# under us-- we don't want to accept any build information
-		# from builds that have been invalidated or claimed by
-		# other slaves.
-		current_build = Build.fetch(queue.env, build.id)
-		if current_build.status != Build.IN_PROGRESS or current_build.slave != self.name:
-                    raise beep.ProtocolError(550, 'Build %s has been invalidated, will not accept completed steps from slave %s' % (build.id, self.name))
-		
-	
+                # verify that the build hasn't been modified out from
+                # under us-- we don't want to accept any build information
+                # from builds that have been invalidated or claimed by
+                # other slaves.
+                current_build = Build.fetch(queue.env, build.id)
+                if current_build.status != Build.IN_PROGRESS or \
+                        current_build.slave != self.name:
+                    raise beep.ProtocolError(550, 'Build %s has been '
+                        'invalidated, will not accept completed steps from '
+                        'slave %s' % (build.id, self.name))
+        
                 if elem.name == 'started':
                     self._build_started(queue, build, elem, timestamp_delta)
                 elif elem.name == 'step':
@@ -302,7 +305,7 @@
             step.started -= timestamp_delta
             step.stopped -= timestamp_delta
         if elem.attr['result'] == 'failure':
-	    log.warning('Build %s Step %s failed', build.id, elem.attr['id']) 
+            log.warning('Build %s Step %s failed', build.id, elem.attr['id']) 
             step.status = BuildStep.FAILURE
         else:
             step.status = BuildStep.SUCCESS
--- a/bitten/model.py
+++ b/bitten/model.py
@@ -730,8 +730,8 @@
         if self.messages:
             cursor.executemany("INSERT INTO bitten_log_message "
                                "(log,line,level,message) VALUES (%s,%s,%s,%s)",
-                               [(id, idx, message[0], message[1]) for idx, message
-                                in enumerate(self.messages)])
+                               [(id, idx, msg[0], msg[1]) for idx, msg in
+                                enumerate(self.messages)])
 
         if handle_ta:
             db.commit()
--- a/bitten/queue.py
+++ b/bitten/queue.py
@@ -119,20 +119,20 @@
         Otherwise, this function will return C{(None, None)}
         """
         log.debug('Checking for pending builds...')
-	if len(available_slaves) == 0: 
+        if len(available_slaves) == 0: 
             log.debug('No available slaves.')
             return None, None
 
         repos = self.env.get_repository()
 
-	# delete any old builds.
+        # delete any old builds.
         builds_to_delete = []
         try:
             for build in Build.select(self.env, status=Build.PENDING):
-		if self.should_delete_build(build, repos):
-		   builds_to_delete.append(build)
+                if self.should_delete_build(build, repos):
+                   builds_to_delete.append(build)
         finally:
-            db = self.env.get_db_cnx()	
+            db = self.env.get_db_cnx()  
             for build in builds_to_delete:
                 build.delete(db=db)
 
@@ -143,32 +143,32 @@
         # revisions are done/in progress for our set of available
         # slaves, we'll just fall back to processing the remaining
         # builds in descending revision order. First thing we'll do is
-	# figure out the newest revision that has a build for each config.
+        # figure out the newest revision that has a build for each config.
 
-	# now make sure all the newest revisions of each config that can be
-	# built are in-progress or done.
-        for config in BuildConfig.select(self.env):	
-	    # need to loop to get all target platforms of the
+        # now make sure all the newest revisions of each config that can be
+        # built are in-progress or done.
+        for config in BuildConfig.select(self.env):     
+            # need to loop to get all target platforms of the
             # newest revision
-	    newest_rev = -1
+            newest_rev = -1
             for build in Build.select(self.env, config.name):
-		if build.rev < newest_rev:
-		   break
-		if self.should_delete_build(build, repos):
-		   continue
-		newest_rev = build.rev
+                if build.rev < newest_rev:
+                   break
+                if self.should_delete_build(build, repos):
+                   continue
+                newest_rev = build.rev
 
-		if build.status == Build.PENDING:
-   	            slaves = self.slaves.get(build.platform, [])
-	            for idx, slave in enumerate([name for name in slaves
-						 if name in available_slaves]):
+                if build.status == Build.PENDING:
+                    slaves = self.slaves.get(build.platform, [])
+                    for idx, slave in enumerate([name for name in slaves
+                                                 if name in available_slaves]):
                         slaves.append(slaves.pop(idx)) # Round robin 
                         return build, slave
 
-	# now just assign anyone who's left
+        # now just assign anyone who's left
         for build in Build.select(self.env, status=Build.PENDING):
-	    if self.should_delete_build(build, repos):
-		continue
+            if self.should_delete_build(build, repos):
+                continue
             # Find a slave for the build platform that is not already building
             # something else
             slaves = self.slaves.get(build.platform, [])
@@ -183,7 +183,7 @@
     def should_delete_build(self, build, repos):
         # Ignore pending builds for deactived build configs
         config = BuildConfig.fetch(self.env, build.config)
-        if not config.active:	
+        if not config.active:   
             log.info('Dropping build of configuration "%s" at '
                      'revision [%s] on "%s" because the configuration is '
                      'deactivated', config.name, build.rev, TargetPlatform.fetch(self.env, build.platform).name)
@@ -199,8 +199,8 @@
                      'revision [%s] on "%s" because it is outside of the '
                      'revision range of the configuration', config.name,
                      build.rev, TargetPlatform.fetch(self.env, build.platform).name)
-	    return True
-	return False
+            return True
+        return False
 
     def populate(self):
         """Add a build for the next change on each build configuration to the
--- a/bitten/recipe.py
+++ b/bitten/recipe.py
@@ -127,7 +127,10 @@
             try:
                 xml_elem = xmlio.Fragment()
                 for child in xmlio.parse(fileobj).children():
-		    child_elem = xmlio.Element(child.name, **dict([(name, value) for name, value in child.attr.items() if value is not None]))	
+                    child_elem = xmlio.Element(child.name, **dict([
+                        (name, value) for name, value in child.attr.items()
+                        if value is not None
+                    ]))
                     xml_elem.append(child_elem[
                         [xmlio.Element(grandchild.name)[grandchild.gettext()]
                         for grandchild in child.children()]
--- a/bitten/slave.py
+++ b/bitten/slave.py
@@ -58,15 +58,15 @@
             os.makedirs(work_dir)
         self.work_dir = work_dir
         self.keep_files = keep_files
-	self.single_build = single_build
-	self.schedule(120, self._send_heartbeat)
+        self.single_build = single_build
+        self.schedule(120, self._send_heartbeat)
 
     def _send_heartbeat(self):
         for channelno in self.channels.keys():
             if channelno == 0:
                 log.info("Sending heartbeat on channel %s" % channelno);
                 self.channels[channelno].send_heartbeat()
-	self.schedule(120, self._send_heartbeat)
+        self.schedule(120, self._send_heartbeat)
 
 
     def greeting_received(self, profiles):
@@ -167,9 +167,9 @@
                 if not self.session.keep_files:
                     shutil.rmtree(basedir)
                     os.remove(archive_path)
-	        if self.session.single_build:
-	            log.info('Exiting after single build completion.')
-	            self.session.quit()
+                if self.session.single_build:
+                    log.info('Exiting after single build completion.')
+                    self.session.quit()
 
     def unpack_snapshot(self, project_dir, archive_name):
         """Unpack a snapshot archive.
@@ -356,7 +356,7 @@
     slave = Slave(host, port, name=options.name, config=options.config,
                   dry_run=options.dry_run, work_dir=options.work_dir,
                   keep_files=options.keep_files, 
- 	          single_build=options.single_build)
+                  single_build=options.single_build)
     try:
         slave.run()
     except KeyboardInterrupt:
--- a/bitten/util/beep.py
+++ b/bitten/util/beep.py
@@ -122,27 +122,29 @@
         granularity = timedelta(seconds=granularity)
         socket_map = asyncore.socket_map
         last_event_check = datetime.min
-	try: 
+        try:
             while socket_map:
                 now = datetime.now()
                 if now - last_event_check >= granularity:
                     last_event_check = now
                     while self.eventqueue:
                         when, callback = heappop(self.eventqueue)
-		        if now < when:
+                        if now < when:
                             heappush(self.eventqueue, (when, callback))
-			    log.debug('Checking done %d events.', len(self.eventqueue))
+                            log.debug('Checking done %d events.',
+                                      len(self.eventqueue))
                             break
-	                try:
+                        try:
                             callback()
-	                except:
-                            log.error('Exception caught firing callback %s. Ignoring.', callback.__name__)
-		try: 
+                        except:
+                            log.error('Exception caught firing callback %s. '
+                                      'Ignoring.', callback.__name__)
+                try: 
                     asyncore.loop(timeout, True, None, 1)
-		except: 
-		    log.error('Exception caught in asyncore.loop, ignoring.');
-	except:
-	    log.error('Exception caught in run()');
+                except: 
+                    log.error('Exception caught in asyncore.loop, ignoring.');
+        except:
+            log.error('Exception caught in run()');
 
 
     def schedule(self, delta, callback):
@@ -524,7 +526,7 @@
         @param payload: The message payload (a `Payload` instance)
         @param handle_reply: A function that is called when a reply to this
                              message is received
-	@param force_flush: Flush the beep channel after sending the message
+        @param force_flush: Flush the beep channel after sending the message
         @return: the message number assigned to the message
         """
         while True: # Find a unique message number
@@ -535,11 +537,11 @@
         if handle_reply is not None:
             assert callable(handle_reply), 'Reply handler must be callable'
             self.reply_handlers[msgno] = handle_reply
-	if force_flush == True:
+        if force_flush == True:
             self.send_with_producer(FrameProducer(self, 'MSG', msgno, None,
                                                       payload))
-	else: 
- 	    self.session.push_with_producer(FrameProducer(self, 'MSG', msgno, None, payload))
+        else: 
+            self.session.push_with_producer(FrameProducer(self, 'MSG', msgno, None, payload))
 
         return msgno
 
@@ -585,15 +587,15 @@
     def send_with_producer(self, fp): 
         """Sends a message contained in the given FrameProducer to the peer, 
         ensuring the message is flushed before continuing.      
-	""" 
-	# push with producer seems to send the first frame out the door 
-	self.session.push_with_producer(fp) 
-	# if there are any more, make sure they get out as well. 
-	if not fp.done:  
-	    while not fp.done: 
-	       asyncore.loop(count=1) 
-	    # make sure to flush the last bit. 
-	    asyncore.loop(count=1) 
+        """ 
+        # push with producer seems to send the first frame out the door 
+        self.session.push_with_producer(fp) 
+        # if there are any more, make sure they get out as well. 
+        if not fp.done:  
+            while not fp.done: 
+               asyncore.loop(count=1) 
+            # make sure to flush the last bit. 
+            asyncore.loop(count=1) 
 
 class ProfileHandler(object):
     """Abstract base class for handlers of specific BEEP profiles.
Copyright (C) 2012-2017 Edgewall Software