def __init__(self, color=False, caching=False, reset=False, help=False): cmd.Cmd.__init__(self) self.color = color self.caching = caching self.reset = reset self.open_args = None self.fe = None self.repl = None self.tokenizer = Tokenizer() if platform.system() == 'Windows': self.use_rawinput = False if platform.system() == 'Darwin': self.reset = True self.__intro() self.__set_prompt_path() if help is False: self.do_help(None) print( "can input help ls or other command if you don't know how to use it." ) plist = self.all_serial() if len(plist) <= 0: print("serial not found!") else: for serial in plist: print("serial name :", serial[1], " : ", serial[0].split('/')[-1]) print("input ' open", plist[len(plist) - 1][0].split('/')[-1], "' and enter connect your board.")
def __init__(self, color=False, caching=False, reset=False): if color: colorama.init() cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout) else: cmd.Cmd.__init__(self) self.color = color self.caching = caching self.reset = reset self.open_args = None self.fe = None self.repl = None self.tokenizer = Tokenizer() if platform.system() == 'Windows': self.use_rawinput = False if platform.system() == 'Darwin': self.reset = True self.__intro() self.__set_prompt_path() self.do_help(None) print( colorama.Fore.YELLOW + "All support commands, can input help ls or other command if you don't know how to use it(ls)." ) self.view_all_serial()
def __init__(self, color=False, caching=False, reset=False, help=False): cmd.Cmd.__init__(self) self.color = color self.caching = caching self.reset = reset self.open_args = None self.fe = None self.repl = None self.tokenizer = Tokenizer() if platform.system() == 'Windows': self.use_rawinput = False if platform.system() == 'Darwin': self.reset = True self.__intro() self.__set_prompt_path() if help is False: self.do_help(None) print( "All support commands, can input help ls or other command if you don't know how to use it(ls)." ) self.view_all_serial()
def test_valid_strings(self): tests = [ ("simple1", [Token(Token.STR, "simple1")]), ( "simple1 simple2.txt", [Token(Token.STR, "simple1"), Token(Token.STR, "simple2.txt")], ), ('"Quoted"', [Token(Token.QSTR, "Quoted")]), ( '"Quoted with whitespace" non-quoted', [ Token(Token.QSTR, "Quoted with whitespace"), Token(Token.STR, "non-quoted"), ], ), ( '"$1+2 _3%2*1+2-2/#.py~" $1+2_3%2*1+2-2/#.py~', [ Token(Token.QSTR, "$1+2 _3%2*1+2-2/#.py~"), Token(Token.STR, "$1+2_3%2*1+2-2/#.py~"), ], ), ] t = Tokenizer() for string, exp_tokens in tests: tokens, rest = t.tokenize(string) assert rest == "" assert self.__cmp_tokens(exp_tokens, tokens)
def test_invalid_strings(self): tests = [ ("char ? is invalid", "? is invalid"), ('"char ? is invalid"', '"char ? is invalid"'), ('"unbalanced quotes', '"unbalanced quotes'), ('"valid quotes" valid "unbalanced quotes', '"unbalanced quotes'), ('unbalanced quotes"', '"'), ] t = Tokenizer() for string, exp_rest in tests: tokens, rest = t.tokenize(string) assert rest == exp_rest
def __init__(self, color=False, caching=False, reset=False): cmd.Cmd.__init__(self) self.color = color self.caching = caching self.reset = reset if self.color: colorama.init() self.fe = None self.repl = None self.tokenizer = Tokenizer() self.__intro() self.__set_prompt_path()
def __init__(self, color=False, caching=False, reset=False): """Creates Cmd-based shell object. Keyword arguments: color -- support colored text in the shell caching -- support caching the results of functions like 'ls' reset -- hard reset device via DTR. (serial connection only) """ if color: colorama.init() cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout) else: cmd.Cmd.__init__(self) self.emptyline = lambda: None if platform.system() == "Windows": self.use_rawinput = False self.color = color self.caching = caching self.reset = reset self.fe = None self.repl = None self.tokenizer = Tokenizer() self._intro() self._set_prompt_path() self.emptyline = lambda: None self.prompts = { "gps_uart_tx": ("GPS UART TX pin#: ", int), "gps_uart_rx": ("GPS UART RX pin#: ", int), "i2c_servo_scl": ("Servo SCL pin#: ", int), "i2c_servo_sda": ("Servo SDA pin#: ", int), "i2c_bno_scl": ("BNO055 SCL pin#: ", int), "i2c_bno_sda": ("BNO055 SDA pin#: ", int), "i2c_screen_scl": ("Screen SCL pin#: ", int), "i2c_screen_sda": ("Screen SDA pin#: ", int), "elevation_servo_index": ("Servo default elevation index: ", float), "azimuth_servo_index": ("Servo default azimuth index: ", float), "elevation_max_rate": ("Servo elevation max rate: ", float), "azimuth_max_rate": ("Servo azimuth max rate: ", float) }
def __init__(self, color=False, caching=False, reset=False): if color: colorama.init() cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout) else: cmd.Cmd.__init__(self) self.use_rawinput = False self.color = color self.caching = caching self.reset = reset self.fe = None self.repl = None self.tokenizer = Tokenizer() self.__intro() self.__set_prompt_path()
def __init__(self, color=False, caching=False, reset=False): if color: colorama.init() cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout) else: cmd.Cmd.__init__(self) self.emptyline = lambda: None if platform.system() == "Windows": self.use_rawinput = False self.color = color self.caching = caching self.reset = reset self.fe = None self.repl = None self.tokenizer = Tokenizer() self.__intro() self.__set_prompt_path() # Change prompts to be more descriptive self.prompts = { "gps_uart_tx": ("GPS UART TX pin#: ", int), "gps_uart_rx": ("GPS UART RX pin#: ", int), "i2c_servo_scl": ("Servo SCL pin#: ", int), "i2c_servo_sda": ("Servo SDA pin#: ", int), "i2c_bno_scl": ("BNO055 SCL pin#: ", int), "i2c_bno_sda": ("BNO055 SDA pin#: ", int), "i2c_screen_scl": ("Screen SCL pin#: ", int), "i2c_screen_sda": ("Screen SDA pin#: ", int), "elevation_servo_index": ("Servo default elevation index: ", float), "azimuth_servo_index": ("Servo default azimuth index: ", float), "elevation_max_rate": ("Servo elevation max rate: ", float), "azimuth_max_rate": ("Servo azimuth max rate: ", float) }