fetch_from_archive.py 867 B

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