Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/virtualenv/__main__.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac |
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 |
| parents | 26e78fe6e8c4 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 |
|---|---|
| 1 from __future__ import absolute_import, print_function, unicode_literals | |
| 2 | |
| 3 import argparse | |
| 4 import logging | |
| 5 import os | |
| 6 import sys | |
| 7 from datetime import datetime | |
| 8 | |
| 9 from virtualenv.util.six import ensure_text | |
| 10 | |
| 11 | |
| 12 def run(args=None, options=None): | |
| 13 start = datetime.now() | |
| 14 from virtualenv.error import ProcessCallFailed | |
| 15 from virtualenv.run import cli_run | |
| 16 | |
| 17 if args is None: | |
| 18 args = sys.argv[1:] | |
| 19 try: | |
| 20 session = cli_run(args, options) | |
| 21 logging.warning(LogSession(session, start)) | |
| 22 except ProcessCallFailed as exception: | |
| 23 print("subprocess call failed for {} with code {}".format(exception.cmd, exception.code)) | |
| 24 print(exception.out, file=sys.stdout, end="") | |
| 25 print(exception.err, file=sys.stderr, end="") | |
| 26 raise SystemExit(exception.code) | |
| 27 | |
| 28 | |
| 29 class LogSession(object): | |
| 30 def __init__(self, session, start): | |
| 31 self.session = session | |
| 32 self.start = start | |
| 33 | |
| 34 def __str__(self): | |
| 35 spec = self.session.creator.interpreter.spec | |
| 36 elapsed = (datetime.now() - self.start).total_seconds() * 1000 | |
| 37 lines = [ | |
| 38 "created virtual environment {} in {:.0f}ms".format(spec, elapsed), | |
| 39 " creator {}".format(ensure_text(str(self.session.creator))), | |
| 40 ] | |
| 41 if self.session.seeder.enabled: | |
| 42 lines += (" seeder {}".format(ensure_text(str(self.session.seeder)),),) | |
| 43 if self.session.activators: | |
| 44 lines.append(" activators {}".format(",".join(i.__class__.__name__ for i in self.session.activators))) | |
| 45 return os.linesep.join(lines) | |
| 46 | |
| 47 | |
| 48 def run_with_catch(args=None): | |
| 49 options = argparse.Namespace() | |
| 50 try: | |
| 51 run(args, options) | |
| 52 except (KeyboardInterrupt, Exception) as exception: | |
| 53 if getattr(options, "with_traceback", False): | |
| 54 logging.shutdown() # force flush of log messages before the trace is printed | |
| 55 raise | |
| 56 else: | |
| 57 logging.error("%s: %s", type(exception).__name__, exception) | |
| 58 sys.exit(1) | |
| 59 | |
| 60 | |
| 61 if __name__ == "__main__": | |
| 62 run_with_catch() |
