add documents
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
|
||||
root = pathlib.Path('C:/git/MagnetismHeroes').resolve()
|
||||
backup = root / 'artifacts/verification/VisualUpgrade/BeforeHorizonFix'
|
||||
assert backup.is_relative_to(root / 'artifacts/verification/VisualUpgrade')
|
||||
backup.mkdir(exist_ok=True)
|
||||
sources = [root / 'artifacts/verification/Final', root / 'artifacts/verification/VisualUpgrade/FinalProduct']
|
||||
paths = [path for source in sources for path in source.rglob('*') if path.is_file()]
|
||||
paths += [root / 'artifacts/android/Final/MagnetismHeroes.apk', root / 'artifacts/android/MagnetismHeroes.apk']
|
||||
sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
records = []
|
||||
for source in paths:
|
||||
target = backup / source.relative_to(root)
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
expected = sha(source)
|
||||
if target.exists():
|
||||
assert sha(target) == expected, target
|
||||
else:
|
||||
shutil.copy2(source, target)
|
||||
assert sha(target) == expected, target
|
||||
records.append({'source': source.relative_to(root).as_posix(), 'copy': target.relative_to(backup).as_posix(), 'bytes': source.stat().st_size, 'sha256': expected})
|
||||
result = {'status': 'PASS', 'preservedUtc': datetime.datetime.now(datetime.timezone.utc).isoformat(), 'productSourceCommit': '83182e7f3e86926bf130817d401a331829401fac', 'files': records}
|
||||
(backup / 'manifest.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
|
||||
print(json.dumps({'status': 'PASS', 'preservedFiles': len(records), 'preservedBytes': sum(item['bytes'] for item in records)}))
|
||||
Reference in New Issue
Block a user