blob: 7ab993fc310a755e233217d7f8ba9b684461b283 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import os
import sys
import logging
import argparse
import fetch_from
MDS_PREFIX = "https://storage.yandex-team.ru/get-devtools/"
def parse_args():
parser = argparse.ArgumentParser()
fetch_from.add_common_arguments(parser)
parser.add_argument('--key', required=True)
return parser.parse_args()
def fetch(key):
parts = key.split("/")
if len(parts) != 3:
raise ValueError("Invalid MDS key '{}'".format(key))
_, sha1, file_name = parts
fetched_file = fetch_from.fetch_url(MDS_PREFIX + key, False, file_name, expected_sha1=sha1)
return fetched_file, file_name
def main(args):
fetched_file, resource_file_name = fetch(args.key)
fetch_from.process(fetched_file, resource_file_name, args)
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()
import error
sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1)
|