forked from ARL-UTEP-OC/cdes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_controller.py
50 lines (41 loc) · 1.63 KB
/
test_controller.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
import multiprocessing
from Trigger.timer_trigger import TimerTrigger
from Swapper.swapper import Swapper
from Monitor.monitor import Monitor
from COREIfx.session_reader import SessionReader
import imp
import logging
import time
import sys
import os
import json
from controller import Controller
__author__ = "Jaime C. Acosta"
__license__ = "GPL 3.0"
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
logging.debug("Program instantiated")
cr = Controller()
if len(sys.argv) == 2:
dirs = cr.get_sorted_in_dirs("/tmp/", dircontains="pycore")
if len(dirs) == 0:
logging.error("No sessions exist, make sure core-daemon is running. \n You can start it by running /etc/init.d/core-daemon start")
exit()
mydir = dirs[0]
session_number = mydir.split("pycore.")[1]
logging.warning("Session Number was not passed in; will use latest: " + session_number)
elif len(sys.argv) == 3:
session_number = sys.argv[2]
mydir = os.path.join("/tmp","pycore."+str(sys.argv[2]))
if os.path.exists(mydir) == False:
logging.error("Session "+str(sys.argv[2])+" does not exist, make sure core-daemon is running. \n You can start it by running /etc/init.d/core-daemon start")
exit()
else:
logging.error("Usage: python controller.py <monitor_process_path> [session-number]")
exit()
cr.cdes_run(monitor_cmd=sys.argv[1], session_number=session_number)
# Get output and print to screen
while True:
#logging.debug("Processing...)
time.sleep(0.1)
logging.debug("Controller(): Completed")