"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/clients/tryclient.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

tryclient.py  (buildbot-3.0.2):tryclient.py  (buildbot-3.1.0)
skipping to change at line 98 skipping to change at line 98
def readPatch(self, diff, patchlevel): def readPatch(self, diff, patchlevel):
if not diff: if not diff:
diff = None diff = None
self.patch = (patchlevel, bytes2unicode(diff)) self.patch = (patchlevel, bytes2unicode(diff))
def done(self, res): def done(self, res):
if not self.repository: if not self.repository:
self.repository = self.treetop self.repository = self.treetop
# TODO: figure out the branch and project too # TODO: figure out the branch and project too
ss = SourceStamp(self.branch, self.baserev, self.patch, ss = SourceStamp(bytes2unicode(self.branch), self.baserev, self.patch,
repository=self.repository) repository=self.repository)
return ss return ss
class CVSExtractor(SourceStampExtractor): class CVSExtractor(SourceStampExtractor):
patchlevel = 0 patchlevel = 0
vcexe = "cvs" vcexe = "cvs"
def getBaseRevision(self): def getBaseRevision(self):
# this depends upon our local clock and the repository's clock being # this depends upon our local clock and the repository's clock being
# reasonably synchronized with each other. We express everything in # reasonably synchronized with each other. We express everything in
skipping to change at line 620 skipping to change at line 620
"Revision: {}\n\tBuilders: {}\n{}".format( "Revision: {}\n\tBuilders: {}\n{}".format(
ss.repository, self.project, ss.branch, ss.repository, self.project, ss.branch,
ss.revision, ss.revision,
self.builderNames, self.builderNames,
ss.patch[1])) ss.patch[1]))
self.buildsetStatus = FakeBuildSetStatus() self.buildsetStatus = FakeBuildSetStatus()
d = defer.Deferred() d = defer.Deferred()
d.callback(True) d.callback(True)
return d return d
def deliverJob(self): def deliver_job_ssh(self):
# returns a Deferred that fires when the job has been delivered tryhost = self.getopt("host")
if self.connect == "ssh": tryport = self.getopt("port")
tryhost = self.getopt("host") tryuser = self.getopt("username")
tryport = self.getopt("port") trydir = self.getopt("jobdir")
tryuser = self.getopt("username") buildbotbin = self.getopt("buildbotbin")
trydir = self.getopt("jobdir") ssh_command = self.getopt("ssh")
buildbotbin = self.getopt("buildbotbin") if not ssh_command:
ssh_command = self.getopt("ssh") ssh_commands = which("ssh")
if not ssh_command: if not ssh_commands:
ssh_commands = which("ssh") raise RuntimeError("couldn't find ssh executable, make sure "
if not ssh_commands: "it is available in the PATH")
raise RuntimeError("couldn't find ssh executable, make sure
"
"it is available in the PATH")
argv = [ssh_commands[0]] argv = [ssh_commands[0]]
else:
# Split the string on whitespace to allow passing options in
# ssh command too, but preserving whitespace inside quotes to
# allow using paths with spaces in them which is common under
# Windows. And because Windows uses backslashes in paths, we
# can't just use shlex.split there as it would interpret them
# specially, so do it by hand.
if runtime.platformType == 'win32':
# Note that regex here matches the arguments, not the
# separators, as it's simpler to do it like this. And then we
# just need to get all of them together using the slice and
# also remove the quotes from those that were quoted.
argv = [string.strip(a, '"') for a in
re.split(r'''([^" ]+|"[^"]+")''', ssh_command)[1::2]]
else: else:
# Split the string on whitespace to allow passing options in # Do use standard tokenization logic under POSIX.
# ssh command too, but preserving whitespace inside quotes to argv = shlex.split(ssh_command)
# allow using paths with spaces in them which is common under
# Windows. And because Windows uses backslashes in paths, we
# can't just use shlex.split there as it would interpret them
# specially, so do it by hand.
if runtime.platformType == 'win32':
# Note that regex here matches the arguments, not the
# separators, as it's simpler to do it like this. And then w
e
# just need to get all of them together using the slice and
# also remove the quotes from those that were quoted.
argv = [string.strip(a, '"') for a in
re.split(r'''([^" ]+|"[^"]+")''', ssh_command)[1::2]
]
else:
# Do use standard tokenization logic under POSIX.
argv = shlex.split(ssh_command)
if tryuser: if tryuser:
argv += ["-l", tryuser] argv += ["-l", tryuser]
if tryport: if tryport:
argv += ["-p", tryport] argv += ["-p", tryport]
argv += [tryhost, buildbotbin, "tryserver", "--jobdir", trydir] argv += [tryhost, buildbotbin, "tryserver", "--jobdir", trydir]
pp = RemoteTryPP(self.jobfile) pp = RemoteTryPP(self.jobfile)
reactor.spawnProcess(pp, argv[0], argv, os.environ) reactor.spawnProcess(pp, argv[0], argv, os.environ)
d = pp.d d = pp.d
return d return d
if self.connect == "pb":
user = self.getopt("username") @defer.inlineCallbacks
passwd = self.getopt("passwd") def deliver_job_pb(self):
master = self.getopt("master") user = self.getopt("username")
tryhost, tryport = master.split(":") passwd = self.getopt("passwd")
tryport = int(tryport) master = self.getopt("master")
f = pb.PBClientFactory() tryhost, tryport = master.split(":")
d = f.login(credentials.UsernamePassword(unicode2bytes(user), unicod tryport = int(tryport)
e2bytes(passwd))) f = pb.PBClientFactory()
reactor.connectTCP(tryhost, tryport, f) d = f.login(credentials.UsernamePassword(unicode2bytes(user), unicode2by
d.addCallback(self._deliverJob_pb) tes(passwd)))
return d reactor.connectTCP(tryhost, tryport, f)
raise RuntimeError("unknown connecttype '{}', " remote = yield d
"should be 'ssh' or 'pb'".format(self.connect))
def _deliverJob_pb(self, remote):
ss = self.sourcestamp ss = self.sourcestamp
output("Delivering job; comment=", self.comment) output("Delivering job; comment=", self.comment)
d = remote.callRemote("try", self.buildsetStatus = \
ss.branch, yield remote.callRemote("try", ss.branch, ss.revision, ss.patch, ss.
ss.revision, repository,
ss.patch, self.project, self.builderNames, self.who, s
ss.repository, elf.comment,
self.project, self.config.get('properties', {}))
self.builderNames,
self.who, def deliverJob(self):
self.comment, # returns a Deferred that fires when the job has been delivered
self.config.get('properties', {})) if self.connect == "ssh":
d.addCallback(self._deliverJob_pb2) return self.deliver_job_ssh()
return d if self.connect == "pb":
return self.deliver_job_pb()
def _deliverJob_pb2(self, status): raise RuntimeError("unknown connecttype '{}', "
self.buildsetStatus = status "should be 'ssh' or 'pb'".format(self.connect))
return status
def getStatus(self): def getStatus(self):
# returns a Deferred that fires when the builds have finished, and # returns a Deferred that fires when the builds have finished, and
# may emit status messages while we wait # may emit status messages while we wait
wait = bool(self.getopt("wait")) wait = bool(self.getopt("wait"))
if not wait: if not wait:
output("not waiting for builds to finish") output("not waiting for builds to finish")
elif self.connect == "ssh": elif self.connect == "ssh":
output("waiting for builds with ssh is not supported") output("waiting for builds with ssh is not supported")
else: else:
self.running = defer.Deferred() self.running = defer.Deferred()
assert self.buildsetStatus if not self.buildsetStatus:
self._getStatus_1() output("try scheduler on the master does not have the builder co
nfigured")
return None
self._getStatus_1() # note that we don't wait for the returned Defe
rred
if bool(self.config.get("dryrun")): if bool(self.config.get("dryrun")):
self.statusDone() self.statusDone()
return self.running return self.running
return None return None
def _getStatus_1(self, res=None): @defer.inlineCallbacks
if res: def _getStatus_1(self):
self.buildsetStatus = res
# gather the set of BuildRequests # gather the set of BuildRequests
d = self.buildsetStatus.callRemote("getBuildRequests") brs = yield self.buildsetStatus.callRemote("getBuildRequests")
d.addCallback(self._getStatus_2)
def _getStatus_2(self, brs):
self.builderNames = [] self.builderNames = []
self.buildRequests = {} self.buildRequests = {}
# self.builds holds the current BuildStatus object for each one # self.builds holds the current BuildStatus object for each one
self.builds = {} self.builds = {}
# self.outstanding holds the list of builderNames which haven't # self.outstanding holds the list of builderNames which haven't
# finished yet # finished yet
self.outstanding = [] self.outstanding = []
skipping to change at line 784 skipping to change at line 777
def remote_stepStarted(self, buildername, build, stepname, step): def remote_stepStarted(self, buildername, build, stepname, step):
self.currentStep[buildername] = stepname self.currentStep[buildername] = stepname
def remote_stepFinished(self, buildername, build, stepname, step, results): def remote_stepFinished(self, buildername, build, stepname, step, results):
pass pass
def remote_buildETAUpdate(self, buildername, build, eta): def remote_buildETAUpdate(self, buildername, build, eta):
self.ETA[buildername] = now() + eta self.ETA[buildername] = now() + eta
@defer.inlineCallbacks
def _build_finished(self, bs, builderName): def _build_finished(self, bs, builderName):
# we need to collect status from the newly-finished build. We don't # we need to collect status from the newly-finished build. We don't
# remove the build from self.outstanding until we've collected # remove the build from self.outstanding until we've collected
# everything we want. # everything we want.
self.builds[builderName] = None self.builds[builderName] = None
self.ETA[builderName] = None self.ETA[builderName] = None
self.currentStep[builderName] = "finished" self.currentStep[builderName] = "finished"
d = bs.callRemote("getResults")
d.addCallback(self._build_finished_2, bs, builderName)
return d
def _build_finished_2(self, results, bs, builderName):
self.results[builderName][0] = results
d = bs.callRemote("getText")
d.addCallback(self._build_finished_3, builderName)
return d
def _build_finished_3(self, text, builderName): self.results[builderName][0] = yield bs.callRemote("getResults")
self.results[builderName][1] = text self.results[builderName][1] = yield bs.callRemote("getText")
self.outstanding.remove(builderName) self.outstanding.remove(builderName)
if not self.outstanding: if not self.outstanding:
# all done self.statusDone()
return self.statusDone()
return None
def printStatus(self): def printStatus(self):
try: try:
names = sorted(self.buildRequests.keys()) names = sorted(self.buildRequests.keys())
for n in names: for n in names:
if n not in self.outstanding: if n not in self.outstanding:
# the build is finished, and we have results # the build is finished, and we have results
code, text = self.results[n] code, text = self.results[n]
t = Results[code] t = Results[code]
if text: if text:
skipping to change at line 854 skipping to change at line 837
output(t) output(t)
if code != SUCCESS: if code != SUCCESS:
happy = False happy = False
if happy: if happy:
self.exitcode = 0 self.exitcode = 0
else: else:
self.exitcode = 1 self.exitcode = 1
self.running.callback(self.exitcode) self.running.callback(self.exitcode)
@defer.inlineCallbacks
def getAvailableBuilderNames(self): def getAvailableBuilderNames(self):
# This logs into the master using the PB protocol to # This logs into the master using the PB protocol to
# get the names of the configured builders that can # get the names of the configured builders that can
# be used for the --builder argument # be used for the --builder argument
if self.connect == "pb": if self.connect == "pb":
user = self.getopt("username") user = self.getopt("username")
passwd = self.getopt("passwd") passwd = self.getopt("passwd")
master = self.getopt("master") master = self.getopt("master")
tryhost, tryport = master.split(":") tryhost, tryport = master.split(":")
tryport = int(tryport) tryport = int(tryport)
f = pb.PBClientFactory() f = pb.PBClientFactory()
d = f.login(credentials.UsernamePassword(unicode2bytes(user), unicod e2bytes(passwd))) d = f.login(credentials.UsernamePassword(unicode2bytes(user), unicod e2bytes(passwd)))
reactor.connectTCP(tryhost, tryport, f) reactor.connectTCP(tryhost, tryport, f)
d.addCallback(self._getBuilderNames) remote = yield d
return d buildernames = yield remote.callRemote("getAvailableBuilderNames")
output("The following builders are available for the try scheduler:
")
for buildername in buildernames:
output(buildername)
yield remote.broker.transport.loseConnection()
return
if self.connect == "ssh": if self.connect == "ssh":
output("Cannot get available builders over ssh.") output("Cannot get available builders over ssh.")
sys.exit(1) sys.exit(1)
raise RuntimeError( raise RuntimeError(
"unknown connecttype '{}', should be 'pb'".format(self.connect)) "unknown connecttype '{}', should be 'pb'".format(self.connect))
def _getBuilderNames(self, remote):
d = remote.callRemote("getAvailableBuilderNames")
d.addCallback(self._getBuilderNames2)
d.addCallback(lambda _: remote.broker.transport.loseConnection())
return d
def _getBuilderNames2(self, buildernames):
output("The following builders are available for the try scheduler: ")
for buildername in buildernames:
output(buildername)
def announce(self, message): def announce(self, message):
if not self.quiet: if not self.quiet:
output(message) output(message)
def run(self, _inTests=False): @defer.inlineCallbacks
# we can't do spawnProcess until we're inside reactor.run(), so get def run_impl(self):
# funky
output("using '{}' connect method".format(self.connect)) output("using '{}' connect method".format(self.connect))
self.exitcode = 0 self.exitcode = 0
d = fireEventually(None)
if bool(self.config.get("get-builder-names")): # we can't do spawnProcess until we're inside reactor.run(), so force as
d.addCallback(lambda res: self.getAvailableBuilderNames()) ynchronous execution
else: yield fireEventually(None)
d.addCallback(lambda res: self.createJob())
d.addCallback(lambda res: self.announce("job created")) try:
deliver = self.deliverJob if bool(self.config.get("get-builder-names")):
if bool(self.config.get("dryrun")): yield self.getAvailableBuilderNames()
deliver = self.fakeDeliverJob else:
d.addCallback(lambda res: deliver()) yield self.createJob()
d.addCallback(lambda res: self.announce("job has been delivered")) yield self.announce("job created")
d.addCallback(lambda res: self.getStatus()) if bool(self.config.get("dryrun")):
d.addErrback(self.trapSystemExit) yield self.fakeDeliverJob()
d.addErrback(log.err) else:
if not bool(self.config.get("dryrun")): yield self.deliverJob()
d.addCallback(self.cleanup) yield self.announce("job has been delivered")
if _inTests: yield self.getStatus()
return d
if not bool(self.config.get("dryrun")):
yield self.cleanup()
except SystemExit as e:
self.exitcode = e.code
except Exception as e:
log.err(e)
raise
def run(self):
d = self.run_impl()
d.addCallback(lambda res: reactor.stop()) d.addCallback(lambda res: reactor.stop())
reactor.run() reactor.run()
sys.exit(self.exitcode) sys.exit(self.exitcode)
def trapSystemExit(self, why): def trapSystemExit(self, why):
why.trap(SystemExit) why.trap(SystemExit)
self.exitcode = why.value.code self.exitcode = why.value.code
def cleanup(self, res=None): def cleanup(self, res=None):
 End of changes. 22 change blocks. 
131 lines changed or deleted 122 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)