diff options
Diffstat (limited to 'test/utils/shippable')
-rwxr-xr-x | test/utils/shippable/tools/download.py | 22 | ||||
-rwxr-xr-x | test/utils/shippable/tools/run.py | 12 |
2 files changed, 32 insertions, 2 deletions
diff --git a/test/utils/shippable/tools/download.py b/test/utils/shippable/tools/download.py index 045028914c..5449ee7e6f 100755 --- a/test/utils/shippable/tools/download.py +++ b/test/utils/shippable/tools/download.py @@ -26,6 +26,8 @@ import argparse import json import os import re +import sys + import requests try: @@ -36,6 +38,12 @@ except ImportError: def main(): """Main program body.""" + args = parse_args() + download_run(args) + + +def parse_args(): + """Parse and return args.""" api_key = get_api_key() parser = argparse.ArgumentParser(description='Download results from a Shippable run.') @@ -118,6 +126,11 @@ def main(): if not any(selections): parser.error('At least one download option is required.') + return args + + +def download_run(args): + """Download a Shippable run.""" headers = dict( Authorization='apiToken %s' % args.api_key, ) @@ -137,7 +150,7 @@ def main(): if job_number: if args.job_number: - exit('ERROR: job number found in url and specified with --job-number') + sys.exit('ERROR: job number found in url and specified with --job-number') args.job_number = [job_number] @@ -173,7 +186,7 @@ def main(): project = run['projectName'] run_number = run['runNumber'] else: - exit('ERROR: invalid run: %s' % args.run_id) + sys.exit('ERROR: invalid run: %s' % args.run_id) output_dir = '%s/%s/%s' % (account, project, run_number) @@ -199,6 +212,11 @@ def main(): with open(path, 'w') as metadata_fd: metadata_fd.write(contents) + download_jobs(args, jobs, headers, output_dir) + + +def download_jobs(args, jobs, headers, output_dir): + """Download Shippable jobs.""" for j in jobs: job_id = j['id'] job_number = j['jobNumber'] diff --git a/test/utils/shippable/tools/run.py b/test/utils/shippable/tools/run.py index 7ec7590363..310a7f53f0 100755 --- a/test/utils/shippable/tools/run.py +++ b/test/utils/shippable/tools/run.py @@ -25,6 +25,7 @@ __metaclass__ = type import argparse import json import os + import requests try: @@ -35,6 +36,12 @@ except ImportError: def main(): """Main program body.""" + args = parse_args() + start_run(args) + + +def parse_args(): + """Parse and return args.""" api_key = get_api_key() parser = argparse.ArgumentParser(description='Start a new Shippable run.') @@ -69,6 +76,11 @@ def main(): args = parser.parse_args() + return args + + +def start_run(args): + """Start a new Shippable run.""" headers = dict( Authorization='apiToken %s' % args.key, ) |