-
Notifications
You must be signed in to change notification settings - Fork 0
/
sikulix.py
48 lines (37 loc) · 1.18 KB
/
sikulix.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
import subprocess
import requests
import os
from properties import SIKULIX_API_PATH, SIKULIX_REST, SIKULIX_SCRIPTS_HOME
def start_sikulix_server():
try:
subprocess.run(["java", "-jar", SIKULIX_API_PATH, "-s"])#, check=True, capture_output=True
print("Done")
except subprocess.CalledProcessError as e:
print(e)
def set_sikulix_scripts_home():
request = SIKULIX_REST + "scripts/" + SIKULIX_SCRIPTS_HOME
try:
r = requests.get(request)
print(r)
except requests.exceptions.RequestException as e:
print(e)
# raise SystemExit(e)
def run_sikulix(script_name):
res = run_sikulix_script(script_name)
if res == 1:
try:
os.system("TASKKILL /F /IM unityeyes.exe")
except:
pass
run_sikulix(script_name)
def run_sikulix_script(script_name):
request = SIKULIX_REST + "run/" + script_name
try:
r = requests.get(request)
status = str(r._content)
status = status.replace('PASS 200 runScript: returned: ', '')
status = status[2]
return int(status)
except requests.exceptions.RequestException as e:
print(e)
return 1