cp to basedir
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user