forked from VOLTTRON/volttron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstance.py
46 lines (35 loc) · 1.14 KB
/
instance.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
import argparse
import logging
import os
import subprocess
import sys
logging.basicConfig(level=logging.WARN)
log = logging.getLogger(os.path.basename(__file__))
if not hasattr(sys, 'real_prefix'):
inenv = False
else:
inenv = True
if not inenv:
mypath = os.path.dirname(__file__)
correct_python = sys.executable
if not os.path.exists(correct_python):
log.error("Invalid location for the script {}".format(correct_python))
sys.exit(-10)
# Call this script in a subprocess with the correct python interpreter.
cmds = [correct_python, __file__]
cmds.extend(sys.argv[1:])
process = subprocess.Popen(cmds, env=os.environ)
process.wait()
sys.exit(process.returncode)
from volttron.platform import get_home, is_instance_running
__version__ = '0.2'
if __name__ == '__main__':
parser = argparse.ArgumentParser(version=__version__)
parser.add_argument("-vh", "--volttron-home", default=get_home())
args = parser.parse_args()
result = is_instance_running(args.volttron_home)
if result:
result = 1
else:
result = 0
sys.stdout.write("{}\n".format(int(result)))