From c146e03cf1de2ea33aa86698897b3e3c8d72cf4b Mon Sep 17 00:00:00 2001 From: flaskfarm Date: Wed, 19 Oct 2022 16:40:29 +0900 Subject: [PATCH] update --- cli/code_encode.py | 2 +- lib/framework/init_main.py | 37 ++- lib/framework/init_menu.py | 3 +- lib/framework/init_route.py | 1 - lib/framework/static/js/ff_common1.js | 8 +- lib/framework/static/js/ff_global1.js | 14 + lib/framework/static/js/ff_ui1.js | 79 +++-- lib/framework/static/js/sjva_ui14.js | 9 +- lib/framework/templates/log.html | 6 +- lib/framework/templates/macro.html | 113 ++++--- lib/framework/templates/macro_menu.html | 2 + lib/framework/version.py | 2 +- lib/plugin/logic.py | 12 + lib/plugin/model_base.py | 71 ++-- lib/plugin/route.py | 2 +- lib/support/base/sub_process.py | 39 ++- lib/system/mod_log.py | 5 + lib/system/mod_tool.py | 16 +- lib/system/page_command.py | 291 ++++++++++++++++ lib/system/setup.py | 1 + lib/system/templates/system_all_log.html | 11 +- lib/system/templates/system_home.html | 52 +-- lib/system/templates/system_plugin_list.html | 40 +-- lib/system/templates/system_setting_auth.html | 9 +- lib/system/templates/system_tool_command.html | 310 ++++++++++++++++++ lib/system/templates/system_tool_python.html | 76 +++++ 26 files changed, 965 insertions(+), 246 deletions(-) create mode 100644 lib/system/page_command.py create mode 100644 lib/system/templates/system_tool_command.html create mode 100644 lib/system/templates/system_tool_python.html diff --git a/cli/code_encode.py b/cli/code_encode.py index 8ab44e5..a9b38de 100644 --- a/cli/code_encode.py +++ b/cli/code_encode.py @@ -43,4 +43,4 @@ class CodeEncode: if __name__== "__main__": CodeEncode().process_args() - # python C:\work\FlaskFarm\flaskfarm\lib\cli\code_encode.py --source=C:\work\FlaskFarm\data\LOADING\klive_plus\source_spotv.py +# python C:\work\FlaskFarm\flaskfarm\cli\code_encode.py --source=C:\work\FlaskFarm\data\LOADING\sjva diff --git a/lib/framework/init_main.py b/lib/framework/init_main.py index f4caa9f..50cb278 100644 --- a/lib/framework/init_main.py +++ b/lib/framework/init_main.py @@ -57,6 +57,7 @@ class Framework: def __initialize(self): + os.environ["PYTHONUNBUFFERED"] = "1" os.environ['FF'] = "true" self.__config_initialize("first") self.__make_default_dir() @@ -118,7 +119,9 @@ class Framework: for package_name in plugins: db_path = os.path.join(self.config['path_data'], 'db', f'{package_name}.db') self.app.config['SQLALCHEMY_BINDS'][package_name] = f'sqlite:///{db_path}' - self.db = SQLAlchemy(self.app, session_options={"autoflush": False}) + self.db = SQLAlchemy(self.app, session_options={"autoflush": False, "expire_on_commit": False}) + #with self.app.app_context(): + # self.db.session.expunge_all() def __init_celery(self): @@ -222,6 +225,7 @@ class Framework: from . import init_route, log_viewer self.__make_default_logger() + self.__config_initialize("last") self.logger.info('### LAST') self.logger.info(f"### PORT: {self.config.get('port')}") self.logger.info('### Now you can access App by webbrowser!!') @@ -266,6 +270,18 @@ class Framework: self.app.config['JSON_AS_ASCII'] = False elif mode == 'system_loading_after': pass + elif mode == 'last': + db_foder = os.path.join(self.config['path_data'], 'db') + for name in os.listdir(db_foder): + if name.endswith('.db'): + db_filepath = os.path.join(db_foder, name) + try: + if os.stat(db_filepath).st_size == 0: + os.remove(db_filepath) + self.logger.debug(f"REMOVE {db_filepath}") + except: + pass + def __init_define(self): @@ -372,7 +388,7 @@ class Framework: ################################################### # 로그 ################################################### - def get_logger(self, name): + def get_logger(self, name, from_command=False): logger = logging.getLogger(name) if not logger.handlers: level = logging.DEBUG @@ -396,25 +412,26 @@ class Framework: except: pass logger.setLevel(level) - file_formatter = logging.Formatter(u'[%(asctime)s|%(levelname)s|%(filename)s:%(lineno)s] %(message)s') def customTime(*args): utc_dt = utc.localize(datetime.utcnow()) my_tz = timezone("Asia/Seoul") converted = utc_dt.astimezone(my_tz) return converted.timetuple() + if from_command == False: + file_formatter = logging.Formatter(u'[%(asctime)s|%(levelname)s|%(filename)s:%(lineno)s] %(message)s') + else: + file_formatter = logging.Formatter(u'[%(asctime)s] %(message)s') + file_formatter.converter = customTime file_max_bytes = 1 * 1024 * 1024 fileHandler = logging.handlers.RotatingFileHandler(filename=os.path.join(self.path_data, 'log', f'{name}.log'), maxBytes=file_max_bytes, backupCount=5, encoding='utf8', delay=True) - streamHandler = logging.StreamHandler() - - # handler에 fommater 세팅 fileHandler.setFormatter(file_formatter) - streamHandler.setFormatter(CustomFormatter()) - - # Handler를 logging에 추가 logger.addHandler(fileHandler) - logger.addHandler(streamHandler) + if from_command == False: + streamHandler = logging.StreamHandler() + streamHandler.setFormatter(CustomFormatter()) + logger.addHandler(streamHandler) return logger diff --git a/lib/framework/init_menu.py b/lib/framework/init_menu.py index 0b2d769..6630820 100644 --- a/lib/framework/init_menu.py +++ b/lib/framework/init_menu.py @@ -1,7 +1,7 @@ import os import shutil -from support import SupportYaml +from support import SupportYaml, d from framework import F @@ -89,4 +89,5 @@ class MenuManager: @classmethod def get_menu_map(cls): + #F.logger.warning(d(cls.menu_map)) return cls.menu_map diff --git a/lib/framework/init_route.py b/lib/framework/init_route.py index 8f3fa59..ac4cf5c 100644 --- a/lib/framework/init_route.py +++ b/lib/framework/init_route.py @@ -128,4 +128,3 @@ def videojs(): def connect(): pass - diff --git a/lib/framework/static/js/ff_common1.js b/lib/framework/static/js/ff_common1.js index 88c6ec3..e043560 100644 --- a/lib/framework/static/js/ff_common1.js +++ b/lib/framework/static/js/ff_common1.js @@ -53,7 +53,7 @@ $.notify({ }, offset: 20, spacing: 10, - z_index: 1031, + z_index: 3000, delay: 10000, timer: 1000, url_target: '_blank', @@ -81,7 +81,7 @@ $.notify({ function notify(msg, type) { - $.notify('' + msg + '', {type: type}); + $.notify('' + msg + '', {type: type, z_index: 3000}); } // 메뉴 제거 @@ -289,8 +289,8 @@ $.extend( { var form = ''; $.each( args, function( key, value ) { - //console.log(key); - //console.log(value); + console.log(key); + console.log(value); value = value.split('"').join('\"') form += ''; }); diff --git a/lib/framework/static/js/ff_global1.js b/lib/framework/static/js/ff_global1.js index d4e766c..e0c5301 100644 --- a/lib/framework/static/js/ff_global1.js +++ b/lib/framework/static/js/ff_global1.js @@ -1,5 +1,6 @@ // global socketio $(document).ready(function(){ + ResizeTextArea(); }); $(document).ready(function(){ @@ -23,6 +24,7 @@ frameSocket.on('notify', function(data){ target: '_self' },{ type: data['type'], + z_index: 2000, }); }); @@ -317,5 +319,17 @@ $("body").on('click', '#command_modal_input_btn', function(e) { }); }); + +$(window).resize(function() { + ResizeTextArea(); +}); + + +function ResizeTextArea() { + ClientHeight = window.innerHeight + $("#command_modal").height(ClientHeight-100); + $("#command_modal_textarea").height(ClientHeight-380); +} + /////////////////////////////////////// diff --git a/lib/framework/static/js/ff_ui1.js b/lib/framework/static/js/ff_ui1.js index ee43e42..f2a0494 100644 --- a/lib/framework/static/js/ff_ui1.js +++ b/lib/framework/static/js/ff_ui1.js @@ -1,4 +1,4 @@ -function m_button_group(h) { +function j_button_group(h) { var str = '
'; str += h str += '
'; @@ -6,7 +6,7 @@ function m_button_group(h) { } // primary, secondary, success, danger, warning, info, light, dark, white -function m_button(id, text, data={}, color='success', outline=true, small=false) { +function j_button(id, text, data={}, color='success', outline=true, small=false) { var str = ' + {% endfor %} + + + {{ setting_bottom(desc) }} +{% endmacro %} + + + + {% macro setting_radio_with_value(id, title, radios, value=None, desc=None, disabled=False) %} {{ setting_top(title) }} @@ -635,62 +694,8 @@ macros.setting_button_with_info([['toggle_btn', 'Toggle', [{'key':'category', 'v -{% macro setting_input_textarea_wide(id, left, value='', col='12', row='3', desc='', disabled=False, padding='10') %} -
-
- {% if left != '' %} -
- {{ left }} -
- {% endif %} -
- -
- {% if desc is not none %} -
- - {% if desc is string %} - {{ desc }} - {% elif desc is iterable %} - {% for d in desc %} - {{ d }}
- {% endfor %} - {% endif %} -
-
- {% endif %} -
-
-{% endmacro %} -{% macro setting_input_textarea_and_buttons(id, left, buttons, value='', col='9', row='3', desc='', disabled=False) %} - {{ setting_top(left) }} -
- -
- {% for b in buttons %} - - {% endfor %} -
-
- {{ setting_bottom(desc) }} -{% endmacro %} - diff --git a/lib/framework/templates/macro_menu.html b/lib/framework/templates/macro_menu.html index d21c344..5d407a3 100644 --- a/lib/framework/templates/macro_menu.html +++ b/lib/framework/templates/macro_menu.html @@ -18,6 +18,8 @@ {% for category in menu_map %} {% if 'uri' in category and category['uri'].startswith('http') %} + {% elif 'uri' in category and category['uri'].startswith('http') == False %} + {% else %}