This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemulatorcli.py
38 lines (29 loc) · 1.63 KB
/
emulatorcli.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
34
35
36
37
38
import click, vexbrain, virtualdeviceserver, os, program
@click.group()
def cli(): pass
@click.command()
@click.option('-f','--file',required=False,help='(Full path required!) File to launch upon brain boot')
@click.option('-d','--disable-vds',required=False,help='Disable the virtual device server',is_flag=True)
@click.option('-p','--port',required=False,help='Port to use for the virtual device server',default=8080)
@click.option('-s','--host',required=False,help='Host to use for the virtual device server',default='localhost')
@click.option('-D','--disable-prgm-scan',required=False,help='Dont scan data/emulatedstorage/Internal/programs',is_flag=True)
def start(file, disable_vds, port, host, disable_prgm_scan):
brain = vexbrain.Brain()
if not disable_vds: vds = virtualdeviceserver.VirtualInterface((host, port), brain)
if not disable_prgm_scan:
for programFile in os.listdir('data/emulatedstorage/Internal/programs'):
brain.ProgramsLoaded.append(program.ProgramFile(f'data/emulatedstorage/Internal/programs/{programFile}'))
if brain.CodeEnviorment != None: brain.teardownProgram()
prgm = program.ProgramFile(file)
brain.ProgramsLoaded.append(prgm)
#Get the brain ready to run the program
brain.onProgramFolderScreen = False; brain.BrainScreen._drawProgramBar = True
brain.onProgramScreen = True; brain.onHomeScreen = False
brain.onDeviceScreen = False; brain.BrainScreen.clear_screen()
#Run the program
brain.CodeEnviorment = prgm.loadContainer(brain)
brain.CodeEnviorment.threadedExecute()
while True:
brain.tickmainloop()
cli.add_command(start)
cli()