Files
cutdex/tool/windows/prepare_windows_sandbox.py
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

60 lines
3.0 KiB
Python

"""Create a Windows Sandbox launch file; no developer tools are mapped into it.
Inputs must contain fixture.mp4 (short SDR H.264 + AAC). Model folders are mapped
read-only; the vocals folder must contain melband.pt. Only results are writable.
"""
import argparse
import json
from pathlib import Path
import xml.etree.ElementTree as ET
def main():
parser = argparse.ArgumentParser(description=__doc__)
for name in ('app', 'smoke', 'inputs', 'whisper', 'translation', 'vocals', 'results', 'output'):
parser.add_argument('--' + name, type=Path, required=True)
args = parser.parse_args()
paths = {name: getattr(args, name).resolve() for name in
('app', 'smoke', 'inputs', 'whisper', 'translation', 'vocals', 'results')}
for name in ('app', 'smoke'):
if not (paths[name] / 'checksums.json').is_file():
raise ValueError(f'Not an audited package: {paths[name]}')
for name in ('inputs', 'whisper', 'translation', 'vocals'):
if not paths[name].is_dir():
raise ValueError(f'Missing directory: {paths[name]}')
if not (paths['inputs'] / 'fixture.mp4').is_file() or not (paths['vocals'] / 'melband.pt').is_file():
raise ValueError('Missing fixture.mp4 or vocals/melband.pt')
paths['results'].mkdir(parents=True, exist_ok=True)
config = ET.Element('Configuration')
ET.SubElement(config, 'VGpu').text = 'Enable'
ET.SubElement(config, 'MemoryInMB').text = '8192'
ET.SubElement(config, 'Networking').text = 'Disable'
folders = ET.SubElement(config, 'MappedFolders')
# Copy just the standalone guest script; never map the source/build tool tree.
script = Path(__file__).with_name('test_windows_release.ps1')
(paths['inputs'] / script.name).write_bytes(script.read_bytes())
mapping = {'app': r'C:\Cutdex', 'smoke': r'C:\Smoke', 'inputs': r'C:\Inputs',
'whisper': r'C:\Models\whisper', 'translation': r'C:\Models\translation',
'vocals': r'C:\Models\vocals', 'results': r'C:\Results'}
for name, guest in mapping.items():
folder = ET.SubElement(folders, 'MappedFolder')
ET.SubElement(folder, 'HostFolder').text = str(paths[name])
ET.SubElement(folder, 'SandboxFolder').text = guest
ET.SubElement(folder, 'ReadOnly').text = 'false' if name == 'results' else 'true'
(paths['inputs'] / 'models.json').write_text(json.dumps({
'whisper': mapping['whisper'],
'translation': mapping['translation'],
'vocals': mapping['vocals'] + r'\melband.pt',
}, indent=2), encoding='utf-8')
command = ET.SubElement(config, 'LogonCommand')
ET.SubElement(command, 'Command').text = (
'powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\\Inputs\\test_windows_release.ps1 '
'-App C:\\Cutdex -SmokeApp C:\\Smoke -Inputs C:\\Inputs -Results C:\\Results')
ET.indent(config)
args.output.write_text(ET.tostring(config, encoding='unicode') + '\n', encoding='utf-8')
print(f'Log into Windows, then open {args.output}. Results: {paths["results"]}')
if __name__ == '__main__':
main()