linkkf 로직수정중
This commit is contained in:
@@ -27,7 +27,12 @@ def default_route(P):
|
||||
def first_menu(sub):
|
||||
try:
|
||||
if P.ModelSetting is not None and (P.package_name == 'system' and sub != 'home'):
|
||||
P.ModelSetting.set('recent_menu_plugin', '{}'.format(sub))
|
||||
current_menu = sub
|
||||
for except_menu in P.recent_menu_plugin_except_list:
|
||||
if current_menu.startswith(except_menu) or current_menu == except_menu:
|
||||
break
|
||||
else:
|
||||
P.ModelSetting.set('recent_menu_plugin', current_menu)
|
||||
for module in P.module_list:
|
||||
if sub == module.name:
|
||||
first_menu = module.get_first_menu()
|
||||
@@ -45,8 +50,8 @@ def default_route(P):
|
||||
return redirect(f"/{P.package_name}/manual/{P.get_first_manual_path()}")
|
||||
|
||||
return render_template('sample.html', title='%s - %s' % (P.package_name, sub))
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/manual/<path:path>', methods=['GET', 'POST'])
|
||||
@@ -57,16 +62,43 @@ def default_route(P):
|
||||
filepath = os.path.join(plugin_root, *path.split('/'))
|
||||
from support import SupportFile
|
||||
data = SupportFile.read_file(filepath)
|
||||
if filepath.endswith('.mdf'):
|
||||
try:
|
||||
from support import SupportSC
|
||||
data = SupportSC.decode(data)
|
||||
except:
|
||||
pass
|
||||
return render_template('manual.html', data=data)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/<module_name>/manual/<path:path>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def module_manual(module_name, path):
|
||||
try:
|
||||
plugin_root = os.path.dirname(P.blueprint.template_folder)
|
||||
filepath = os.path.join(plugin_root, *path.split('/'))
|
||||
from support import SupportFile
|
||||
data = SupportFile.read_file(filepath)
|
||||
return render_template('manual.html', data=data)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@P.blueprint.route('/<sub>/<sub2>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def second_menu(sub, sub2):
|
||||
if sub2 == 'null':
|
||||
return
|
||||
if P.ModelSetting is not None:
|
||||
P.ModelSetting.set('recent_menu_plugin', '{}|{}'.format(sub, sub2))
|
||||
current_menu = f"{sub}|{sub2}"
|
||||
for except_menu in P.recent_menu_plugin_except_list:
|
||||
if current_menu.startswith(except_menu) or current_menu == except_menu:
|
||||
break
|
||||
else:
|
||||
P.ModelSetting.set('recent_menu_plugin', current_menu)
|
||||
try:
|
||||
for module in P.module_list:
|
||||
if sub == module.name:
|
||||
@@ -74,8 +106,8 @@ def default_route(P):
|
||||
if sub == 'log':
|
||||
return render_template('log.html', package=P.package_name)
|
||||
return render_template('sample.html', title='%s - %s' % (P.package_name, sub))
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
#########################################################
|
||||
@@ -84,7 +116,7 @@ def default_route(P):
|
||||
@P.blueprint.route('/ajax/<sub>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def ajax(sub):
|
||||
P.logger.debug('AJAX %s %s', P.package_name, sub)
|
||||
#P.logger.debug('AJAX %s %s', P.package_name, sub)
|
||||
try:
|
||||
# global
|
||||
if sub == 'setting_save':
|
||||
@@ -93,8 +125,8 @@ def default_route(P):
|
||||
module.setting_save_after(change_list)
|
||||
return jsonify(ret)
|
||||
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/ajax/<module_name>/<cmd>', methods=['GET', 'POST'])
|
||||
@@ -109,8 +141,9 @@ def default_route(P):
|
||||
else:
|
||||
P.logic.scheduler_stop(module_name)
|
||||
return jsonify(go)
|
||||
elif cmd == 'reset_db':
|
||||
ret = P.logic.reset_db(module_name)
|
||||
elif cmd == 'db_delete':
|
||||
day = request.form['day']
|
||||
ret = P.logic.db_delete(module_name, None, day)
|
||||
return jsonify(ret)
|
||||
elif cmd == 'one_execute':
|
||||
ret = P.logic.one_execute(module_name)
|
||||
@@ -118,18 +151,25 @@ def default_route(P):
|
||||
elif cmd == 'immediately_execute':
|
||||
ret = P.logic.immediately_execute(module_name)
|
||||
return jsonify(ret)
|
||||
elif cmd == 'web_list':
|
||||
model = P.logic.get_module(module_name).web_list_model
|
||||
if model != None:
|
||||
return jsonify(model.web_list(request))
|
||||
|
||||
|
||||
if module_name == module.name:
|
||||
if cmd == 'command':
|
||||
return module.process_command(request.form['command'], request.form.get('arg1'), request.form.get('arg2'), request.form.get('arg3'), request)
|
||||
elif cmd == 'web_list':
|
||||
model = P.logic.get_module(module_name).web_list_model
|
||||
if model != None:
|
||||
return jsonify(model.web_list(request))
|
||||
elif cmd == 'db_delete_item':
|
||||
db_id = request.form['db_id']
|
||||
ret = False
|
||||
if module.web_list_model != None:
|
||||
ret = module.web_list_model.delete_by_id(db_id)
|
||||
return jsonify(ret)
|
||||
else:
|
||||
return module.process_ajax(cmd, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/ajax/<module_name>/<page_name>/<command>', methods=['GET', 'POST'])
|
||||
@@ -148,10 +188,10 @@ def default_route(P):
|
||||
else:
|
||||
P.logic.scheduler_stop_sub(module_name, page_name)
|
||||
return jsonify(go)
|
||||
#elif command == 'reset_db':
|
||||
# sub = request.form['sub']
|
||||
# ret = P.logic.reset_db(sub)
|
||||
# return jsonify(ret)
|
||||
elif command == 'db_delete':
|
||||
day = request.form['day']
|
||||
ret = P.logic.db_delete(module_name, page_name, day)
|
||||
return jsonify(ret)
|
||||
elif command == 'one_execute':
|
||||
ret = P.logic.one_execute_sub(module_name, page_name)
|
||||
return jsonify(ret)
|
||||
@@ -160,25 +200,30 @@ def default_route(P):
|
||||
return jsonify(ret)
|
||||
elif command == 'command':
|
||||
return ins_page.process_command(request.form['command'], request.form.get('arg1'), request.form.get('arg2'), request.form.get('arg3'), request)
|
||||
elif command == 'db_delete_item':
|
||||
db_id = request.form['db_id']
|
||||
ret = False
|
||||
if ins_page.web_list_model != None:
|
||||
ret = ins_page.web_list_model.delete_by_id(db_id)
|
||||
return jsonify(ret)
|
||||
else:
|
||||
return ins_page.process_ajax(command, request)
|
||||
P.logger.error(f"not process ajax : {P.package_name} {module_name} {page_name} {command}")
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
#########################################################
|
||||
# API - 외부
|
||||
#########################################################
|
||||
# 단일 모듈인 경우 모듈이름을 붙이기 불편하여 추가.
|
||||
@P.blueprint.route('/api/<sub2>', methods=['GET', 'POST'])
|
||||
@P.blueprint.route('/api/<sub>', methods=['GET', 'POST'])
|
||||
@F.check_api
|
||||
def api_first(sub2):
|
||||
def api_first(sub):
|
||||
try:
|
||||
for module in P.module_list:
|
||||
return module.process_api(sub2, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
return P.module_list[0].process_api(sub, request)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/api/<sub>/<sub2>', methods=['GET', 'POST'])
|
||||
@@ -188,8 +233,16 @@ def default_route(P):
|
||||
for module in P.module_list:
|
||||
if sub == module.name:
|
||||
return module.process_api(sub2, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/normal/<sub>', methods=['GET', 'POST'])
|
||||
def normal_first(sub):
|
||||
try:
|
||||
return P.module_list[0].process_normal(sub, request)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/normal/<sub>/<sub2>', methods=['GET', 'POST'])
|
||||
@@ -198,13 +251,13 @@ def default_route(P):
|
||||
for module in P.module_list:
|
||||
if sub == module.name:
|
||||
return module.process_normal(sub2, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
|
||||
# default_route 끝
|
||||
|
||||
|
||||
|
||||
@@ -266,18 +319,14 @@ def default_route_single_module(P):
|
||||
else:
|
||||
P.logic.scheduler_stop(sub)
|
||||
return jsonify(go)
|
||||
elif sub == 'reset_db':
|
||||
sub = request.form['sub']
|
||||
ret = P.logic.reset_db(sub)
|
||||
return jsonify(ret)
|
||||
elif sub == 'one_execute':
|
||||
sub = request.form['sub']
|
||||
ret = P.logic.one_execute(sub)
|
||||
return jsonify(ret)
|
||||
else:
|
||||
return P.module_list[0].process_ajax(sub, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/api/<sub>', methods=['GET', 'POST'])
|
||||
@@ -285,16 +334,16 @@ def default_route_single_module(P):
|
||||
def api(sub):
|
||||
try:
|
||||
return P.module_list[0].process_api(sub, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@P.blueprint.route('/normal/<sub>', methods=['GET', 'POST'])
|
||||
def normal(sub):
|
||||
try:
|
||||
return P.module_list[0].process_normal(sub, request)
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -330,14 +379,15 @@ def default_route_socketio_module(module, attach=''):
|
||||
module.socketio_list = []
|
||||
|
||||
@F.socketio.on('connect', namespace=f'/{P.package_name}/{module.name}{attach}')
|
||||
@F.login_required
|
||||
def connect():
|
||||
try:
|
||||
P.logger.debug(f'socket_connect : {P.package_name} - {module.name}{attach}')
|
||||
module.socketio_list.append(request.sid)
|
||||
socketio_callback('start', '')
|
||||
module.socketio_connect()
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -347,8 +397,8 @@ def default_route_socketio_module(module, attach=''):
|
||||
P.logger.debug(f'socket_disconnect : {P.package_name} - {module.name}{attach}')
|
||||
module.socketio_list.remove(request.sid)
|
||||
module.socketio_disconnect()
|
||||
except Exception as exception:
|
||||
P.logger.error('Exception:%s', exception)
|
||||
except Exception as e:
|
||||
P.logger.error(f"Exception:{str(e)}")
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
@@ -357,7 +407,7 @@ def default_route_socketio_module(module, attach=''):
|
||||
if encoding:
|
||||
data = json.dumps(data, cls=AlchemyEncoder)
|
||||
data = json.loads(data)
|
||||
F.socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}{attach}', broadcast=True)
|
||||
F.socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}{attach}')
|
||||
|
||||
module.socketio_callback = socketio_callback
|
||||
|
||||
@@ -392,9 +442,10 @@ def default_route_socketio_page(page):
|
||||
page.socketio_list = []
|
||||
|
||||
@F.socketio.on('connect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
||||
@F.login_required
|
||||
def page_socketio_connect():
|
||||
try:
|
||||
P.logger.debug(f'socket_connect : {P.package_name}/{module.name}/{page.name}')
|
||||
#P.logger.debug(f'socket_connect : {P.package_name}/{module.name}/{page.name}')
|
||||
page.socketio_list.append(request.sid)
|
||||
page_socketio_socketio_callback('start', '')
|
||||
except Exception as e:
|
||||
@@ -405,7 +456,7 @@ def default_route_socketio_page(page):
|
||||
@F.socketio.on('disconnect', namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
||||
def page_socketio_disconnect():
|
||||
try:
|
||||
P.logger.debug(f'socket_disconnect : {P.package_name}/{module.name}/{page.name}')
|
||||
#P.logger.debug(f'socket_disconnect : {P.package_name}/{module.name}/{page.name}')
|
||||
page.socketio_list.remove(request.sid)
|
||||
except Exception as e:
|
||||
P.logger.error(f'Exception:{str(e)}')
|
||||
@@ -417,6 +468,6 @@ def default_route_socketio_page(page):
|
||||
if encoding:
|
||||
data = json.dumps(data, cls=AlchemyEncoder)
|
||||
data = json.loads(data)
|
||||
F.socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}/{page.name}', broadcast=True)
|
||||
F.socketio.emit(cmd, data, namespace=f'/{P.package_name}/{module.name}/{page.name}')
|
||||
|
||||
page.socketio_callback = page_socketio_socketio_callback
|
||||
|
||||
Reference in New Issue
Block a user