Package buildbot :: Package clients :: Module tryclient
[frames] | no frames]

Source Code for Module buildbot.clients.tryclient

  1  # -*- test-case-name: buildbot.test.test_scheduler,buildbot.test.test_vc -*- 
  2   
  3  import sys, os, re, time, random 
  4  from twisted.internet import utils, protocol, defer, reactor, task 
  5  from twisted.spread import pb 
  6  from twisted.cred import credentials 
  7  from twisted.python import log 
  8  from twisted.python.procutils import which 
  9   
 10  from buildbot.sourcestamp import SourceStamp 
 11  from buildbot.util import now 
 12  from buildbot.status import builder 
 13   
14 -class SourceStampExtractor:
15
16 - def __init__(self, treetop, branch):
17 self.treetop = treetop # also is repository 18 self.branch = branch 19 self.exe = which(self.vcexe)[0]
20
21 - def dovc(self, cmd):
22 """This accepts the arguments of a command, without the actual 23 command itself.""" 24 env = os.environ.copy() 25 env['LC_ALL'] = "C" 26 d = utils.getProcessOutputAndValue(self.exe, cmd, env=env, 27 path=self.treetop) 28 d.addCallback(self._didvc, cmd) 29 return d
30 - def _didvc(self, res, cmd):
31 (stdout, stderr, code) = res 32 # 'bzr diff' sets rc=1 if there were any differences. 33 # cvs does something similar, so don't bother requring rc=0. 34 return stdout
35
36 - def get(self):
37 """Return a Deferred that fires with a SourceStamp instance.""" 38 d = self.getBaseRevision() 39 d.addCallback(self.getPatch) 40 d.addCallback(self.done) 41 return d
42 - def readPatch(self, res, patchlevel):
43 self.patch = (patchlevel, res)
44 - def done(self, res):
45 # TODO: figure out the branch and project too 46 ss = SourceStamp(self.branch, self.baserev, self.patch, 47 repository=self.treetop) 48 return ss
49
50 -class CVSExtractor(SourceStampExtractor):
51 patchlevel = 0 52 vcexe = "cvs"
53 - def getBaseRevision(self):
54 # this depends upon our local clock and the repository's clock being 55 # reasonably synchronized with each other. We express everything in 56 # UTC because the '%z' format specifier for strftime doesn't always 57 # work. 58 self.baserev = time.strftime("%Y-%m-%d %H:%M:%S +0000", 59 time.gmtime(now())) 60 return defer.succeed(None)
61
62 - def getPatch(self, res):
63 # the -q tells CVS to not announce each directory as it works 64 if self.branch is not None: 65 # 'cvs diff' won't take both -r and -D at the same time (it 66 # ignores the -r). As best I can tell, there is no way to make 67 # cvs give you a diff relative to a timestamp on the non-trunk 68 # branch. A bare 'cvs diff' will tell you about the changes 69 # relative to your checked-out versions, but I know of no way to 70 # find out what those checked-out versions are. 71 raise RuntimeError("Sorry, CVS 'try' builds don't work with " 72 "branches") 73 args = ['-q', 'diff', '-u', '-D', self.baserev] 74 d = self.dovc(args) 75 d.addCallback(self.readPatch, self.patchlevel) 76 return d
77
78 -class SVNExtractor(SourceStampExtractor):
79 patchlevel = 0 80 vcexe = "svn" 81
82 - def getBaseRevision(self):
83 d = self.dovc(["status", "-u"]) 84 d.addCallback(self.parseStatus) 85 return d
86 - def parseStatus(self, res):
87 # svn shows the base revision for each file that has been modified or 88 # which needs an update. You can update each file to a different 89 # version, so each file is displayed with its individual base 90 # revision. It also shows the repository-wide latest revision number 91 # on the last line ("Status against revision: \d+"). 92 93 # for our purposes, we use the latest revision number as the "base" 94 # revision, and get a diff against that. This means we will get 95 # reverse-diffs for local files that need updating, but the resulting 96 # tree will still be correct. The only weirdness is that the baserev 97 # that we emit may be different than the version of the tree that we 98 # first checked out. 99 100 # to do this differently would probably involve scanning the revision 101 # numbers to find the max (or perhaps the min) revision, and then 102 # using that as a base. 103 104 for line in res.split("\n"): 105 m = re.search(r'^Status against revision:\s+(\d+)', line) 106 if m: 107 self.baserev = int(m.group(1)) 108 return 109 raise IndexError("Could not find 'Status against revision' in " 110 "SVN output: %s" % res)
111 - def getPatch(self, res):
112 d = self.dovc(["diff", "-r%d" % self.baserev]) 113 d.addCallback(self.readPatch, self.patchlevel) 114 return d
115
116 -class BzrExtractor(SourceStampExtractor):
117 patchlevel = 0 118 vcexe = "bzr"
119 - def getBaseRevision(self):
120 d = self.dovc(["revision-info","-rsubmit:"]) 121 d.addCallback(self.get_revision_number) 122 return d
123
124 - def get_revision_number(self, out):
125 revno, revid= out.split() 126 self.baserev = 'revid:' + revid 127 return
128
129 - def getPatch(self, res):
130 d = self.dovc(["diff","-r%s.." % self.baserev]) 131 d.addCallback(self.readPatch, self.patchlevel) 132 return d
133
134 -class MercurialExtractor(SourceStampExtractor):
135 patchlevel = 1 136 vcexe = "hg"
137 - def getBaseRevision(self):
138 d = self.dovc(["identify", "--id", "--debug"]) 139 d.addCallback(self.parseStatus) 140 return d
141 - def parseStatus(self, output):
142 m = re.search(r'^(\w+)', output) 143 self.baserev = m.group(0)
144 - def getPatch(self, res):
145 d = self.dovc(["diff"]) 146 d.addCallback(self.readPatch, self.patchlevel) 147 return d
148 149
150 -class PerforceExtractor(SourceStampExtractor):
151 patchlevel = 0 152 vcexe = "p4"
153 - def getBaseRevision(self):
154 d = self.dovc(["changes", "-m1", "..."]) 155 d.addCallback(self.parseStatus) 156 return d
157
158 - def parseStatus(self, res):
159 # 160 # extract the base change number 161 # 162 m = re.search(r'Change (\d+)',res) 163 if m: 164 self.baserev = m.group(1) 165 return 166 167 raise IndexError("Could not find change number in output: %s" % res)
168
169 - def readPatch(self, res, patchlevel):
170 # 171 # extract the actual patch from "res" 172 # 173 assert self.branch, "you must specify a branch" 174 mpatch = "" 175 found = False 176 for line in res.split("\n"): 177 m = re.search('==== //depot/' + self.branch + r'/([\w\/\.\d\-\_]+)#(\d+) -',line) 178 if m: 179 mpatch += "--- %s#%s\n" % (m.group(1), m.group(2) ) 180 mpatch += "+++ %s\n" % (m.group(1) ) 181 found = True 182 else: 183 mpatch += line 184 mpatch += "\n" 185 assert found, "could not parse patch file" 186 self.patch = (patchlevel, mpatch)
187 - def getPatch(self, res):
188 d = self.dovc(["diff", "-du"]) 189 d.addCallback(self.readPatch, self.patchlevel) 190 return d
191 192
193 -class DarcsExtractor(SourceStampExtractor):
194 patchlevel = 1 195 vcexe = "darcs"
196 - def getBaseRevision(self):
197 d = self.dovc(["changes", "--context"]) 198 d.addCallback(self.parseStatus) 199 return d
200 - def parseStatus(self, res):
201 self.baserev = res # the whole context file
202 - def getPatch(self, res):
203 d = self.dovc(["diff", "-u"]) 204 d.addCallback(self.readPatch, self.patchlevel) 205 return d
206
207 -class GitExtractor(SourceStampExtractor):
208 patchlevel = 1 209 vcexe = "git" 210
211 - def getBaseRevision(self):
212 d = self.dovc(["branch", "--no-color", "-v", "--no-abbrev"]) 213 d.addCallback(self.parseStatus) 214 return d
215
216 - def readConfig(self):
217 d = self.dovc(["config", "-l"]) 218 d.addCallback(self.parseConfig) 219 return d
220
221 - def parseConfig(self, res):
222 git_config = {} 223 for l in res.split("\n"): 224 if l.strip(): 225 parts = l.strip().split("=", 2) 226 git_config[parts[0]] = parts[1] 227 228 # If we're tracking a remote, consider that the base. 229 remote = git_config.get("branch." + self.branch + ".remote") 230 ref = git_config.get("branch." + self.branch + ".merge") 231 if remote and ref: 232 remote_branch = ref.split("/", 3)[-1] 233 d = self.dovc(["rev-parse", remote + "/" + remote_branch]) 234 d.addCallback(self.override_baserev) 235 return d
236
237 - def override_baserev(self, res):
238 self.baserev = res.strip()
239
240 - def parseStatus(self, res):
241 # The current branch is marked by '*' at the start of the 242 # line, followed by the branch name and the SHA1. 243 # 244 # Branch names may contain pretty much anything but whitespace. 245 m = re.search(r'^\* (\S+)\s+([0-9a-f]{40})', res, re.MULTILINE) 246 if m: 247 self.baserev = m.group(2) 248 # If a branch is specified, parse out the rev it points to 249 # and extract the local name (assuming it has a slash). 250 # This may break if someone specifies the name of a local 251 # branch that has a slash in it and has no corresponding 252 # remote branch (or something similarly contrived). 253 if self.branch: 254 d = self.dovc(["rev-parse", self.branch]) 255 if '/' in self.branch: 256 self.branch = self.branch.split('/', 1)[1] 257 d.addCallback(self.override_baserev) 258 return d 259 else: 260 self.branch = m.group(1) 261 return self.readConfig() 262 raise IndexError("Could not find current GIT branch: %s" % res)
263
264 - def getPatch(self, res):
265 d = self.dovc(["diff", self.baserev]) 266 d.addCallback(self.readPatch, self.patchlevel) 267 return d
268
269 -def getSourceStamp(vctype, treetop, branch=None):
270 if vctype == "cvs": 271 e = CVSExtractor(treetop, branch) 272 elif vctype == "svn": 273 e = SVNExtractor(treetop, branch) 274 elif vctype == "bzr": 275 e = BzrExtractor(treetop, branch) 276 elif vctype == "hg": 277 e = MercurialExtractor(treetop, branch) 278 elif vctype == "p4": 279 e = PerforceExtractor(treetop, branch) 280 elif vctype == "darcs": 281 e = DarcsExtractor(treetop, branch) 282 elif vctype == "git": 283 e = GitExtractor(treetop, branch) 284 else: 285 raise KeyError("unknown vctype '%s'" % vctype) 286 return e.get()
287 288
289 -def ns(s):
290 return "%d:%s," % (len(s), s)
291
292 -def createJobfile(bsid, branch, baserev, patchlevel, diff, repository, 293 project, builderNames):
294 job = "" 295 job += ns("2") 296 job += ns(bsid) 297 job += ns(branch) 298 job += ns(str(baserev)) 299 job += ns("%d" % patchlevel) 300 job += ns(diff) 301 job += ns(repository) 302 job += ns(project) 303 for bn in builderNames: 304 job += ns(bn) 305 return job
306
307 -def getTopdir(topfile, start=None):
308 """walk upwards from the current directory until we find this topfile""" 309 if not start: 310 start = os.getcwd() 311 here = start 312 toomany = 20 313 while toomany > 0: 314 if os.path.exists(os.path.join(here, topfile)): 315 return here 316 next = os.path.dirname(here) 317 if next == here: 318 break # we've hit the root 319 here = next 320 toomany -= 1 321 raise ValueError("Unable to find topfile '%s' anywhere from %s upwards" 322 % (topfile, start))
323
324 -class RemoteTryPP(protocol.ProcessProtocol):
325 - def __init__(self, job):
326 self.job = job 327 self.d = defer.Deferred()
328 - def connectionMade(self):
329 self.transport.write(self.job) 330 self.transport.closeStdin()
331 - def outReceived(self, data):
332 sys.stdout.write(data)
333 - def errReceived(self, data):
334 sys.stderr.write(data)
335 - def processEnded(self, status_object):
336 sig = status_object.value.signal 337 rc = status_object.value.exitCode 338 if sig != None or rc != 0: 339 self.d.errback(RuntimeError("remote 'buildbot tryserver' failed" 340 ": sig=%s, rc=%s" % (sig, rc))) 341 return 342 self.d.callback((sig, rc))
343
344 -class BuildSetStatusGrabber:
345 retryCount = 5 # how many times to we try to grab the BuildSetStatus? 346 retryDelay = 3 # seconds to wait between attempts 347
348 - def __init__(self, status, bsid):
349 self.status = status 350 self.bsid = bsid
351
352 - def grab(self):
353 # return a Deferred that either fires with the BuildSetStatus 354 # reference or errbacks because we were unable to grab it 355 self.d = defer.Deferred() 356 # wait a second before querying to give the master's maildir watcher 357 # a chance to see the job 358 reactor.callLater(1, self.go) 359 return self.d
360
361 - def go(self, dummy=None):
362 if self.retryCount == 0: 363 raise RuntimeError("couldn't find matching buildset") 364 self.retryCount -= 1 365 d = self.status.callRemote("getBuildSets") 366 d.addCallback(self._gotSets)
367
368 - def _gotSets(self, buildsets):
369 for bs,bsid in buildsets: 370 if bsid == self.bsid: 371 # got it 372 self.d.callback(bs) 373 return 374 d = defer.Deferred() 375 d.addCallback(self.go) 376 reactor.callLater(self.retryDelay, d.callback, None)
377 378
379 -class Try(pb.Referenceable):
380 buildsetStatus = None 381 quiet = False 382
383 - def __init__(self, config):
384 self.config = config 385 self.connect = self.getopt('connect') 386 assert self.connect, "you must specify a connect style: ssh or pb" 387 self.builderNames = self.getopt('builders') 388 self.project = self.getopt('project', '')
389
390 - def getopt(self, config_name, default=None):
391 value = self.config.get(config_name) 392 if value is None or value == []: 393 value = default 394 return value
395
396 - def createJob(self):
397 # returns a Deferred which fires when the job parameters have been 398 # created 399 400 # generate a random (unique) string. It would make sense to add a 401 # hostname and process ID here, but a) I suspect that would cause 402 # windows portability problems, and b) really this is good enough 403 self.bsid = "%d-%s" % (time.time(), random.randint(0, 1000000)) 404 405 # common options 406 branch = self.getopt("branch") 407 408 difffile = self.config.get("diff") 409 if difffile: 410 baserev = self.config.get("baserev") 411 if difffile == "-": 412 diff = sys.stdin.read() 413 else: 414 diff = open(difffile,"r").read() 415 patch = (self.config['patchlevel'], diff) 416 ss = SourceStamp(branch, baserev, patch) 417 d = defer.succeed(ss) 418 else: 419 vc = self.getopt("vc") 420 if vc in ("cvs", "svn"): 421 # we need to find the tree-top 422 topdir = self.getopt("try-topdir") 423 if topdir: 424 treedir = os.path.expanduser(topdir) 425 else: 426 topfile = self.getopt("try-topfile") 427 treedir = getTopdir(topfile) 428 else: 429 treedir = os.getcwd() 430 d = getSourceStamp(vc, treedir, branch) 431 d.addCallback(self._createJob_1) 432 return d
433
434 - def _createJob_1(self, ss):
435 self.sourcestamp = ss 436 if self.connect == "ssh": 437 patchlevel, diff = ss.patch 438 revspec = ss.revision 439 if revspec is None: 440 revspec = "" 441 self.jobfile = createJobfile(self.bsid, 442 ss.branch or "", revspec, 443 patchlevel, diff, ss.repository, 444 self.project, self.builderNames)
445
446 - def fakeDeliverJob(self):
447 # Display the job to be delivered, but don't perform delivery. 448 ss = self.sourcestamp 449 print ("Job:\n\tRepository: %s\n\tProject: %s\n\tBranch: %s\n\t" 450 "Revision: %s\n\tBuilders: %s\n%s" 451 % (ss.repository, self.project, ss.branch, 452 ss.revision, 453 self.builderNames, 454 ss.patch[1])) 455 d = defer.Deferred() 456 d.callback(True) 457 return d
458
459 - def deliverJob(self):
460 # returns a Deferred that fires when the job has been delivered 461 462 if self.connect == "ssh": 463 tryhost = self.getopt("tryhost") 464 tryuser = self.getopt("username") 465 trydir = self.getopt("trydir") 466 467 argv = ["ssh", "-l", tryuser, tryhost, 468 "buildbot", "tryserver", "--jobdir", trydir] 469 # now run this command and feed the contents of 'job' into stdin 470 471 pp = RemoteTryPP(self.jobfile) 472 reactor.spawnProcess(pp, argv[0], argv, os.environ) 473 d = pp.d 474 return d 475 if self.connect == "pb": 476 user = self.getopt("username") 477 passwd = self.getopt("passwd") 478 master = self.getopt("master") 479 tryhost, tryport = master.split(":") 480 tryport = int(tryport) 481 f = pb.PBClientFactory() 482 d = f.login(credentials.UsernamePassword(user, passwd)) 483 reactor.connectTCP(tryhost, tryport, f) 484 d.addCallback(self._deliverJob_pb) 485 return d 486 raise RuntimeError("unknown connecttype '%s', should be 'ssh' or 'pb'" 487 % self.connect)
488
489 - def _deliverJob_pb(self, remote):
490 ss = self.sourcestamp 491 492 d = remote.callRemote("try", 493 ss.branch, 494 ss.revision, 495 ss.patch, 496 ss.repository, 497 self.project, 498 self.builderNames, 499 self.config.get('properties', {})) 500 d.addCallback(self._deliverJob_pb2) 501 return d
502 - def _deliverJob_pb2(self, status):
503 self.buildsetStatus = status 504 return status
505
506 - def getStatus(self):
507 # returns a Deferred that fires when the builds have finished, and 508 # may emit status messages while we wait 509 wait = bool(self.getopt("wait", "try_wait")) 510 if not wait: 511 # TODO: emit the URL where they can follow the builds. This 512 # requires contacting the Status server over PB and doing 513 # getURLForThing() on the BuildSetStatus. To get URLs for 514 # individual builds would require we wait for the builds to 515 # start. 516 print "not waiting for builds to finish" 517 return 518 d = self.running = defer.Deferred() 519 if self.buildsetStatus: 520 self._getStatus_1() 521 return self.running 522 # contact the status port 523 # we're probably using the ssh style 524 master = self.getopt("master") 525 host, port = master.split(":") 526 port = int(port) 527 self.announce("contacting the status port at %s:%d" % (host, port)) 528 f = pb.PBClientFactory() 529 creds = credentials.UsernamePassword("statusClient", "clientpw") 530 d = f.login(creds) 531 reactor.connectTCP(host, port, f) 532 d.addCallback(self._getStatus_ssh_1) 533 return self.running
534
535 - def _getStatus_ssh_1(self, remote):
536 # find a remotereference to the corresponding BuildSetStatus object 537 self.announce("waiting for job to be accepted") 538 g = BuildSetStatusGrabber(remote, self.bsid) 539 d = g.grab() 540 d.addCallback(self._getStatus_1) 541 return d
542
543 - def _getStatus_1(self, res=None):
544 if res: 545 self.buildsetStatus = res 546 # gather the set of BuildRequests 547 d = self.buildsetStatus.callRemote("getBuildRequests") 548 d.addCallback(self._getStatus_2)
549
550 - def _getStatus_2(self, brs):
551 self.builderNames = [] 552 self.buildRequests = {} 553 554 # self.builds holds the current BuildStatus object for each one 555 self.builds = {} 556 557 # self.outstanding holds the list of builderNames which haven't 558 # finished yet 559 self.outstanding = [] 560 561 # self.results holds the list of build results. It holds a tuple of 562 # (result, text) 563 self.results = {} 564 565 # self.currentStep holds the name of the Step that each build is 566 # currently running 567 self.currentStep = {} 568 569 # self.ETA holds the expected finishing time (absolute time since 570 # epoch) 571 self.ETA = {} 572 573 for n,br in brs: 574 self.builderNames.append(n) 575 self.buildRequests[n] = br 576 self.builds[n] = None 577 self.outstanding.append(n) 578 self.results[n] = [None,None] 579 self.currentStep[n] = None 580 self.ETA[n] = None 581 # get new Builds for this buildrequest. We follow each one until 582 # it finishes or is interrupted. 583 br.callRemote("subscribe", self) 584 585 # now that those queries are in transit, we can start the 586 # display-status-every-30-seconds loop 587 self.printloop = task.LoopingCall(self.printStatus) 588 self.printloop.start(3, now=False)
589 590 591 # these methods are invoked by the status objects we've subscribed to 592
593 - def remote_newbuild(self, bs, builderName):
594 if self.builds[builderName]: 595 self.builds[builderName].callRemote("unsubscribe", self) 596 self.builds[builderName] = bs 597 bs.callRemote("subscribe", self, 20) 598 d = bs.callRemote("waitUntilFinished") 599 d.addCallback(self._build_finished, builderName)
600
601 - def remote_stepStarted(self, buildername, build, stepname, step):
602 self.currentStep[buildername] = stepname
603
604 - def remote_stepFinished(self, buildername, build, stepname, step, results):
605 pass
606
607 - def remote_buildETAUpdate(self, buildername, build, eta):
608 self.ETA[buildername] = now() + eta
609
610 - def _build_finished(self, bs, builderName):
611 # we need to collect status from the newly-finished build. We don't 612 # remove the build from self.outstanding until we've collected 613 # everything we want. 614 self.builds[builderName] = None 615 self.ETA[builderName] = None 616 self.currentStep[builderName] = "finished" 617 d = bs.callRemote("getResults") 618 d.addCallback(self._build_finished_2, bs, builderName) 619 return d
620 - def _build_finished_2(self, results, bs, builderName):
621 self.results[builderName][0] = results 622 d = bs.callRemote("getText") 623 d.addCallback(self._build_finished_3, builderName) 624 return d
625 - def _build_finished_3(self, text, builderName):
626 self.results[builderName][1] = text 627 628 self.outstanding.remove(builderName) 629 if not self.outstanding: 630 # all done 631 return self.statusDone()
632
633 - def printStatus(self):
634 names = self.buildRequests.keys() 635 names.sort() 636 for n in names: 637 if n not in self.outstanding: 638 # the build is finished, and we have results 639 code,text = self.results[n] 640 t = builder.Results[code] 641 if text: 642 t += " (%s)" % " ".join(text) 643 elif self.builds[n]: 644 t = self.currentStep[n] or "building" 645 if self.ETA[n]: 646 t += " [ETA %ds]" % (self.ETA[n] - now()) 647 else: 648 t = "no build" 649 self.announce("%s: %s" % (n, t)) 650 self.announce("")
651
652 - def statusDone(self):
653 self.printloop.stop() 654 print "All Builds Complete" 655 # TODO: include a URL for all failing builds 656 names = self.buildRequests.keys() 657 names.sort() 658 happy = True 659 for n in names: 660 code,text = self.results[n] 661 t = "%s: %s" % (n, builder.Results[code]) 662 if text: 663 t += " (%s)" % " ".join(text) 664 print t 665 if code != builder.SUCCESS: 666 happy = False 667 668 if happy: 669 self.exitcode = 0 670 else: 671 self.exitcode = 1 672 self.running.callback(self.exitcode)
673
674 - def getAvailableBuilderNames(self):
675 # This logs into the master using the PB protocol to 676 # get the names of the configured builders that can 677 # be used for the --builder argument 678 if self.connect == "pb": 679 user = self.getopt("username", "try_username") 680 passwd = self.getopt("passwd", "try_password") 681 master = self.getopt("master", "try_master") 682 tryhost, tryport = master.split(":") 683 tryport = int(tryport) 684 f = pb.PBClientFactory() 685 d = f.login(credentials.UsernamePassword(user, passwd)) 686 reactor.connectTCP(tryhost, tryport, f) 687 d.addCallback(self._getBuilderNames, self._getBuilderNames2) 688 return d 689 if self.connect == "ssh": 690 raise RuntimeError("ssh connection type not supported for this command") 691 raise RuntimeError("unknown connecttype '%s', should be 'pb'" % self.connect)
692
693 - def _getBuilderNames(self, remote, output):
694 d = remote.callRemote("getAvailableBuilderNames") 695 d.addCallback(self._getBuilderNames2) 696 return d
697
698 - def _getBuilderNames2(self, buildernames):
699 print "The following builders are available for the try scheduler: " 700 for buildername in buildernames: 701 print buildername
702
703 - def announce(self, message):
704 if not self.quiet: 705 print message
706
707 - def run(self):
708 # we can't do spawnProcess until we're inside reactor.run(), so get 709 # funky 710 print "using '%s' connect method" % self.connect 711 self.exitcode = 0 712 d = defer.Deferred() 713 if bool(self.config.get("get-builder-names")): 714 d.addCallback(lambda res: self.getAvailableBuilderNames()) 715 else: 716 d.addCallback(lambda res: self.createJob()) 717 d.addCallback(lambda res: self.announce("job created")) 718 deliver = self.deliverJob 719 if bool(self.config.get("dryrun")): 720 deliver = self.fakeDeliverJob 721 d.addCallback(lambda res: deliver()) 722 d.addCallback(lambda res: self.announce("job has been delivered")) 723 d.addCallback(lambda res: self.getStatus()) 724 d.addErrback(log.err) 725 d.addCallback(self.cleanup) 726 d.addCallback(lambda res: reactor.stop()) 727 728 reactor.callLater(0, d.callback, None) 729 reactor.run() 730 sys.exit(self.exitcode)
731
732 - def logErr(self, why):
733 log.err(why) 734 print "error during 'try' processing" 735 print why
736
737 - def cleanup(self, res=None):
738 if self.buildsetStatus: 739 self.buildsetStatus.broker.transport.loseConnection()
740