def start(self): version = self.slaveVersion("uploadFile") if not version: m = "slave is too old, does not know about uploadFile" raise BuildSlaveTooOldError(m) source = render_properties(self.slavesrc, self.build) masterdest = render_properties(self.masterdest, self.build) # we rely upon the fact that the buildmaster runs chdir'ed into its # basedir to make sure that relative paths in masterdest are expanded # properly. TODO: maybe pass the master's basedir all the way down # into the BuildStep so we can do this better. masterdest = os.path.expanduser(masterdest) log.msg("FileUpload started, from slave %r to master %r" % (source, masterdest)) self.step_status.setColor('yellow') self.step_status.setText(['uploading', os.path.basename(source)]) # we use maxsize to limit the amount of data on both sides fileWriter = _FileWriter(masterdest, self.maxsize, self.mode) # default arguments args = { 'slavesrc': source, 'workdir': self.workdir, 'writer': fileWriter, 'maxsize': self.maxsize, 'blocksize': self.blocksize, } self.cmd = StatusRemoteCommand('uploadFile', args) d = self.runCommand(self.cmd) d.addCallback(self.finished).addErrback(self.failed)
def describe(self, done=False): """Return a list of short strings to describe this step, for the status display. This uses the first few words of the shell command. You can replace this by setting .description in your subclass, or by overriding this method to describe the step better. @type done: boolean @param done: whether the command is complete or not, to improve the way the command is described. C{done=False} is used while the command is still running, so a single imperfect-tense verb is appropriate ('compiling', 'testing', ...) C{done=True} is used when the command has finished, and the default getText() method adds some text, so a simple noun is appropriate ('compile', 'tests' ...) """ if done and self.descriptionDone is not None: return self.descriptionDone if self.description is not None: return self.description words = self.command if isinstance(words, (str, unicode)): words = words.split() # render() each word to handle WithProperties objects words = [render_properties(word, self.build) for word in words] if len(words) < 1: return ["???"] if len(words) == 1: return ["'%s'" % words[0]] if len(words) == 2: return ["'%s" % words[0], "%s'" % words[1]] return ["'%s" % words[0], "%s" % words[1], "...'"]
def start(self): version = self.slaveVersion("downloadFile") if not version: m = "slave is too old, does not know about downloadFile" raise BuildSlaveTooOldError(m) # we are currently in the buildmaster's basedir, so any non-absolute # paths will be interpreted relative to that source = os.path.expanduser(render_properties(self.mastersrc, self.build)) slavedest = render_properties(self.slavedest, self.build) log.msg("FileDownload started, from master %r to slave %r" % (source, slavedest)) self.step_status.setColor('yellow') self.step_status.setText(['downloading', "to", os.path.basename(slavedest)]) # setup structures for reading the file try: fp = open(source, 'rb') except IOError: # if file does not exist, bail out with an error self.addCompleteLog('stderr', 'File %r not available at master' % source) # TODO: once BuildStep.start() gets rewritten to use # maybeDeferred, just re-raise the exception here. reactor.callLater(0, BuildStep.finished, self, FAILURE) return fileReader = _FileReader(fp) # default arguments args = { 'slavedest': slavedest, 'maxsize': self.maxsize, 'reader': fileReader, 'blocksize': self.blocksize, 'workdir': self.workdir, 'mode': self.mode, } self.cmd = StatusRemoteCommand('downloadFile', args) d = self.runCommand(self.cmd) d.addCallback(self.finished).addErrback(self.failed)
def _interpolateWorkdir(self, workdir): return render_properties(workdir, self.build)