29 lines
1.8 KiB
Python
29 lines
1.8 KiB
Python
from pathlib import Path
|
|
import json,hashlib,shutil,subprocess
|
|
root=Path(__file__).resolve().parents[2];out=Path(__file__).resolve().parent
|
|
private=Path('C:/Users/macbook/.config/investmoz/negocios-classificacao-QA-20261016');qa=private/'source'
|
|
plan=json.loads((root/'outputs/investmoz-negocios-classificacao-mapa-20261016/FONTES-E-DELTA-PREVISTO.json').read_text('utf-8'))
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe'
|
|
def run(script):
|
|
p=subprocess.run([php,str(out/script)],cwd=root,capture_output=True);(private/(script+'.log')).write_bytes(p.stdout+p.stderr)
|
|
# Laravel's console handler can emit an error while returning zero; require expected artifacts below too.
|
|
assert p.returncode==0,'Probe failed: '+script
|
|
run('compatibility-prepare.php');assert (private/'compatibility-before.json').exists()
|
|
backup=private/'candidate-for-reversal';assert not backup.exists();backup.mkdir()
|
|
paths=[s['path'] for s in plan['planned_replacements']+plan['planned_new_sources']]
|
|
hashes={n:sha(qa/n) for n in paths}
|
|
for n in paths:
|
|
p=backup/n;p.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(qa/n,p)
|
|
base=qa.resolve()
|
|
try:
|
|
for s in plan['planned_replacements']:
|
|
n=s['path'];assert sha(root/n)==s['observed_sha256'];shutil.copy2(root/n,qa/n)
|
|
for s in plan['planned_new_sources']:
|
|
p=qa/s['path'];assert p.resolve().is_relative_to(base) and sha(p)==hashes[s['path']];p.unlink()
|
|
run('compatibility-old-save.php');assert (private/'compatibility-old-save.json').exists(),'Inspect private old-save log'
|
|
finally:
|
|
for n in paths:shutil.copy2(backup/n,qa/n);assert sha(qa/n)==hashes[n]
|
|
run('compatibility-recover.php');assert (out/'REVERSAO-APOS-EDICAO-ANTERIOR.json').exists()
|
|
print('Actual previous code installed in private QA, content edit succeeded, candidate restored and classification recovered intact')
|