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
|
import sys, argparse
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from .. import public_relay
|
from .. import public_relay
|
||||||
|
@ -120,14 +121,19 @@ def run(args, stdout, stderr, executable=None):
|
||||||
also invoked by entry() below."""
|
also invoked by entry() below."""
|
||||||
|
|
||||||
args = parser.parse_args()
|
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:
|
try:
|
||||||
#rc = command.func(args, stdout, stderr)
|
#rc = command.func(args, stdout, stderr)
|
||||||
rc = args.func(args)
|
rc = args.func(args)
|
||||||
return rc
|
return rc
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print >>stderr, "--- ImportError ---"
|
print("--- ImportError ---", file=stderr)
|
||||||
print >>stderr, e
|
print(e, file=stderr)
|
||||||
print >>stderr, "Please run 'python setup.py build'"
|
print("Please run 'python setup.py build'", file=stderr)
|
||||||
raise
|
raise
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -138,4 +144,4 @@ def entry():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print args
|
print(args)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user