From e599b0c4aa79b5795b04ab0f91bfbafdffaff638 Mon Sep 17 00:00:00 2001 From: flaskfarm Date: Thu, 13 Oct 2022 02:11:01 +0900 Subject: [PATCH] update --- lib/framework/init_main.py | 1 + lib/framework/init_plugin.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/framework/init_main.py b/lib/framework/init_main.py index 8bb478b..57147f5 100644 --- a/lib/framework/init_main.py +++ b/lib/framework/init_main.py @@ -207,6 +207,7 @@ class Framework: #system.LogicPlugin.custom_plugin_update() from .init_plugin import PluginManager self.PluginManager = PluginManager + PluginManager.plugin_update() PluginManager.plugin_init() PluginManager.plugin_menus['system'] = {'menu':SP.menu, 'match':False} diff --git a/lib/framework/init_plugin.py b/lib/framework/init_plugin.py index 4153731..be7d741 100644 --- a/lib/framework/init_plugin.py +++ b/lib/framework/init_plugin.py @@ -421,3 +421,32 @@ class PluginManager: ret['ret'] = 'danger' ret['msg'] = str(e) return ret + + + @classmethod + def plugin_update(cls): + try: + if os.environ.get('UPDATE_STOP') == 'true': + return + if os.environ.get('PLUGIN_UPDATE_FROM_PYTHON') == 'false': + return + if F.config['plugin_update'] != True: + return + plugins_path = os.path.join(F.config['path_data'], 'plugins') + tmps = os.listdir(plugins_path) + for t in tmps: + plugin_path = os.path.join(plugins_path, t) + if t.startswith('_'): + continue + if os.path.exists(os.path.join(plugin_path, '.git')): + command = ['git', '-C', plugin_path, 'reset', '--hard', 'HEAD'] + ret = SupportSubprocess.execute_command_return(command) + F.logger.debug(ret) + command = ['git', '-C', plugin_path, 'pull'] + ret = SupportSubprocess.execute_command_return(command) + F.logger.debug(ret) + else: + F.logger.debug(f"{plugin_path} not git repo") + except Exception as exception: + F.logger.error('Exception:%s', exception) + F.logger.error(traceback.format_exc())