#!/usr/bin/env python3 """Environment analyzer - produces structured system info.""" import os import sys import platform import subprocess import json from datetime import datetime def get_shell_info(): """Get shell environment info.""" shell = os.environ.get('SHELL', 'unknown') term = os.environ.get('TERM', 'unknown') return {'shell': shell, 'term': term} def get_hermes_info(): """Get Hermes profile and config info.""" profile = os.environ.get('SPARK_PROFILE', 'spark') scratch = os.environ.get('TMPDIR', '/tmp') cwd = os.getcwd() home = os.environ.get('HOME', 'unknown') return { 'profile': profile, 'scratch_dir': scratch, 'cwd': cwd, 'home': home } def get_python_info(): """Get Python version and path.""" return { 'version': sys.version, 'version_info': list(sys.version_info), 'executable': sys.executable } def get_platform_info(): """Get platform info.""" return { 'system': platform.system(), 'release': platform.release(), 'machine': platform.machine(), 'processor': platform.processor() } def run_command(cmd): """Run a shell command and return output.""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=5) return result.stdout.strip() if result.returncode == 0 else None except: return None def main(): """Main entry point.""" info = { 'timestamp': datetime.utcnow().isoformat() + 'Z', 'shell': get_shell_info(), 'hermes': get_hermes_info(), 'python': get_python_info(), 'platform': get_platform_info(), 'node_id': run_command('hostname') or 'unknown', 'uptime': run_command('uptime -p') or 'unknown' } output_path = '/root/.hermes/wizard-outputs/spark/system_info.json' with open(output_path, 'w') as f: json.dump(info, f, indent=2) print(f"System info written to {output_path}") return info if __name__ == '__main__': result = main() print(json.dumps(result, indent=2))