scripts/runner: make py3-compatible
This commit is contained in:
parent
2e2bd1bb5f
commit
e9d87828c2
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function
|
||||
import sys, argparse
|
||||
from textwrap import dedent
|
||||
from .. import public_relay
|
||||
|
@ -120,14 +121,19 @@ def run(args, stdout, stderr, executable=None):
|
|||
also invoked by entry() below."""
|
||||
|
||||
args = parser.parse_args()
|
||||
if not getattr(args, "func", None):
|
||||
# So far this only works on py3. py2 exits with a really terse
|
||||
# "error: too few arguments" during parse_args().
|
||||
parser.print_help()
|
||||
sys.exit(0)
|
||||
try:
|
||||
#rc = command.func(args, stdout, stderr)
|
||||
rc = args.func(args)
|
||||
return rc
|
||||
except ImportError as e:
|
||||
print >>stderr, "--- ImportError ---"
|
||||
print >>stderr, e
|
||||
print >>stderr, "Please run 'python setup.py build'"
|
||||
print("--- ImportError ---", file=stderr)
|
||||
print(e, file=stderr)
|
||||
print("Please run 'python setup.py build'", file=stderr)
|
||||
raise
|
||||
return 1
|
||||
|
||||
|
@ -138,4 +144,4 @@ def entry():
|
|||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
print args
|
||||
print(args)
|
||||
|
|
Loading…
Reference in New Issue
Block a user