cp to basedir

This commit is contained in:
“zj”
2026-04-04 22:47:48 +08:00
parent 1aa8f7b608
commit f0bd2d279e
2 changed files with 34 additions and 21 deletions

View File

@@ -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