From f0bd2d279e73f60a0d9616be1f743937a887b0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czj=E2=80=9D?= <1052308357@qq.com> Date: Sat, 4 Apr 2026 22:47:48 +0800 Subject: [PATCH] cp to basedir --- config/devices.json | 35 +++++++++++++++++------------------ scripts/generate.py | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/config/devices.json b/config/devices.json index 5f3dd79..36e69b1 100644 --- a/config/devices.json +++ b/config/devices.json @@ -1,12 +1,12 @@ { "global": { - "tms_server_ip": "192.168.139.133", + "tms_server_ip": "192.168.9.9", "python_path": "/usr/bin/python3", - "base_dir": "/home/smart/pythonPJ/upc_resent" + "base_dir": "/opt/upc_resent" }, "command_sets": { "set1": { - "name": "标准8路控制", + "name": "中联", "commands": { "open1": "000100000008010F006400010001", "close1": "000100000008010F006400010000", @@ -29,18 +29,18 @@ } }, "set2": { - "name": "4路精简控制", + "name": "贞名", "commands": { - "open1": "000100000008010F006400010001", - "close1": "000100000008010F006400010000", - "open2": "000100000008010F006500010001", - "close2": "000100000008010F006500010000", - "open3": "000100000008010F006600010001", - "close3": "000100000008010F006600010000", - "open4": "000100000008010F006700010001", - "close4": "000100000008010F006700010000", - "openall": "000100000008010F00640004000F", - "closeall": "000100000008010F006400040000" + "open1": "736574723d31787878", + "close1": "736574723d30787878", + "open2": "736574723d78317878", + "close2": "736574723d78307878", + "open3": "736574723d78783178", + "close3": "736574723d78783078", + "open4": "736574723d78787831", + "close4": "736574723d78787830", + "openall4": "736574723d31313131", + "closeall4": "736574723d30303030" } }, "set3": { @@ -54,7 +54,7 @@ "devices": [ { "id": "dev1", - "name": "设备1-8路控制", + "name": "7号厅", "listen_protocol": "tcp", "device_protocol": "tcp", "command_set": "set1", @@ -66,7 +66,7 @@ }, { "id": "dev2", - "name": "设备2-8路控制", + "name": "12号厅", "listen_protocol": "tcp", "device_protocol": "tcp", "command_set": "set1", @@ -100,7 +100,6 @@ ], "mappings": { "open": "openall4", - "close": "closeall4", - "guanggao-guan": "closeall4" + "close": "closeall4" } } diff --git a/scripts/generate.py b/scripts/generate.py index 235b753..4b70d75 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -244,7 +244,13 @@ def generate_crontab(devices, global_config): with open(output_file, 'w', encoding='utf-8') as f: f.write(content) - print(f"[生成] {output_file}") + # 同时复制到 base_dir 目录 + base_dir = global_config['base_dir'] + target_file = os.path.join(base_dir, 'crontab.txt') + with open(target_file, 'w', encoding='utf-8') as f: + f.write(content) + + print(f"[生成] {output_file} -> {target_file}") return output_file @@ -278,12 +284,20 @@ def generate_control_script(devices, global_config): content = content.replace('{python_path}', global_config['python_path']) content = content.replace('{device_defs}', device_defs) + # 生成到项目根目录 output_file = 'control.sh' with open(output_file, 'w', encoding='utf-8') as f: f.write(content) - os.chmod(output_file, 0o755) - print(f"[生成] {output_file}") + + # 同时复制到 base_dir 目录 + base_dir = global_config['base_dir'] + target_file = os.path.join(base_dir, 'control.sh') + with open(target_file, 'w', encoding='utf-8') as f: + f.write(content) + os.chmod(target_file, 0o755) + + print(f"[生成] {output_file} -> {target_file}") return output_file