def get_status_exit_code_duration(self, status): if self.format_version == 1: job_status = {'status': status} return (Job.exit_code(job_status), Job.total_duration_msecs(job_status)) assert len(status) == 2 return status
def db_status(self, status): if self.format_version == 1: return status job_status = {'status': status} return [ Job.exit_code(job_status), Job.total_duration_msecs(job_status) ]
async def get_batch(request, userdata): # pylint: disable=unused-argument batch_id = int(request.match_info['batch_id']) batch_client = request.app['batch_client'] b = await batch_client.get_batch(batch_id) status = await b.status() for j in status['jobs']: j['duration'] = humanize.naturaldelta(Job.total_duration(j)) j['exit_code'] = Job.exit_code(j) return {'batch': status}
async def get_batch(request, userdata): batch_id = int(request.match_info['batch_id']) batch_client = request.app['batch_client'] b = await batch_client.get_batch(batch_id) status = await b.status() for j in status['jobs']: j['duration'] = humanize.naturaldelta(Job.total_duration(j)) j['exit_code'] = Job.exit_code(j) page_context = {'batch': status} return await render_template('ci', request, userdata, 'batch.html', page_context)
async def ui_batch(request, userdata): app = request.app batch_id = int(request.match_info['batch_id']) user = userdata['username'] batch = await _get_batch(app, batch_id, user) jobs = await _get_batch_jobs(app, batch_id, user) for job in jobs: job['exit_code'] = Job.exit_code(job) job['duration'] = humanize.naturaldelta(Job.total_duration(job)) batch['jobs'] = jobs page_context = {'batch': batch} return await render_template('batch2', request, userdata, 'batch.html', page_context)
async def get_pr(request, userdata): # pylint: disable=unused-argument watched_branch_index = int(request.match_info['watched_branch_index']) pr_number = int(request.match_info['pr_number']) if watched_branch_index < 0 or watched_branch_index >= len( watched_branches): raise web.HTTPNotFound() wb = watched_branches[watched_branch_index] if not wb.prs or pr_number not in wb.prs: raise web.HTTPNotFound() pr = wb.prs[pr_number] page_context = {} page_context['repo'] = wb.branch.repo.short_str() page_context['number'] = pr.number # FIXME if pr.batch: if hasattr(pr.batch, 'id'): status = await pr.batch.status() for j in status['jobs']: j['duration'] = humanize.naturaldelta(Job.total_duration(j)) j['exit_code'] = Job.exit_code(j) attrs = j['attributes'] if 'link' in attrs: attrs['link'] = attrs['link'].split(',') page_context['batch'] = status # [4:] strips off gs:/ page_context[ 'artifacts'] = f'{BUCKET}/build/{pr.batch.attributes["token"]}'[ 4:] else: page_context['exception'] = '\n'.join( traceback.format_exception(None, pr.batch.exception, pr.batch.exception.__traceback__)) batch_client = request.app['batch_client'] batches = await batch_client.list_batches(attributes={ 'test': '1', 'pr': pr_number }) batches = sorted(batches, key=lambda b: b.id, reverse=True) page_context['history'] = [await b.status() for b in batches] return await render_template('ci', request, userdata, 'pr.html', page_context)
async def get_pr(request): watched_branch_index = int(request.match_info['watched_branch_index']) pr_number = int(request.match_info['pr_number']) if watched_branch_index < 0 or watched_branch_index >= len( watched_branches): raise web.HTTPNotFound() wb = watched_branches[watched_branch_index] if not wb.prs or pr_number not in wb.prs: raise web.HTTPNotFound() pr = wb.prs[pr_number] config = {} config['number'] = pr.number # FIXME if pr.batch: if hasattr(pr.batch, 'id'): status = await pr.batch.status() for j in status['jobs']: if 'duration' in j and j['duration'] is not None: duration = Job.duration(j) if duration is not None: j['duration'] = humanize.naturaldelta( datetime.timedelta(seconds=duration)) j['exit_code'] = Job.exit_code(j) attrs = j['attributes'] if 'link' in attrs: attrs['link'] = attrs['link'].split(',') config['batch'] = status config[ 'artifacts'] = f'{BUCKET}/build/{pr.batch.attributes["token"]}' else: config['exception'] = '\n'.join( traceback.format_exception(None, pr.batch.exception, pr.batch.exception.__traceback__)) batch_client = request.app['batch_client'] batches = await batch_client.list_batches(attributes={ 'test': '1', 'pr': pr_number }) batches = sorted(batches, key=lambda b: b.id, reverse=True) config['history'] = [await b.status() for b in batches] return config
def db_status(self, status): if self.format_version == 1: return status job_status = {'status': status} ec = Job.exit_code(job_status) status_version = status.get('version', 1) if status_version == 1: duration = Job.total_duration_msecs(job_status) else: start_time = status.get('start_time') end_time = status.get('end_time') if start_time and end_time: duration = end_time - start_time else: duration = None return [ec, duration]
async def get_batch(request): batch_id = int(request.match_info['batch_id']) batch_client = request.app['batch_client'] b = await batch_client.get_batch(batch_id) status = await b.status() for j in status['jobs']: if 'duration' in j and j['duration'] is not None: j['duration'] = humanize.naturaldelta( datetime.timedelta(seconds=sum(j['duration']))) j['exit_code'] = Job.exit_code(j) return {'batch': status}