def report_ticket(self, ticket, status, log, plugins=(), dry_run=False, pending_status=None): report = { 'status': status, 'patches': ticket['patches'], 'deps': ticket['depends_on'], 'spkgs': ticket['spkgs'], 'base': self.base, 'user': self.config['user'], 'machine': self.config['machine'], 'time': datetime(), 'plugins': plugins, 'patchbot_version': patchbot_version.get_version(), } if pending_status: report['pending_status'] = pending_status try: report['base'] = ticket_base = sorted([ describe_branch('patchbot/base', tag_only=True), describe_branch('patchbot/ticket_upstream', tag_only=True)], compare_version)[-1] report['git_base'] = self.git_commit('patchbot/base') report['git_base_human'] = describe_branch('patchbot/base') if ticket['id'] != 0: report['git_branch'] = ticket.get('git_branch', None) report['git_log'] = subprocess.check_output(['git', 'log', '--oneline', '%s..patchbot/ticket_upstream' % ticket_base]).strip().split('\n') # If apply failed, we don't want to be stuck in an infinite loop. report['git_commit'] = self.git_commit('patchbot/ticket_upstream') report['git_commit_human'] = describe_branch('patchbot/ticket_upstream') report['git_merge'] = self.git_commit('patchbot/ticket_merged') report['git_merge_human'] = describe_branch('patchbot/ticket_merged') else: report['git_branch'] = self.config['base_branch'] report['git_log'] = [] report['git_commit'] = report['git_merge'] = report['git_base'] except Exception: traceback.print_exc() if status != 'Pending': history = open("%s/history.txt" % self.log_dir, "a") history.write("%s %s %s%s\n" % ( datetime(), ticket['id'], status, " dry_run" if dry_run else "")) history.close() print "REPORT" import pprint pprint.pprint(report) print ticket['id'], status fields = {'report': json.dumps(report)} if os.path.exists(log): files = [('log', 'log', bz2.compress(open(log).read()))] else: files = [] if not dry_run or status == 'Pending': print post_multipart("%s/report/%s" % (self.server, ticket['id']), fields, files)
def report_ticket(server, ticket, status, base, machine, user, log, plugins=[]): print ticket['id'], status report = { 'status': status, 'patches': ticket['patches'], 'deps': ticket['depends_on'], 'spkgs': ticket['spkgs'], 'base': base, 'user': user, 'machine': machine, 'time': datetime(), 'plugins': plugins, } fields = {'report': json.dumps(report)} if status != 'Pending': files = [('log', 'log', bz2.compress(open(log).read()))] else: files = [] print post_multipart("%s/report/%s" % (server, ticket['id']), fields, files)