linkkf 로직수정중
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import queue
|
||||
import shlex
|
||||
|
||||
from support import SupportSubprocess
|
||||
from tool import ToolModalCommand
|
||||
@@ -25,7 +26,7 @@ class PageCommand(PluginPageBase):
|
||||
ret = {'ret':'success'}
|
||||
if command == 'foreground_command':
|
||||
P.ModelSetting.set(f'{self.parent.name}_{self.name}_recent', arg1)
|
||||
self.__foreground_execute(arg1, arg1.split(' '))
|
||||
self.__foreground_execute(arg1, shlex.split(arg1))
|
||||
|
||||
return jsonify('')
|
||||
elif command == 'job_new':
|
||||
@@ -54,7 +55,7 @@ class PageCommand(PluginPageBase):
|
||||
elif command == 'job_fore_execute':
|
||||
db_item = ModelCommand.get_by_id(arg1)
|
||||
cmd = (db_item.command + ' ' + db_item.args).strip()
|
||||
self.__foreground_execute(f"Command ID: {db_item.id}", cmd.split(' '), db_item.id)
|
||||
self.__foreground_execute(f"Command ID: {db_item.id}", shlex.split(cmd), db_item.id)
|
||||
elif command == 'job_back_execute':
|
||||
self.execute_thread_start(arg1)
|
||||
ret['msg'] = "실행 요청을 하였습니다.<br>로그를 확인하세요."
|
||||
@@ -64,8 +65,8 @@ class PageCommand(PluginPageBase):
|
||||
ret['ret'] = 'danger'
|
||||
ret['msg'] = "로그 파일이 없습니다."
|
||||
elif command == 'task_sched':
|
||||
job_id = req.form['arg1']
|
||||
flag = (req.form['arg2'] == 'true')
|
||||
job_id = arg1
|
||||
flag = (arg2 == 'true')
|
||||
scheduler_id = f'command_{job_id}'
|
||||
if flag and F.scheduler.is_include(scheduler_id):
|
||||
ret['msg'] = '이미 스케쥴러에 등록되어 있습니다.'
|
||||
@@ -92,7 +93,7 @@ class PageCommand(PluginPageBase):
|
||||
if command[0] != 'LOAD':
|
||||
ToolModalCommand.start(title, [command])
|
||||
else:
|
||||
F.socketio.emit("command_modal_show", title, namespace='/framework', broadcast=True)
|
||||
F.socketio.emit("command_modal_show", title, namespace='/framework')
|
||||
def start_communicate_load(load_log_list):
|
||||
def func():
|
||||
while True:
|
||||
@@ -100,7 +101,7 @@ class PageCommand(PluginPageBase):
|
||||
load_log_list.truncate(0)
|
||||
if logs:
|
||||
P.logger.error(logs)
|
||||
F.socketio.emit("command_modal_add_text", logs.strip() + '\n', namespace='/framework', broadcast=True)
|
||||
F.socketio.emit("command_modal_add_text", logs.strip() + '\n', namespace='/framework')
|
||||
if logs == '<<END>>':
|
||||
break
|
||||
time.sleep(0.3)
|
||||
@@ -154,11 +155,12 @@ class PageCommand(PluginPageBase):
|
||||
th = threading.Thread(target=self.execute_thread_function_by_job_id, args=(job_id,))
|
||||
th.setDaemon(True)
|
||||
th.start()
|
||||
return th
|
||||
|
||||
|
||||
def execute_thread_function_by_job_id(self, *args, **kwargs):
|
||||
P.logger.error(d(args))
|
||||
P.logger.error(d(kwargs))
|
||||
#P.logger.error(d(args))
|
||||
#P.logger.error(d(kwargs))
|
||||
db_item = ModelCommand.get_by_id(args[0])
|
||||
kwargs['id'] = args[0]
|
||||
self.execute_thread_function((db_item.command + ' ' + db_item.args).strip(), **kwargs)
|
||||
@@ -166,7 +168,7 @@ class PageCommand(PluginPageBase):
|
||||
|
||||
def execute_thread_function(self, command, **kwargs):
|
||||
try:
|
||||
cmd = command.split(' ')
|
||||
cmd = shlex.split(command)
|
||||
|
||||
if cmd[0] == 'LOAD':
|
||||
command_logger = F.get_logger(f"command_{kwargs['id']}")
|
||||
@@ -177,8 +179,8 @@ class PageCommand(PluginPageBase):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
def stdout_callback(self, mode, text):
|
||||
if mode == 'log':
|
||||
def stdout_callback(self, call_id, mode, text):
|
||||
if mode == 'LOG':
|
||||
self.logger.debug(text)
|
||||
else:
|
||||
self.logger.debug(mode)
|
||||
@@ -194,14 +196,17 @@ class PageCommand(PluginPageBase):
|
||||
def plugin_load(self):
|
||||
def plugin_load_thread():
|
||||
try:
|
||||
while F.config['loading_completed'] == False:
|
||||
time.sleep(1)
|
||||
|
||||
db_items = ModelCommand.get_list()
|
||||
for db_item in db_items:
|
||||
if db_item.schedule_mode == 'startup':
|
||||
self.execute_thread_start(db_item.id)
|
||||
elif db_item.schedule_mode == 'scheduler' and db_item.schedule_auto_start:
|
||||
self.__sched_add(db_item.id, db_item=db_item)
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
try:
|
||||
th = threading.Thread(target=plugin_load_thread)
|
||||
@@ -219,7 +224,7 @@ class PageCommand(PluginPageBase):
|
||||
job_id = f"command_{db_item.id}"
|
||||
if scheduler.is_include(job_id):
|
||||
return
|
||||
job = Job(self.P.package_name, job_id, db_item.schedule_interval, self.execute_thread_function_by_job_id, db_item.description, args=db_item.id)
|
||||
job = Job(self.P.package_name, job_id, db_item.schedule_interval, self.execute_thread_function_by_job_id, db_item.description, args=(db_item.id,))
|
||||
scheduler.add_job_instance(job)
|
||||
return True
|
||||
except Exception as e:
|
||||
@@ -286,6 +291,6 @@ class ModelCommand(ModelBase):
|
||||
item['process'] = (SupportSubprocess.get_instance_by_call_id(f"command_{item['id']}") != None)
|
||||
|
||||
return data
|
||||
except Exception as exception:
|
||||
logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception:{str(e)}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
Reference in New Issue
Block a user