-
Notifications
You must be signed in to change notification settings - Fork 17
/
emu.py
executable file
·42 lines (35 loc) · 1.15 KB
/
emu.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
39
40
41
42
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
if __package__ is None:
import sys
from os import path
sys.path.append(path.abspath(path.join(path.dirname(__file__), 'py_utils')))
sys.path.append(path.abspath(path.join(path.dirname(__file__), 'commands')))
from py_utils.emu_utils import BaseFunctions
from py_utils.emu_utils import OPENPILOT_PATH
from commands import EMU_COMMANDS
sys.path.append(OPENPILOT_PATH) # for importlib
DEBUG = not path.exists('/data/params/d')
class Emu(BaseFunctions):
def __init__(self, args):
self.name = 'emu'
self.args = args
self.commands = {cmd.name: cmd for cmd in EMU_COMMANDS}
self.parse()
def parse(self):
cmd = self.next_arg()
if cmd is None:
self.print_commands(error_msg='You must specify a command for emu. Some options are:', ascii_art=True)
return
if cmd not in self.commands:
self.print_commands(error_msg='Unknown command! Try one of these:')
return
self.commands[cmd].main(self.args, cmd)
if __name__ == "__main__":
args = sys.argv[1:]
if DEBUG:
args = input().split(' ')
if '' in args:
args.remove('')
emu = Emu(args)