Update task.py

pull/109/head
midoks 4 years ago
parent 9b953cf608
commit 8ae7441eff
  1. 13
      task.py

@ -10,7 +10,14 @@ import time
import threading import threading
# print sys.path # print sys.path
sys.path.append("/usr/local/lib/python3.6/site-packages")
if mw.isAppleSystem():
cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''
info = mw.execShell(cmd)
p = "/usr/local/lib/" + info[0].strip() + "/site-packages"
sys.path.append(p)
import psutil import psutil
sys.path.append(os.getcwd() + "/class/core") sys.path.append(os.getcwd() + "/class/core")
@ -39,14 +46,14 @@ if not os.path.exists(isTask):
os.system("touch " + isTask) os.system("touch " + isTask)
def async(f): def mw_async(f):
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
thr = threading.Thread(target=f, args=args, kwargs=kwargs) thr = threading.Thread(target=f, args=args, kwargs=kwargs)
thr.start() thr.start()
return wrapper return wrapper
@async @mw_async
def restartMw(): def restartMw():
time.sleep(1) time.sleep(1)
cmd = mw.getRunDir() + '/scripts/init.d/mw restart' cmd = mw.getRunDir() + '/scripts/init.d/mw restart'

Loading…
Cancel
Save