"""Versioned offline qualification artifact, not a runtime installer. Reuse an attested upstream Tool build's object files unchanged. Only the adapter entry point is compiled. The previous staging, packages and services are untouched. All inputs, link objects, outputs and checks are hashed in the private report. """ import argparse from datetime import datetime, timezone import hashlib import json import os from pathlib import Path import platform import re import subprocess import time import zipfile from engine_profile import load_profile, contract def digest(path): return hashlib.sha256(path.read_bytes()).hexdigest() def run(args): with zipfile.ZipFile(args.artifact) as bundle: profile = load_profile(bundle.read("engine-profile.json")) COMMIT = profile["upstream"]["commit"] UPSTREAM_SHA256 = profile["upstream"]["source_sha256"] release = platform.freedesktop_os_release() if os.geteuid() == 0 or (release.get("ID"), release.get("VERSION_ID"), platform.machine()) != ("ubuntu", "24.04", "x86_64"): raise RuntimeError("Unprivileged Ubuntu 24.04 amd64 required") group = Path("/sys/fs/cgroup") / Path("/proc/self/cgroup").read_text().strip().split("::", 1)[1].lstrip("/") limit = (group / "memory.max").read_text().strip() if limit == "max" or int(limit) > 3 * 1024**3: raise RuntimeError("A bounded user scope with MemoryMax <= 3G is required") previous = json.loads(args.upstream_report.read_text()) if previous.get("state") != "complete" or previous.get("source_sha256") != UPSTREAM_SHA256 or previous.get("source_commit") != COMMIT: raise RuntimeError("Unqualified upstream build") upstream = Path(previous["binary"]) if digest(upstream) != previous["binary_sha256"]: raise RuntimeError("Upstream binary changed") source = upstream.parents[2] if source.name != "vesc_tool-" + COMMIT: raise RuntimeError("Upstream source path mismatch") os.umask(0o077) root = args.output.resolve() root.mkdir(parents=True, mode=0o700, exist_ok=False) # Paths enter a generated makefile, never a shell command assembled from JSON. if any(not re.fullmatch(r"[A-Za-z0-9_./-]+", str(p)) for p in (root, source)): raise RuntimeError("Build paths must be make-safe") with zipfile.ZipFile(args.artifact) as bundle: for name in ("native_can_check.py", "native_broker_check.py", "native_samples_check.py", "qml_vesc_interface.h", "qml_broker.h", "qml_interactive.h", "sample_data.h", "qml_preview.cpp", "qml_sandbox.h", "qml_build.py", "bms-settings.xml", "native_extensions_check.py", "native_packages_check.py", "package_archive.py", "vesc_pkg_all.rcc", "offline_main.cpp", "config_export.h", "config_edit.h", "firmware_image.h", "firmware_source.h", "firmware_native.h", "swd_native.h", "tools_native.h", "bms_native.h", "custom_native.h", "code_native.h", "package_native.h", "engine_main.cpp", "native_bundle.py", "engine_profile.py", "engine_profile.h", "engine-profile.json"): (root / name).write_bytes(bundle.read(name)) report = {"schema": "missioncore.vesc.native-probe/v1", "state": "running", "started_at": datetime.now(timezone.utc).isoformat(), "monotonic_started": time.monotonic(), "source_commit": COMMIT, "artifact_sha256": digest(args.artifact), "upstream_report_sha256": digest(args.upstream_report), "adapter_sha256": digest(root / "offline_main.cpp"), "hardware_access": False, "runtime_installed": False, "system_packages_installed": False, "jobs": [], "checks": []} def publish(): (root / "report.json").write_text(json.dumps(report, indent=2) + "\n") staging = source.parents[1] qtbase = staging / "sysroot/usr" env = dict(os.environ, LC_ALL="C", QT_QPA_PLATFORM="offscreen", LD_LIBRARY_PATH=str(qtbase / "lib/x86_64-linux-gnu"), QT_PLUGIN_PATH=str(qtbase / "lib/x86_64-linux-gnu/qt5/plugins"), XDG_CONFIG_HOME=str(root / "config"), XDG_CACHE_HOME=str(root / "cache")) def execute(name, command, data=None, expected=0, timeout=60): start = time.monotonic() proc = subprocess.run(command, cwd=source, env=env, input=data, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout) (root / (name + ".stdout")).write_bytes(proc.stdout) (root / (name + ".stderr")).write_bytes(proc.stderr) report["jobs"].append({"id": name, "exit_code": proc.returncode, "duration_seconds": time.monotonic() - start, "stdout_sha256": hashlib.sha256(proc.stdout).hexdigest(), "stderr_sha256": hashlib.sha256(proc.stderr).hexdigest()}) publish() if proc.returncode != expected: raise RuntimeError("Native probe step failed: " + name) return proc.stdout try: makefile = (source / "Makefile").read_text().replace("\\\n", " ") match = re.search(r"^OBJECTS\s*=\s*(.+)$", makefile, re.MULTILINE) if not match: raise RuntimeError("Upstream link objects missing") objects = [source / name for name in match.group(1).split() if name != "build/lin/obj/main.o"] if not 100 < len(objects) < 1000 or any(not p.is_file() for p in objects): raise RuntimeError("Upstream object inventory incomplete") report["link_objects"] = [{"file": str(p.relative_to(source)), "sha256": digest(p)} for p in objects] report["upstream_makefile_sha256"] = digest(source / "Makefile") target = root / "mission-core-vesc-offline" wrapper = root / "Makefile.native" wrapper.write_text( "include " + str(source / "Makefile") + "\n" ".PHONY: mission-core-native-probe\n" "mission-core-native-probe:\n" "\t$(CXX) -c $(CXXFLAGS) $(INCPATH) -o " + str(root / "offline_main.o") + " " + str(root / "offline_main.cpp") + "\n" "\t$(LINK) $(LFLAGS) -o " + str(target) + " " + str(root / "offline_main.o") + " $(filter-out build/lin/obj/main.o,$(OBJECTS)) $(OBJCOMP) $(LIBS) -lz\n") execute("compile-link", ["/usr/bin/make", "-f", str(wrapper), "mission-core-native-probe"], timeout=180) report["binary_sha256"] = digest(target) for index, archive in enumerate(args.archives): raw = archive.read_bytes() native = json.loads(execute("archive-%d" % index, [str(target)], raw)) if not native["ok"] or not native["compatibility"]["legacy_power_loss_correction"]: raise RuntimeError("Upstream compatibility check failed") import base64 packet = base64.b64decode(native["compatibility"]["offline_detect_example_base64"]) if packet[:2] != bytes([58, 0]) or int.from_bytes(packet[2:6], "big", signed=True) != 50000: raise RuntimeError("Expected native 5.02 detect correction was not applied") rpm_packets = [base64.b64decode(p) for p in native["offline_signed_rpm_examples_base64"]] if (len(rpm_packets) != 2 or any(len(p) != 5 or p[0] != 8 for p in rpm_packets) or [int.from_bytes(p[1:], "big", signed=True) for p in rpm_packets] != [3000, -3000]): raise RuntimeError("Upstream signed RPM serialization mismatch") report["checks"].append({"id": "signed-rpm-serialization-%d" % index, "ok": True}) report["checks"].append({"id": "native-archive-%d" % index, "ok": True, "archive_sha256": hashlib.sha256(raw).hexdigest(), "motor_parameter_count": len(native["motor"]["parameters"]), "application_parameter_count": len(native["application"]["parameters"]), "binary_round_trip_exact": True, "xml_equivalent_by_upstream_comparison": True, "xml_binary_exact": all(native[k]["xml_round_trip_exact"] for k in ("motor", "application")), "legacy_power_loss_correction": True}) # Exercise the same native preparation used online, without any transport. edits = [ ("typed", {"changes": {"l_current_max": 20.0}}, 0), ("restore", {"payload": json.loads(raw)["configs"]["motor"]["payload"]}, 0), ("xml", {"xml": native["motor"]["xml"]}, 0), ("unknown-field", {"changes": {"not_a_parameter": 1}}, 1), ("outside-range", {"changes": {"l_current_max": 1e12}}, 1), ("wrong-type", {"changes": {"l_current_max": "20"}}, 1), ("bad-enum", {"changes": {"motor_type": 500}}, 1), ("xml-unknown", {"xml": "1"}, 1), ("xml-metadata", {"xml": "Changed"}, 1), ("xml-nan", {"xml": "NaN"}, 1), ("xml-duplicate", {"xml": "2030"}, 1), ("xml-entity", {"xml": ']>&x;'}, 1), ] for label, source_edit, expected in edits: value = json.loads(raw); value["edit"] = {"kind": "motor", "source": source_edit} edited = json.loads(execute("edit-%s-%d" % (label, index), [str(target)], json.dumps(value).encode(), expected=expected)) if edited.get("ok") != (expected == 0) or edited.get("hardware_access"): raise RuntimeError("Native edit qualification mismatch") if label == "typed" and not any(p["name"] == "l_current_max" and p["after"] == 20 for p in edited["edit"]["changes"]): raise RuntimeError("Native edit did not preserve requested value") if label == "restore" and edited["edit"]["changes"]: raise RuntimeError("Restoring the identical backup changed parameters") report["checks"].append({"id": "edit-%s-%d" % (label, index), "ok": True}) # Test exactly the file inspector used by the USB owner, but with # synthetic vectors and no transport or firmware upload. image = bytes.fromhex("0000022001010008") + bytes(1016) for label, data, kind, expected in ( ("raw",image,"firmware",0), ("bootloader",image,"bootloader",0), ("short",image[:100],"firmware",1), ("stack",bytes(1024),"firmware",1), ("reset",image[:4]+bytes(4)+image[8:],"firmware",1), ("large-bootloader",image+bytes(65536),"bootloader",1), ("kind",image,"other",1)): value = json.loads(raw) value["firmware_image"] = {"data":base64.b64encode(data).decode(),"kind":kind} inspected = json.loads(execute("image-%s-%d" % (label,index),[str(target)],json.dumps(value).encode(),expected=expected)) if inspected.get("ok") != (expected == 0) or inspected.get("hardware_access"): raise RuntimeError("Firmware image inspection qualification failed") if expected == 0 and inspected["firmware_image"]["sha256"] != hashlib.sha256(data).hexdigest(): raise RuntimeError("Firmware image digest changed") # Original HexFile normalization behind strict container/address bounds. def hexline(address, kind, data=b''): record=bytes([len(data),address>>8,address&255,kind])+data return b':'+(record+bytes([-sum(record)&255])).hex().upper().encode()+b'\n' def ihex(data, base=0x08000000): return hexline(0,4,(base>>16).to_bytes(2,'big'))+b''.join(hexline(i,0,data[i:i+16]) for i in range(0,len(data),16))+hexline(0,1) valid=ihex(image) gap=hexline(0,4,b'\x08\x00')+hexline(0,0,image[:16])+hexline(1008,0,image[-16:])+hexline(0,1) reordered=hexline(0,4,b'\x08\x00')+hexline(1008,0,image[-16:])+hexline(0,0,image[:16])+hexline(0,1) duplicate=valid.replace(hexline(0,1),hexline(0,0,image[:16])+hexline(0,1)) for label,data,kind,expected in [ ('valid',valid,'firmware',0),('crlf',valid.replace(b'\n',b'\r\n'),'firmware',0), ('gap',gap,'firmware',0),('reordered',reordered,'firmware',0), ('checksum',valid.replace(b':020000040800F2',b':020000040800F3'),'firmware',1), ('junk',valid.replace(b':10',b':1G',1),'firmware',1),('overlap',duplicate,'firmware',1), ('truncated',valid.replace(hexline(0,1),b''),'firmware',1), ('trailing',valid+hexline(16,0,image[16:32]),'firmware',1), ('wrong-base',ihex(image,0x08010000),'firmware',1), ('sparse',valid.replace(hexline(0,1),hexline(0,4,b'\x09\x00')+hexline(0,0,image[:16])+hexline(0,1)),'firmware',1), ('bootloader-address',valid,'bootloader',1)]: value=json.loads(raw);value['firmware_image']={'data':base64.b64encode(data).decode(),'kind':kind,'format':'hex'} inspected=json.loads(execute('hex-%s-%d'%(label,index),[str(target)],json.dumps(value).encode(),expected=expected)) if inspected.get('ok')!=(expected==0):raise RuntimeError('HEX admission failed: '+label) if expected==0: actual=inspected['firmware_image'] normalized=image if label in ('valid','crlf') else image[:16]+b'\xff'*992+image[-16:] if actual['source_sha256']!=hashlib.sha256(data).hexdigest() or actual['sha256']!=hashlib.sha256(normalized).hexdigest(): raise RuntimeError('HEX normalized bytes differ') # Original Commands serialization, disconnected from every transport. for action,suffix in [('charge_enable','6101'),('charge_disable','6100'),('balance_enable','6401'),('balance_disable','6400'),('reset_ah','630100'),('reset_wh','630001'),('zero_current','65')]: for can_id in (0,253): value=json.loads(raw);value['bms_command']={'can_id':can_id,'command':action} checked=json.loads(execute('bms-%s-%d-%d'%(action,can_id,index),[str(target)],json.dumps(value).encode())) # COMM_FORWARD_CAN(34), exact target, upstream typed command. if checked['bms_command']['packet_hex']!='22'+format(can_id,'02x')+suffix: raise RuntimeError('Unexpected BMS CAN command serialization') for can_id,command in [(255,'charge_enable'),(-1,'charge_enable'),(1,'motor_run'),(1.5,'reset_ah')]: value=json.loads(raw);value['bms_command']={'can_id':can_id,'command':command} execute('bms-reject-%s-%s-%d'%(can_id,command,index),[str(target)],json.dumps(value).encode(),expected=1) report['checks'].append({'id':'bms-unicast-serialization-%d'%index,'ok':True,'hardware_access':False}) for name, target_spec, expected in ( ("stm32",{'target_code':1,'pins':'default','address':0x08000000,'flash_bytes':131072},0), ("nrf",{'target_code':8,'pins':'nrf5x','address':0,'flash_bytes':1048576},0), ("uicr",{'target_code':8,'pins':'nrf5x','address':0x10001000,'flash_bytes':1024},1), ("short-range",{'target_code':1,'pins':'default','address':0x08000000,'flash_bytes':256},1), ("family",{'target_code':99,'pins':'default','address':0,'flash_bytes':1024},1)): candidate=json.loads(raw);candidate['swd_image']={'target':target_spec,'data':base64.b64encode(image).decode()} result=json.loads(execute(f'swd-{name}-{index}',[str(target)],json.dumps(candidate).encode(),expected=expected)) if result['ok']!=(expected==0) or result['hardware_access']:raise RuntimeError('SWD image boundary failed') report['checks'].append({'id':f'swd-{name}-{index}','ok':True}) candidate=json.loads(raw);candidate['can_route']=7 result=json.loads(execute(f'can-route-{index}',[str(target)],json.dumps(candidate).encode())) if not result.get('can_route') or result['hardware_access']:raise RuntimeError('CAN route qualification failed') report['checks'].append({'id':f'can-route-{index}','ok':True}) # Fail closed on archive corruption and unsupported firmware instead # of silently presenting the bundled defaults as actual settings. original = json.loads(raw) damaged = json.loads(raw); damaged["configs"]["motor"]["sha256"] = "0" * 64 unknown = json.loads(raw); unknown["identity"]["major"] = 99 wrong_signature = json.loads(raw) payload = bytearray(base64.b64decode(original["configs"]["motor"]["payload"])); payload[1] ^= 1 wrong_signature["configs"]["motor"]["payload"] = base64.b64encode(payload).decode() wrong_signature["configs"]["motor"]["sha256"] = hashlib.sha256(payload).hexdigest() truncated = json.loads(raw) payload = base64.b64decode(original["configs"]["motor"]["payload"])[:-1] truncated["configs"]["motor"].update(payload=base64.b64encode(payload).decode(), sha256=hashlib.sha256(payload).hexdigest(), bytes=len(payload)) for name, value in (("corrupt", damaged), ("unsupported", unknown), ("signature", wrong_signature), ("truncated", truncated)): rejected = json.loads(execute("%s-%d" % (name, index), [str(target)], json.dumps(value).encode(), expected=1)) if rejected["ok"] or rejected["hardware_access"]: raise RuntimeError("Invalid archive was not rejected") report["checks"].append({"id": "%s-%d" % (name, index), "ok": True}) from native_packages_check import check_packages from native_extensions_check import check_extensions check_extensions(execute,target,raw,root,report) check_packages(execute,target,raw,root,report) for item in report["link_objects"]: if digest(source / item["file"]) != item["sha256"]: raise RuntimeError("Upstream objects were modified") engine = root / "mission-core-vesc-engine" wrapper.write_text(wrapper.read_text() + "\n.PHONY: mission-core-native-engine\nmission-core-native-engine:\n" "\t$(CXX) -c $(CXXFLAGS) $(INCPATH) -o " + str(root / "engine_main.o") + " " + str(root / "engine_main.cpp") + "\n" "\t$(LINK) $(LFLAGS) -o " + str(engine) + " " + str(root / "engine_main.o") + " $(filter-out build/lin/obj/main.o,$(OBJECTS)) $(OBJCOMP) $(LIBS) -lz\n") execute("engine-compile", ["/usr/bin/make", "-f", str(wrapper), "mission-core-native-engine"], timeout=180) requests = [{"id": 1, "method": "engine"}, {"id": 2, "method": "current", "current_a": 30}, {"id": 3, "method": "hall_start", "current_a": 5}, {"id": 4, "method": "arbitrary_packet"}, { "id": 5, "method": "duty", "duty": .5}, {"id": 6, "method": "configuration_preview"}, {"id": 7, "method": "configuration_apply"}] requests += [{"id":100+i,"method":method} for i,method in enumerate(profile["methods"]) if method.startswith("sample_") or method.startswith("firmware_") or method == "device_tool" or method.startswith("custom_") or (method.startswith("code_") and method != "code_pack")] responses = [json.loads(line) for line in execute("engine-offline", [str(engine), "--offline"], b"".join(json.dumps(r).encode()+b"\n" for r in requests)).splitlines()] if (len(responses) != len(requests) + 1 or not responses[0]["ready"] or not responses[1]["ok"] or any(r["ok"] for r in responses[2:]) or responses[1]["result"]["hardware_enabled"]): raise RuntimeError("Native engine offline boundary failed") if responses[1]["result"].get("contract") != contract(profile): raise RuntimeError("Native adapter contract differs from release profile") can_check = json.loads(execute("engine-can-synthetic", ["/usr/bin/python3", str(root / "native_can_check.py"), str(engine), str(args.archives[0])])) if can_check.get("ok") is not True: raise RuntimeError("Native CAN loopback check failed") report["checks"].append({"id": "engine-can-synthetic", "ok": True, "hardware_access": False}) report["engine_contract"] = contract(profile) report["checks"].append({"id": "engine-offline-denies-hardware", "ok": True}) from native_samples_check import samples, interactive samples(execute,target,json.loads(args.archives[0].read_bytes()),report) from qml_build import dependencies qmlroot = dependencies(root, execute, args.qml_dependency_cache) renderer = root / "mission-core-vesc-qml-preview" wrapper.write_text(wrapper.read_text() + "\n.PHONY: mission-core-qml-preview\nmission-core-qml-preview:\n" "\t" + str(qtbase / "lib/qt5/bin/moc") + " $(DEFINES) $(INCPATH) " + str(root / "qml_vesc_interface.h") + " -o " + str(root / "qml_vesc_interface.moc") + "\n" "\t$(CXX) -c $(CXXFLAGS) $(INCPATH) -o " + str(root / "qml_preview.o") + " " + str(root / "qml_preview.cpp") + "\n" "\t$(LINK) $(LFLAGS) -o " + str(renderer) + " " + str(root / "qml_preview.o") + " $(filter-out build/lin/obj/main.o,$(OBJECTS)) $(OBJCOMP) $(LIBS) -lz\n") execute("qml-compile", ["/usr/bin/make", "-f", str(wrapper), "mission-core-qml-preview"], timeout=180) execute("runtime-bundle", ["/usr/bin/python3", str(root / "native_bundle.py"), "--qml-sysroot", str(qmlroot), "--engine", str(engine), "--sysroot", str(staging / "sysroot"), "--source", str(source), "--output", str(root / "runtime")], timeout=180) payload = root / "runtime/payload" qenv = dict(env, LD_LIBRARY_PATH=str(payload / "lib"), QT_PLUGIN_PATH=str(payload / "plugins")) interactive(payload / "bin/mission-core-vesc-qml-preview", qenv, report, root) from native_broker_check import broker broker(payload / "bin/mission-core-vesc-qml-preview", qenv, json.loads(args.archives[0].read_bytes()), report) candidate = json.loads(args.archives[0].read_bytes()) candidate.update(width=640,height=480,values=base64.b64encode(bytes([4])+bytes(95)).decode()) for label, text, expected in ( ("fill-viewport", 'import QtQuick 2.5; Rectangle { anchors.fill: parent; color: "#112233"; Rectangle { anchors.right: parent.right; anchors.bottom: parent.bottom; width: 40; height: 40; color: "#c0ffee" } }', True), ("controls", 'import QtQuick 2.5; import QtQuick.Controls 2.2; Rectangle { color: "#112233"; Label { text: "Snapshot verified"; anchors.centerIn: parent } }', True), ("motor-command-is-discarded", 'import QtQuick 2.5; Rectangle { Component.onCompleted: VescIf.commands().setRpm(999); color: "#123456" }', True), ("syntax-error", 'import QtQuick 2.5; BROKEN {', False)): candidate['source'] = text checked = subprocess.run([str(payload/'bin/mission-core-vesc-qml-preview')], input=json.dumps(candidate).encode(),env=qenv,capture_output=True,timeout=8) (root/('qml-'+label+'.stdout')).write_bytes(checked.stdout) (root/('qml-'+label+'.stderr')).write_bytes(checked.stderr) result = json.loads(checked.stdout) if result.get('ok') != expected or result.get('hardware_access') is not False or result.get('sandbox_verified') is not True: raise RuntimeError('QML qualification failed: '+label+' '+str(result)) if label == "fill-viewport" and (result.get("root_width"), result.get("root_height")) != (640,480): raise RuntimeError("Anchored QML root does not fill the viewport") if expected and (not base64.b64decode(result['png']).startswith(b'\x89PNG\r\n\x1a\n') or (result['width'], result['height']) != (640,480)): raise RuntimeError('Invalid rendered QML frame') if label=='motor-command-is-discarded' and result['discarded_commands']<1:raise RuntimeError('QML command was not observed/discarded') report['checks'].append({'id':'qml-'+label,'ok':True,'hardware_access':False}) for label, file in (("LogUI", "pkg-official-1.stdout"), ("VL-ABI-Encoder-Config", "pkg-official-38.stdout")): pkg = json.loads((root/file).read_text())['package'] candidate['source'] = pkg['qml_source'] checked = subprocess.run([str(payload/'bin/mission-core-vesc-qml-preview')], input=json.dumps(candidate).encode(),env=qenv,capture_output=True,timeout=8) (root/('qml-official-'+label+'.stdout')).write_bytes(checked.stdout) result = json.loads(checked.stdout) if not result.get('ok') or result.get('hardware_access') is not False or not result.get('sandbox_verified'): raise RuntimeError('Official QML preview failed: '+label+' '+str(result)) if label == 'LogUI': from qml_build import bright_pixels if bright_pixels(base64.b64decode(result['png']), (10, 200, 124, 295)) < 100: raise RuntimeError('Original LogUI left labels are absent from the rendered image') report['checks'].append({'id':'qml-official-'+label,'ok':True,'source_sha256':result['source_sha256'],'warnings':result['warnings'],'hardware_access':False}) candidate['source'] = 'import QtQuick 2.5; Item { Component.onCompleted: {while(true){}} }' checked = subprocess.run([str(payload/'bin/mission-core-vesc-qml-preview')], input=json.dumps(candidate).encode(),env=qenv,capture_output=True,timeout=6) if checked.returncode != -9:raise RuntimeError('Infinite QML did not stop at CPU limit') report['checks'].append({'id':'qml-infinite-loop-terminated','ok':True,'hardware_access':False}) report["native_runtime"] = json.loads((root / "runtime/bundle.json").read_text()) report.update(state="complete", binary=str(target), upstream_objects_unchanged=True) except Exception as error: report.update(state="error", error=str(error)) raise finally: report["finished_at"] = datetime.now(timezone.utc).isoformat() report["duration_seconds"] = time.monotonic() - report["monotonic_started"] publish() def main(): parser = argparse.ArgumentParser() parser.add_argument("--artifact", type=Path, required=True) parser.add_argument("--upstream-report", type=Path, required=True) parser.add_argument("--output", type=Path, required=True) parser.add_argument("--qml-dependency-cache", type=Path) parser.add_argument("--archives", type=Path, nargs="+", required=True) run(parser.parse_args()) if __name__ == "__main__": main()