forked from metrixplusplus/metrixplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrixpp.py
58 lines (48 loc) · 1.71 KB
/
metrixpp.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# Metrix++, Copyright 2009-2019, Metrix++ Project
# Link: https://github.com/metrixplusplus/metrixplusplus
#
# This file is a part of Metrix++ Tool.
#
import time
import sys
import logging
import os
import subprocess
import itertools
import mpp.log
import mpp.internal.loader
def main():
os.environ['METRIXPLUSPLUS_INSTALL_DIR'] = os.path.dirname(os.path.abspath(__file__))
exemode = None
if len(sys.argv[1:]) != 0:
exemode = sys.argv[1]
if exemode != "-R" and exemode != "-D":
exemode = '-D' # TODO implement install and release mode
# inject '-D' or '-R' option
#profile_args = ['-m', 'cProfile']
profile_args = []
exit(subprocess.call(itertools.chain([sys.executable], profile_args, [sys.argv[0], '-D'], sys.argv[1:])))
command = ""
if len(sys.argv[1:]) > 1:
command = sys.argv[2]
loader = mpp.internal.loader.Loader()
mpp_paths = []
if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
args = loader.load(command, mpp_paths, sys.argv[3:])
exit_code = loader.run(args)
loader.unload()
return exit_code
def start():
ts = time.time()
mpp.log.set_default_format()
exit_code = main()
time_spent = round((time.time() - ts), 2)
if 'METRIXPLUSPLUS_TEST_GENERATE_GOLDS' in os.environ.keys() and \
os.environ['METRIXPLUSPLUS_TEST_GENERATE_GOLDS'] == "True":
time_spent = 1 # Constant value if under tests
logging.warning("Done (" + str(time_spent) +" seconds). Exit code: " + str(exit_code))
exit(exit_code)
if __name__ == '__main__':
start()