~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/model/builder.py

  • Committer: Francis J. Lacoste
  • Date: 2011-07-14 21:49:37 UTC
  • mto: This revision was merged to the branch mainline in revision 13501.
  • Revision ID: francis.lacoste@canonical.com-20110714214937-redwzax7e3ti1wxe
Lint sucks, but hoover blows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
 
172
172
        :param builder_url: The URL of the slave buildd machine,
173
173
            e.g. http://localhost:8221
174
 
        :param vm_host: If the slave is virtual, specify its host machine here.
 
174
        :param vm_host: If the slave is virtual, specify its host machine
 
175
            here.
175
176
        :param reactor: Used by tests to override the Twisted reactor.
176
177
        :param proxy: Used By tests to override the xmlrpc.Proxy.
177
178
        """
216
217
    def getFile(self, sha_sum, file_to_write):
217
218
        """Fetch a file from the builder.
218
219
 
219
 
        :param sha_sum: The sha of the file (which is also its name on the 
 
220
        :param sha_sum: The sha of the file (which is also its name on the
220
221
            builder)
221
222
        :param file_to_write: A file name or file-like object to write
222
223
            the file to
258
259
        resume_command = config.builddmaster.vm_resume_command % {
259
260
            'vm_host': self._vm_host}
260
261
        # Twisted API requires string but the configuration provides unicode.
261
 
        resume_argv = [term.encode('utf-8') for term in resume_command.split()]
 
262
        resume_argv = [
 
263
            term.encode('utf-8') for term in resume_command.split()]
262
264
        d = defer.Deferred()
263
265
        p = ProcessWithTimeout(
264
266
            d, config.builddmaster.socket_timeout, clock=clock)
281
283
    def sendFileToSlave(self, sha1, url, username="", password=""):
282
284
        """Helper to send the file at 'url' with 'sha1' to this builder."""
283
285
        d = self.ensurepresent(sha1, url, username, password)
 
286
 
284
287
        def check_present((present, info)):
285
288
            if not present:
286
289
                raise CannotFetchFile(url, info)
299
302
        """
300
303
        d = self._with_timeout(self._server.callRemote(
301
304
            'build', buildid, builder_type, chroot_sha1, filemap, args))
 
305
 
302
306
        def got_fault(failure):
303
307
            failure.trap(xmlrpclib.Fault)
304
308
            raise BuildSlaveFailure(failure.value)
370
374
                d = builder.cleanSlave()
371
375
            else:
372
376
                d = builder.requestAbort()
 
377
 
373
378
            def log_rescue(ignored):
374
379
                if logger:
375
380
                    logger.info(
514
519
        logger.info("Resuming %s (%s)" % (self.name, self.url))
515
520
 
516
521
        d = self.slave.resume()
 
522
 
517
523
        def got_resume_ok((stdout, stderr, returncode)):
518
524
            return stdout, stderr
 
525
 
519
526
        def got_resume_bad(failure):
520
527
            stdout, stderr, code = failure.value
521
528
            raise CannotResumeHost(
605
612
    def slaveStatus(self):
606
613
        """See IBuilder."""
607
614
        d = self.slave.status()
 
615
 
608
616
        def got_status(status_sentence):
609
617
            status = {'builder_status': status_sentence[0]}
610
618
 
680
688
        if not self.builderok:
681
689
            return defer.succeed(False)
682
690
        d = self.slaveStatusSentence()
 
691
 
683
692
        def catch_fault(failure):
684
693
            failure.trap(xmlrpclib.Fault, socket.error)
685
694
            return False
 
695
 
686
696
        def check_available(status):
687
697
            return status[0] == BuilderStatus.IDLE
688
698
        return d.addCallbacks(check_available, catch_fault)