diff options
author | spreis <spreis@yandex-team.ru> | 2022-02-10 16:47:13 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:13 +0300 |
commit | bcd1126cbd5d445cd0665d295198aa39c6ab8cbe (patch) | |
tree | d41d29a041d5733ef148335290dbb817b197d4cd /build/scripts/fetch_from_external.py | |
parent | 986cb5d624f352524bfa0c42c9a7695235cdaa41 (diff) | |
download | ydb-bcd1126cbd5d445cd0665d295198aa39c6ab8cbe.tar.gz |
Restoring authorship annotation for <spreis@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/scripts/fetch_from_external.py')
-rw-r--r-- | build/scripts/fetch_from_external.py | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/build/scripts/fetch_from_external.py b/build/scripts/fetch_from_external.py index d4ed6f4221..83f0416ca1 100644 --- a/build/scripts/fetch_from_external.py +++ b/build/scripts/fetch_from_external.py @@ -1,60 +1,60 @@ import sys import json -import os.path -import fetch_from -import argparse -import logging +import os.path +import fetch_from +import argparse +import logging -def parse_args(): - parser = argparse.ArgumentParser() - fetch_from.add_common_arguments(parser) - parser.add_argument('--external-file', required=True) - parser.add_argument('--custom-fetcher') - parser.add_argument('--resource-file') - return parser.parse_args() +def parse_args(): + parser = argparse.ArgumentParser() + fetch_from.add_common_arguments(parser) + parser.add_argument('--external-file', required=True) + parser.add_argument('--custom-fetcher') + parser.add_argument('--resource-file') + return parser.parse_args() -def main(args): - external_file = args.external_file.rstrip('.external') - if os.path.isfile(args.resource_file): +def main(args): + external_file = args.external_file.rstrip('.external') + if os.path.isfile(args.resource_file): fetch_from.process(args.resource_file, os.path.basename(args.resource_file), args, False) - return - - error = None - try: - with open(args.external_file) as f: - js = json.load(f) - - if js['storage'] == 'SANDBOX': - import fetch_from_sandbox as ffsb - del args.external_file - args.resource_id = js['resource_id'] - ffsb.main(args) - elif js['storage'] == 'MDS': - import fetch_from_mds as fmds - del args.external_file - args.key = js['resource_id'] - fmds.main(args) - else: - error = 'Unsupported storage in {}'.format(external_file) - except: - logging.error('Invalid external file: {}'.format(external_file)) - raise - if error: - raise Exception(error) - - + return + + error = None + try: + with open(args.external_file) as f: + js = json.load(f) + + if js['storage'] == 'SANDBOX': + import fetch_from_sandbox as ffsb + del args.external_file + args.resource_id = js['resource_id'] + ffsb.main(args) + elif js['storage'] == 'MDS': + import fetch_from_mds as fmds + del args.external_file + args.key = js['resource_id'] + fmds.main(args) + else: + error = 'Unsupported storage in {}'.format(external_file) + except: + logging.error('Invalid external file: {}'.format(external_file)) + raise + if error: + raise Exception(error) + + if __name__ == '__main__': - args = parse_args() - fetch_from.setup_logging(args, os.path.basename(__file__)) - - try: - main(args) - except Exception as e: - logging.exception(e) - print >>sys.stderr, open(args.abs_log_path).read() - sys.stderr.flush() + args = parse_args() + fetch_from.setup_logging(args, os.path.basename(__file__)) + + try: + main(args) + except Exception as e: + logging.exception(e) + print >>sys.stderr, open(args.abs_log_path).read() + sys.stderr.flush() import error sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) |