Skip to content

Commit f02e08e

Browse files
committed
Change cli to do a subprocess call
1 parent 434d15f commit f02e08e

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎softioc/__main__.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
from argparse import ArgumentParser
4+
import subprocess
45

56
from softioc import __version__
67

@@ -9,16 +10,10 @@ def main(args=None):
910
parser = ArgumentParser()
1011
parser.add_argument("--version", action="version", version=__version__)
1112
parser.add_argument("script", help="The python script to run")
13+
parser.add_argument("arg", help="Any arguments to pass to the script", nargs="*")
1214
parsed_args = parser.parse_args(args)
13-
# Insert the directory containing script onto the path in case we do
14-
# any imports
15-
sys.path.insert(0, os.path.dirname(os.path.abspath(parsed_args.script)))
16-
if sys.version_info < (3, 0):
17-
# Python 2
18-
execfile(parsed_args.script)
19-
else:
20-
# Python 3
21-
exec(open(parsed_args.script).read())
15+
# Execute as subprocess
16+
subprocess.Popen([sys.executable, parsed_args.script, *parsed_args.arg]).communicate()
2217

2318

2419
if __name__ == "__main__":

0 commit comments

Comments
 (0)