probe-trial-runtime.py 1.0 KB

12345678910111213141516171819202122
  1. """Inspect supported image prerequisites without network or changing runtime files."""
  2. import json
  3. import os
  4. from pathlib import Path
  5. roots = [Path('/opt/data'), Path('/root/.hermes'), Path('/home/hermes/.hermes')]
  6. result = {'uid': os.getuid(), 'home': os.environ.get('HOME'),
  7. 'hermesHome': os.environ.get('HERMES_HOME'), 'roots': {}}
  8. for root in roots:
  9. entry = {'exists': root.exists()}
  10. if root.exists():
  11. entry['entries'] = sorted(p.name for p in root.iterdir())
  12. entry['plugins'] = sorted(p.name for p in (root / 'plugins').glob('*'))
  13. entry['scripts'] = sorted(p.name for p in (root / 'scripts').glob('*'))
  14. result['roots'][str(root)] = entry
  15. result['source'] = {}
  16. for relative in ['docker/entrypoint-dispatch.sh', 'docker/main-wrapper.sh', 'docker/entrypoint.sh',
  17. 'hermes_cli/config.py', 'hermes_cli/paths.py', 'gateway/platforms/matrix.py']:
  18. file = Path('/opt/hermes') / relative
  19. if file.is_file():
  20. result['source'][relative] = file.read_text()
  21. print(json.dumps(result, ensure_ascii=False))