27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
import subprocess
|
||
|
||
# 更新 crontab:cron_to_xmpp.py 改指 deploy 路径(web-dashboard 副本已归档)
|
||
r = subprocess.run(['crontab', '-l'], capture_output=True, text=True)
|
||
lines = r.stdout.splitlines()
|
||
new_lines = []
|
||
for line in lines:
|
||
if 'cron_to_xmpp.py' in line and 'web-dashboard' in line:
|
||
new_line = line.replace(
|
||
'cd /home/hmo/web-dashboard && python3 cron_to_xmpp.py',
|
||
'cd /home/hmo/MoFin/deploy/profile-scripts && python3 cron_to_xmpp.py')
|
||
new_lines.append(new_line)
|
||
print('CHANGED:')
|
||
print(' old:', line)
|
||
print(' new:', new_line)
|
||
else:
|
||
new_lines.append(line)
|
||
|
||
p = subprocess.run(['crontab', '-'], input='\n'.join(new_lines) + '\n',
|
||
capture_output=True, text=True)
|
||
print('crontab updated, rc=', p.returncode)
|
||
|
||
# 验证 deploy 版本能跑(dry check: import + 语法)
|
||
r2 = subprocess.run(
|
||
"cd /home/hmo/MoFin/deploy/profile-scripts && python3 -c 'import ast; ast.parse(open(\"cron_to_xmpp.py\").read()); print(\"syntax OK\")'",
|
||
shell=True, capture_output=True, text=True, timeout=10)
|
||
print(r2.stdout.strip() or r2.stderr.strip()[:200]) |