main.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from os.path import abspath, expanduser
import sys
from utils import run_jar
CLI_HELP_MSG = "Usage: arg1 - JAR path, [*args] - JAR program arguments"
if __name__ == "__main__":
# Program must be provided with JAR path (sys.argv[0] is self program path)
if len(sys.argv) < 2:
print(CLI_HELP_MSG)
jar_path = abspath(expanduser(sys.argv[1]))
args = sys.argv[2:]
print("Using absolute jar path %s" % jar_path)
stdout, stderr = run_jar(jar_path, *args)
if stderr != "":
print("Program executed with error:\n%s" % stderr)
else:
print("Program executed without errors. Result:\n%s" % stdout)