def list(): """ List all projects. """ projects_data = request('get', '/api/v0/projects/', params={ 'count': 9000 }).json()['results'] projects_data.sort(key=itemgetter('name')) print(projects_data) print_table(projects_data, ['name', 'description'])
def outputs(counter, download): """ List and download execution outputs. """ execution = get_project(require=True).get_execution_from_counter( counter=counter, detail=True) outputs = execution.get('outputs', ()) if not outputs: warn('The execution has no outputs.') return print_table(outputs, ('name', 'url', 'size')) if download: download_outputs(outputs, download)
def print_incomplete_executions(project): incomplete_executions = request('get', '/api/v0/executions/', params={ 'project': project.id, 'status': 'incomplete', 'ordering': 'counter', }).json().get('results', ()) if not incomplete_executions: return click.secho('## %d Incomplete Executions\n' % len(incomplete_executions), bold=True) print_table(incomplete_executions, ['counter', 'status', 'step'], headers=['#', 'Status', 'Step'])
def print_execution_summary(project_data): execution_summary = project_data.get('execution_summary', {}).copy() if not execution_summary: return total = execution_summary.pop('count') if not total: click.secho('No executions yet.', fg='cyan') return click.secho('## Summary of %d executions\n' % total, bold=True) print_table( [{ 'status': key.replace('_count', ''), 'count': value } for (key, value) in sorted(execution_summary.items()) if value], columns=('status', 'count'), headers=('Status', 'Count'), ) click.secho('\n')
def info(counter): """ Show execution info. """ execution = get_project(require=True).get_execution_from_counter( counter=counter, detail=True) data = dict((humanize_identifier(key), str(value)) for (key, value) in execution.items() if key not in ignored_keys) data['project name'] = execution['project']['name'] data['environment name'] = execution['environment']['name'] print_table(data) print() print_table( { input['name']: '; '.join(input['urls']) for input in execution.get('inputs', ()) }, headers=('input', 'URLs'), ) print() print_table( execution.get('parameters', {}), headers=('parameter', 'value'), ) print()
def commits(): """ List the commits for the linked project. """ project = get_project(require=True) commits_data = request( 'get', '/api/v0/projects/{id}/commits/'.format(id=project.id)).json() try: current_commit = get_current_commit(project.directory) except: current_commit = None # Filter out ad-hoc executions (and remove the adhocness marker) commits_data = [ commit for commit in commits_data if not commit.pop('adhoc', False) ] # Mark the current commit for commit in commits_data: if commit['identifier'] == current_commit: commit['identifier'] += ' (current)' print_table(commits_data)