42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""Real application close while one disposable metadata boundary is held."""
|
|
from pathlib import Path
|
|
import sys,time
|
|
|
|
from PySide6.QtCore import QTimer
|
|
from PySide6.QtWidgets import QApplication
|
|
from cbb_refresh_verify import scoped_manifest as manifest
|
|
from cbb_refresh_verify.operation_queue import check_active
|
|
from cbb_refresh_verify.ui.main_window import MainWindow
|
|
|
|
root=Path(sys.argv[1]);mode=sys.argv[2]
|
|
source=root/'source';source.mkdir()
|
|
(source/('one.log' if mode=='copy' else 'one.dat')).write_bytes(b'isolated fixture')
|
|
def held():
|
|
(root/'entered').touch()
|
|
while not (root/'release').exists():time.sleep(.02)
|
|
def hash_file(path):
|
|
held()
|
|
return manifest.hash_file(path)
|
|
if mode=='copy':
|
|
original=manifest.shutil.copy2
|
|
def copy_file(*args,**kwargs):
|
|
held()
|
|
return original(*args,**kwargs)
|
|
manifest.shutil.copy2=copy_file
|
|
def action():
|
|
if mode=='hash':manifest.build_manifest(source,hash_function=hash_file)
|
|
else:manifest.copy_verified(source,root/'partial-copy',hash_function=hash_file)
|
|
check_active()
|
|
(root/'late-dispatch').touch()
|
|
app=QApplication([])
|
|
window=MainWindow(reader=lambda _:None,data_root=root/'data');window.show()
|
|
job=window._new_job('management',library=root/'library.lmc')
|
|
window._start(action,lambda _:None,queued=False,job=job)
|
|
def close_when_entered():
|
|
if (root/'entered').exists():window.close()
|
|
else:QTimer.singleShot(20,close_when_entered)
|
|
QTimer.singleShot(20,close_when_entered)
|
|
code=app.exec()
|
|
(root/'main-returning').touch()
|
|
raise SystemExit(code)
|