Esempio n. 1
0
    def process_job(self, job):
        job = Job(self, job)
        self.logger.info("Processing %s job for %s (%s@%s)" % (job.action, job.repo, job.ref, job.sha1))
        to_submit = {'repo': job.repo, 'ref': job.ref, 'prev_sha1': job.prev_sha1, 'sha1': job.sha1,
                     'why': 'action-started', 'action': job.action, 'host': socket.gethostname(),
                     'start_time': toutctimestamp(job.start_time)}
        self.bs.use(self.submit_queue)
        self.bs.put(json.dumps(to_submit), ttr=600)

        if self.repo_sync:
            job.run_hook('pre-sync')
            job.sync()
            job.run_hook('post-sync')

        os.chdir(job.work_path)

        if self.repo_checkout:
            job.run_hook('pre-checkout')
            job.checkout(job.sha1)
            os.chdir(job.work_path)
            job.run_hook('post-checkout')

        try:
            self.setup(job)
            self.process_job_simple(job)
            job.result = 'success'
        except GolemRetryLater, e:
            self.logger.error(unicode(e).encode('utf-8'))
            job.result = 'retry'
Esempio n. 2
0
def my_deepcopy(data):
    if isinstance(data, list):
        return [my_deepcopy(x) for x in data]
    elif isinstance(data, dict):
        return dict([(my_deepcopy(x), my_deepcopy(data[x])) for x in data])
    elif isinstance(data, datetime.datetime):
        return toutctimestamp(data)
    elif data.__class__ == re_class:
        return data.pattern
    return data
Esempio n. 3
0
 def publish_results(self):
     for glb in getattr(self, 'publish', []):
         for file in glob.glob(os.path.join(self.work_path, glb)):
             self.logger.info("Adding artefact %s" % file.replace(self.work_path, ''))
             os.rename(file, os.path.join(self.artefact_path, os.path.basename(file)))
     local = self.artefact_path + os.sep
     remote = '/'.join([self.worker.rsync_root, self.repo, 'artefacts', self.action, '%s@%s' % (self.ref, self.sha1)]) + os.sep
     self.logger.info("Publishing %s => %s" % (local, remote))
     args = ['-av', local, remote]
     if self.worker.rsync_password:
         args += ['--password-file', self.worker.rsync_password]
     self.shell.rsync(*args)
     self.end_time = now()
     to_submit = {'repo': self.repo, 'ref': self.ref, 'prev_sha1': self.prev_sha1, 'sha1': self.sha1,
                  'why': 'action-done', 'action': self.action, 'result': self.result,
                  'start_time': toutctimestamp(self.start_time), 'end_time': toutctimestamp(self.end_time),
                  'duration': (self.end_time-self.start_time).total_seconds(),
                  'host': socket.gethostname()}
     self.worker.bs.use(self.worker.submit_queue)
     self.worker.bs.put(json.dumps(to_submit), ttr=600)