Explorer
/proc/2012/task/2072/root/tmp/remove_apollo_everywhere.py
← Zurück ↓ Download
from pathlib import Path
from datetime import datetime
stamp=datetime.now().strftime('%Y%m%d-%H%M%S')

p=Path('/opt/struktur/projects-dashboard/app.py')
t=p.read_text()
Path(str(p)+f'.bak-remove-apollo-{stamp}').write_text(t)
t=t.replace('from apollo import apollo_bp\n','')
t=t.replace('app.register_blueprint(apollo_bp)\n','')
p.write_text(t)

p=Path('/opt/struktur/agent-solutions-cockpit/app.py')
t=p.read_text()
Path(str(p)+f'.bak-remove-apollo-{stamp}').write_text(t)
start=t.find("    {\n        'id': 'hermes-apollo',")
if start<0: raise SystemExit('Apollo service block not found')
end=t.find('    },', start)
if end<0: raise SystemExit('Apollo service block end not found')
t=t[:start]+t[end+7:]
p.write_text(t)

ap=Path('/opt/struktur/projects-dashboard/apollo.py')
if ap.exists():
    ap.rename(Path(str(ap)+f'.removed-{stamp}'))
print('REMOVED', stamp)