#!/usr/bin/env python3
"""Remove only the original classification source archive, keeping its raw dirs."""
import hashlib
import json
import subprocess
from pathlib import Path
root=Path(__file__).parent
archive=Path('/private/tmp/cdx-store-category9.rETOWM/source.tgz')
assert archive.is_file() and not archive.is_symlink()
record={'target':'classification local source.tgz','bytes':archive.stat().st_size,'sha256':hashlib.sha256(archive.read_bytes()).hexdigest()}
assert record['bytes']==1482797
archive.unlink()
record['remaining']=archive.exists()
record['protected_local_processes']=subprocess.check_output(['ps','-p','20770,43014','-o','pid=,stat=,comm='],text=True)
output=root/'cleanup-private-evidence/local-archive.json'
assert not output.exists()
output.write_text(json.dumps(record,ensure_ascii=False,indent=2)+'\n');output.chmod(0o600)
print(json.dumps(record,ensure_ascii=False))
