#!/usr/bin/env python3 import json, subprocess, shutil from pathlib import Path PROJECT=Path('/home/smlflg/Projekte/CodexDashBoard') COMMAND='python -m compileall -q . && pytest -q' def run(cmd, timeout=60): try: p=subprocess.run(cmd, cwd=PROJECT, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout) return {'cmd':cmd,'exit_code':p.returncode,'stdout':p.stdout[-4000:],'stderr':p.stderr[-4000:]} except Exception as e: return {'cmd':cmd,'exit_code':124,'stdout':'','stderr':str(e)} def main(): checks=[]; failures=[]; warnings=[] if not PROJECT.exists(): failures.append('project path missing') if not (PROJECT/'.git').exists(): warnings.append('no .git marker') checks.append(run('git status --short', timeout=20)) # Main smoke command. Non-destructive; no install. checks.append(run(COMMAND, timeout=90)) status='passed' for c in checks: if c['exit_code'] not in (0,): status='needs_human' if 'not found' in (c.get('stderr','')+c.get('stdout','')).lower() else 'failed' failures.append(f"{c['cmd']} exit={c['exit_code']}") result={'status':status,'project_path':str(PROJECT),'verifier_kind':'python','checks':checks,'failures':failures,'warnings':warnings,'next_action':'If failed/needs_human, inspect stderr and decide dependency/test setup.'} print(json.dumps(result,indent=2)) raise SystemExit(0 if status=='passed' else 1) if __name__=='__main__': main()