Files
MoFin/archive/hermes-dead-tools-20260820/remove_xiaoguo.py
T
xxm c68f987653 chore(cleansweep): 代码大扫除——归档hermes 111个死工具+4个废弃scanner,收敛MoFin/scripts重复副本,删除根旧版mo_models
- archive/hermes-dead-tools-20260820/: hermes独有不在cron不被import的111个一次性排查/测试工具
- archive/hermes-dead-tools-20260820/: 4个废弃scanner(btd1_v3/market_scanner/market_thermometer已废弃/s2v2)
- archive/legacy-cleanup-20260820/: MoFin根2旧版(mo_models/technical_analysis)+/home/hmo/scripts无引用旧项目+MoFin/scripts重复prepare_report_data
- 删除MoFin根mo_models.py(根旧版,deploy/profile-scripts权威保留)
- 保留: mofin_db.py/mo_data.py硬链接(server.py多层sys.path需各目录访问同一inode,非冗余)
- fix_gateway.py保留(Gateway看门狗fix_gateway_port.py的活跃依赖,勿误删)
- 验证: cron所有脚本引用无缺失, key模块import正常
- hermes独有从116收敛到5核心(alert_logger/market_screener/prepare_report_data/self_todo_executor_v2/xmpp_zhiwei_bot)
2026-08-20 10:36:25 +08:00

52 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json, shutil, os
from datetime import datetime
# 1. 删小果相关 cron jobquick-scan / tunnel-watchdog / 情感分析 / 独立扫描)
REMOVE_JOBS = {'xiaoguo-quick-scan', 'xiaoguo-tunnel-watchdog', '小果情感分析', '小果独立扫描'}
for jf in ['/home/hmo/.hermes/profiles/position-analyst/cron/jobs.json',
'/home/hmo/.hermes/cron/jobs.json']:
shutil.copy(jf, jf + '.bak-20260720-xiaoguo')
d = json.load(open(jf))
is_list = isinstance(d, list)
jobs = d if is_list else d.get('jobs', [])
kept = [j for j in jobs if j.get('name') not in REMOVE_JOBS]
removed = [j.get('name') for j in jobs if j.get('name') in REMOVE_JOBS]
if removed:
print(f'{jf}: removed {removed}')
if is_list:
json.dump(kept, open(jf, 'w'), ensure_ascii=False, indent=2)
else:
d['jobs'] = kept
json.dump(d, open(jf, 'w'), ensure_ascii=False, indent=2)
else:
print(f'{jf}: nothing to remove')
# 2. 归档小果脚本和数据文件
ARCHIVE = '/home/hmo/MoFin/archive/xiaoguo-retired-20260720'
os.makedirs(ARCHIVE, exist_ok=True)
candidates = [
'/home/hmo/MoFin/deploy/profile-scripts/xiaoguo_scanner.py',
'/home/hmo/MoFin/deploy/profile-scripts/xiaoguo_news_processor.py',
'/home/hmo/MoFin/deploy/profile-scripts/xiaoguo_sentiment_bridge.py',
'/home/hmo/MoFin/deploy/profile-scripts/xiaoguo_signal_consumer.py',
'/home/hmo/MoFin/scripts/inject_xiaoguo_insight.py',
'/home/hmo/web-dashboard/data/xiaoguo_insights.json',
'/home/hmo/web-dashboard/data/xiaoguo_sentiment.json',
'/home/hmo/MoFin/data/xiaoguo_insights.json',
'/home/hmo/MoFin/data/xiaoguo_sentiment.json',
]
for f in candidates:
if os.path.exists(f):
shutil.move(f, os.path.join(ARCHIVE, os.path.basename(f)))
print('archived:', f)
# 3. 处理 profile scripts 里残留的 xiaoguo 硬链接
import glob
for f in glob.glob('/home/hmo/.hermes/profiles/position-analyst/scripts/xiaoguo_*.py'):
os.unlink(f)
print('unlinked:', f)
# 4. 检查 default profile scripts 的 xiaoguo 文件
for f in glob.glob('/home/hmo/.hermes/scripts/xiaoguo_*.py') + glob.glob('/home/hmo/.hermes/scripts/xiaoguo_*.sh'):
print('default profile xiaoguo file:', f)
print('DONE')