"""Prepare a separate QA scanner/update directory; keep existing QA and active scanners.""" from pathlib import Path import json, shutil ROOT=Path(__file__).resolve().parent.parent PRIVATE=ROOT/'storage/app/private/investmoz-v2/portal-audit' plan=json.loads((PRIVATE/'portal-stability-latest.json').read_text(encoding='utf-8')) source=Path(plan['source']);work=source/'antivirus-qa';work.mkdir(exist_ok=False) database=work/'database';shutil.copytree(PRIVATE/'clamav/database',database) binary=PRIVATE/'clamav/runtime/clamav-1.5.4.win.x64' assert (binary/'freshclam.exe').is_file() and (binary/'clamd.exe').is_file() (work/'freshclam.conf').write_text(f'''DatabaseDirectory "{database.as_posix()}" DatabaseMirror database.clamav.net UpdateLogFile "{(work/'freshclam.log').as_posix()}" MaxAttempts 1 ConnectTimeout 30 ReceiveTimeout 60 ''',encoding='utf-8') (work/'clamd.conf').write_text(f'''DatabaseDirectory "{database.as_posix()}" TCPAddr 127.0.0.1 TCPSocket 13310 LogFile "{(work/'clamd.log').as_posix()}" PidFile "{(work/'clamd.pid').as_posix()}" MaxScanSize 100M MaxFileSize 20M StreamMaxLength 25M Foreground yes ''',encoding='utf-8') plan['antivirus_QA']={'work':str(work),'binary':str(binary),'port':13310,'existing_scanners_unchanged':True, 'official_source':'https://docs.clamav.net/manual/Usage/SignatureManagement.html'} (PRIVATE/'portal-stability-latest.json').write_text(json.dumps(plan,ensure_ascii=False,indent=2),encoding='utf-8') print(json.dumps({'result':'isolated_scanner_prepared','port':13310,'existing_scanners_unchanged':True,'active_writes':0}))