浏览代码

!2 add write daily cfg to minio

pcacc 1 周之前
父节点
当前提交
20394509e3
共有 2 个文件被更改,包括 32 次插入23 次删除
  1. 32 14
      app_dongri.py
  2. 0 9
      daily.json

+ 32 - 14
app_dongri.py

@@ -558,22 +558,40 @@ def read_cfg():
 
     
 def write_Dailycfg(config):
-    with open('daily.json', 'w') as config_file:
-        json.dump(config, config_file, indent=4)
+    try:
+        config_manager = MinIOConfigManager()
+        localCfg_name = task_getComputerName() + '_daily'
+        config_manager.set_config(localCfg_name, config)
+    except Exception as e:
+        print("写入minIO错误, 尝试写入本地")
+        with open('daily.json', 'w') as config_file:
+            json.dump(config, config_file, indent=4)
+
+
+    
 def read_Dailycfg():
     try:
-        with open('daily.json', 'r') as config_file:
-            config = json.load(config_file)
-            return config
-    except FileNotFoundError:
-        print("配置文件不存在,请检查文件路径。")
-        return None
-    except PermissionError:
-        print("没有权限读取配置文件。")
-        return None
-    except json.JSONDecodeError:
-        print("配置文件格式错误,请检查文件内容是否为有效的 JSON。")
-        return None
+        config_manager = MinIOConfigManager()
+        localCfg_name = task_getComputerName() + '_daily'
+        localCfg = config_manager.get_config(localCfg_name)
+        config = json.loads(localCfg)
+        return config
+    except Exception as e:
+        print("读取minIO错误, 尝试读取本地")
+        try:
+            with open('daily.json', 'r') as config_file:
+                config = json.load(config_file)
+                return config
+        except FileNotFoundError:
+            print("配置文件不存在,请检查文件路径。")
+            return None
+        except PermissionError:
+            print("没有权限读取配置文件。")
+            return None
+        except json.JSONDecodeError:
+            print("配置文件格式错误,请检查文件内容是否为有效的 JSON。")
+            return None
+    
 
 @socketio.on('begin_auto')
 def handle_auto(data):

+ 0 - 9
daily.json

@@ -1,9 +0,0 @@
-{
-    "daily": {
-        "2025-07-11": {
-            "login_task": true,
-            "fight_bigMonster_times": 0
-        }
-    },
-    "runType": 1
-}