fetch_from_archive.py 908 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. from __future__ import print_function
  2. import os
  3. import sys
  4. import logging
  5. import argparse
  6. import fetch_from
  7. def parse_args():
  8. parser = argparse.ArgumentParser()
  9. fetch_from.add_common_arguments(parser)
  10. parser.add_argument('--file-name', required=True)
  11. parser.add_argument('--archive', required=True)
  12. return parser.parse_args()
  13. def main(args):
  14. archive = args.archive
  15. file_name = args.file_name.rstrip('-')
  16. fetch_from.process(archive, file_name, args, remove=False)
  17. if __name__ == '__main__':
  18. args = parse_args()
  19. fetch_from.setup_logging(args, os.path.basename(__file__))
  20. try:
  21. main(args)
  22. except Exception as e:
  23. logging.exception(e)
  24. print(open(args.abs_log_path).read(), file=sys.stderr)
  25. sys.stderr.flush()
  26. import error
  27. sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1)