-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (25 loc) · 883 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
import importlib
import toy_vm
import gui
import log
logger = log.logging.getLogger(__name__)
SWITCH_ARG_PREFIX = "--"
if __name__ == "__main__":
debug = False
if len(sys.argv) > 1 and sys.argv[1].startswith(SWITCH_ARG_PREFIX):
match arg_key := sys.argv.pop(1).split(SWITCH_ARG_PREFIX):
case _, "debug":
debug = True
log.init_logging(debug=debug)
logger.debug(sys.argv)
vm_instances = {
"toy_vm_default": toy_vm.instance_factory(),
}
if len(sys.argv) > 1:
for vm_module_name in sys.argv[1:]:
module = importlib.import_module(vm_module_name)
vm_instances[vm_module_name] = module.instance_factory()
logger.debug(f"Loaded VM instance from {vm_module_name=}")
gui_instance = gui.VirualMachineGUI(available_vms=vm_instances)
gui_instance.run()