You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# coding:utf-8
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import io
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import re
|
|
|
|
|
|
|
|
web_dir = os.getcwd() + "/web"
|
|
|
|
if os.path.exists(web_dir):
|
|
|
|
sys.path.append(web_dir)
|
|
|
|
os.chdir(web_dir)
|
|
|
|
|
|
|
|
import core.mw as mw
|
|
|
|
|
|
|
|
app_debug = False
|
|
|
|
if mw.isAppleSystem():
|
|
|
|
app_debug = True
|
|
|
|
|
|
|
|
|
|
|
|
def getPluginName():
|
|
|
|
return 'data_query'
|
|
|
|
|
|
|
|
|
|
|
|
def getPluginDir():
|
|
|
|
return mw.getPluginDir() + '/' + getPluginName()
|
|
|
|
|
|
|
|
|
|
|
|
def getServerDir():
|
|
|
|
return mw.getServerDir() + '/' + getPluginName()
|
|
|
|
|
|
|
|
|
|
|
|
def getInitDTpl():
|
|
|
|
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
def getArgs():
|
|
|
|
args = sys.argv[3:]
|
|
|
|
tmp = {}
|
|
|
|
args_len = len(args)
|
|
|
|
|
|
|
|
if args_len == 1:
|
|
|
|
t = args[0].strip('{').strip('}')
|
|
|
|
if t.strip() == '':
|
|
|
|
tmp = []
|
|
|
|
else:
|
|
|
|
t = t.split(':')
|
|
|
|
tmp[t[0]] = t[1]
|
|
|
|
tmp[t[0]] = t[1]
|
|
|
|
elif args_len > 1:
|
|
|
|
for i in range(len(args)):
|
|
|
|
t = args[i].split(':')
|
|
|
|
tmp[t[0]] = t[1]
|
|
|
|
return tmp
|
|
|
|
|
|
|
|
def checkArgs(data, ck=[]):
|
|
|
|
for i in range(len(ck)):
|
|
|
|
if not ck[i] in data:
|
|
|
|
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
|
|
|
return (True, mw.returnJson(True, 'ok'))
|
|
|
|
|
|
|
|
|
|
|
|
def status():
|
|
|
|
return 'start'
|
|
|
|
|
|
|
|
def appOp(method):
|
|
|
|
return 'ok'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def start():
|
|
|
|
return appOp('start')
|
|
|
|
|
|
|
|
|
|
|
|
def stop():
|
|
|
|
return appOp('stop')
|
|
|
|
|
|
|
|
|
|
|
|
def restart():
|
|
|
|
status = appOp('restart')
|
|
|
|
return status
|
|
|
|
|
|
|
|
def reload():
|
|
|
|
return appOp('reload')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
func = sys.argv[1]
|
|
|
|
if func == 'status':
|
|
|
|
print(status())
|
|
|
|
elif func == 'start':
|
|
|
|
print(start())
|
|
|
|
elif func == 'stop':
|
|
|
|
print(stop())
|
|
|
|
elif func == 'restart':
|
|
|
|
print(restart())
|
|
|
|
elif func == 'reload':
|
|
|
|
print(reload())
|
|
|
|
else:
|
|
|
|
print('error')
|