Handle forward compatability with cycle refactor
This handles the old and new data format for the builds/ and build/ endpoints. Builds will soon include multiple refs. Change-Id: I1db5e9fc3fd38864f72b914e09629d3d0637f355
This commit is contained in:
parent
6250b3eb4d
commit
21785e1464
@ -130,22 +130,26 @@ class PrettyTableFormatter(BaseFormatter):
|
|||||||
return str(table)
|
return str(table)
|
||||||
|
|
||||||
def formatBuild(self, data) -> str:
|
def formatBuild(self, data) -> str:
|
||||||
|
if 'project' in data:
|
||||||
|
ref = data
|
||||||
|
else:
|
||||||
|
ref = data['ref']
|
||||||
output = ''
|
output = ''
|
||||||
# This is based on the web UI
|
# This is based on the web UI
|
||||||
output += 'UUID: %s\n' % data.get('uuid', 'N/A')
|
output += 'UUID: %s\n' % data.get('uuid', 'N/A')
|
||||||
output += '=' * len('UUID: %s' % data.get('uuid', 'N/A')) + '\n'
|
output += '=' * len('UUID: %s' % data.get('uuid', 'N/A')) + '\n'
|
||||||
output += 'Result: %s\n' % data.get('result', 'N/A')
|
output += 'Result: %s\n' % data.get('result', 'N/A')
|
||||||
output += 'Pipeline: %s\n' % data.get('pipeline', 'N/A')
|
output += 'Pipeline: %s\n' % data.get('pipeline', 'N/A')
|
||||||
output += 'Project: %s\n' % data.get('project', 'N/A')
|
output += 'Project: %s\n' % ref.get('project', 'N/A')
|
||||||
output += 'Job: %s\n' % data.get('job_name', 'N/A')
|
output += 'Job: %s\n' % data.get('job_name', 'N/A')
|
||||||
if data.get('newrev'):
|
if ref.get('newrev'):
|
||||||
output += 'Ref: %s\n' % data.get('ref', 'N/A')
|
output += 'Ref: %s\n' % ref.get('ref', 'N/A')
|
||||||
output += 'New Rev: %s\n' % data['newrev']
|
output += 'New Rev: %s\n' % ref['newrev']
|
||||||
if data.get('change') and data.get('patchset'):
|
if ref.get('change') and ref.get('patchset'):
|
||||||
output += 'Change: %s\n' % (str(data['change']) + ',' +
|
output += 'Change: %s\n' % (str(ref['change']) + ',' +
|
||||||
str(data['patchset']))
|
str(ref['patchset']))
|
||||||
output += 'Branch: %s\n' % data.get('branch', 'N/A')
|
output += 'Branch: %s\n' % ref.get('branch', 'N/A')
|
||||||
output += 'Ref URL: %s\n' % data.get('ref_url', 'N/A')
|
output += 'Ref URL: %s\n' % ref.get('ref_url', 'N/A')
|
||||||
output += 'Event ID: %s\n' % data.get('event_id', 'N/A')
|
output += 'Event ID: %s\n' % data.get('event_id', 'N/A')
|
||||||
output += 'Buildset ID: %s\n' % data.get('buildset',
|
output += 'Buildset ID: %s\n' % data.get('buildset',
|
||||||
{}).get('uuid', 'N/A')
|
{}).get('uuid', 'N/A')
|
||||||
@ -245,10 +249,14 @@ class PrettyTableFormatter(BaseFormatter):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
for build in data:
|
for build in data:
|
||||||
if build.get('change') and build.get('patchset'):
|
if 'project' in build:
|
||||||
change = str(build['change']) + ',' + str(build['patchset'])
|
ref = build
|
||||||
else:
|
else:
|
||||||
change = build.get('ref', 'N/A')
|
ref = build['ref']
|
||||||
|
if ref.get('change') and ref.get('patchset'):
|
||||||
|
change = str(ref['change']) + ',' + str(ref['patchset'])
|
||||||
|
else:
|
||||||
|
change = ref.get('ref', 'N/A')
|
||||||
start_time = (
|
start_time = (
|
||||||
build.get('start_time') and
|
build.get('start_time') and
|
||||||
isoparse(build['start_time']) or
|
isoparse(build['start_time']) or
|
||||||
@ -257,8 +265,8 @@ class PrettyTableFormatter(BaseFormatter):
|
|||||||
table.add_row([
|
table.add_row([
|
||||||
build.get('uuid', 'N/A'),
|
build.get('uuid', 'N/A'),
|
||||||
build.get('job_name', 'N/A'),
|
build.get('job_name', 'N/A'),
|
||||||
build.get('project', 'N/A'),
|
ref.get('project', 'N/A'),
|
||||||
build.get('branch', 'N/A'),
|
ref.get('branch', 'N/A'),
|
||||||
build.get('pipeline', 'N/A'),
|
build.get('pipeline', 'N/A'),
|
||||||
change,
|
change,
|
||||||
build.get('duration', 'N/A'),
|
build.get('duration', 'N/A'),
|
||||||
|
Loading…
Reference in New Issue
Block a user