|
@@ -6,9 +6,6 @@ from modelverse import *
|
|
|
from subprocess import Popen, PIPE
|
|
|
import json
|
|
|
|
|
|
-init(sys.argv[1])
|
|
|
-login("test_service", "my_password")
|
|
|
-
|
|
|
def lola_service(port):
|
|
|
json_input = service_get(port)
|
|
|
input_data = json.loads(json_input)
|
|
@@ -31,15 +28,23 @@ def lola_service(port):
|
|
|
service_set(port, result['analysis']['result'])
|
|
|
service_set(port, path.rstrip(','))
|
|
|
|
|
|
-service_register("lola", lola_service)
|
|
|
+try:
|
|
|
+ init(sys.argv[1])
|
|
|
+ login("test_service", "my_password")
|
|
|
+
|
|
|
+ service_register("lola", lola_service)
|
|
|
|
|
|
-if sys.version_info[0] < 3:
|
|
|
- while raw_input() != "STOP":
|
|
|
- # Stay active, as we shouldn't exit while the service is running!
|
|
|
- pass
|
|
|
-else:
|
|
|
- while input() != "STOP":
|
|
|
- # Stay active, as we shouldn't exit while the service is running!
|
|
|
- pass
|
|
|
+ try:
|
|
|
+ if sys.version_info[0] < 3:
|
|
|
+ while raw_input() != "STOP":
|
|
|
+ # Stay active, as we shouldn't exit while the service is running!
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ while input() != "STOP":
|
|
|
+ # Stay active, as we shouldn't exit while the service is running!
|
|
|
+ pass
|
|
|
|
|
|
-service_stop()
|
|
|
+ finally:
|
|
|
+ service_stop()
|
|
|
+except KeyboardInterrupt:
|
|
|
+ pass
|