|
|
@ -60,7 +60,7 @@ def parse_time_table(timetable, available_commands=None): |
|
|
|
# remove empty lines |
|
|
|
# remove empty lines |
|
|
|
lines = (line for line in content_lines if line) |
|
|
|
lines = (line for line in content_lines if line) |
|
|
|
|
|
|
|
|
|
|
|
timed_commands =[] |
|
|
|
timed_commands = [] |
|
|
|
for line in lines: |
|
|
|
for line in lines: |
|
|
|
# split the lines into time and command |
|
|
|
# split the lines into time and command |
|
|
|
try: |
|
|
|
try: |
|
|
@ -175,6 +175,7 @@ def time_as_timedelta(time_object): |
|
|
|
microseconds=time_object.microsecond |
|
|
|
microseconds=time_object.microsecond |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_command(command, available_commands=None): |
|
|
|
def parse_command(command, available_commands=None): |
|
|
|
''' parses a string and checks if it is a valid command |
|
|
|
''' parses a string and checks if it is a valid command |
|
|
|
|
|
|
|
|
|
|
@ -306,7 +307,6 @@ class TimedCommands(object): |
|
|
|
port = port or find_arduino_port() |
|
|
|
port = port or find_arduino_port() |
|
|
|
self.serial = serial.Serial(port, baudrate, **serial_kwargs) |
|
|
|
self.serial = serial.Serial(port, baudrate, **serial_kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _ensure_command_dict(self, iterable): |
|
|
|
def _ensure_command_dict(self, iterable): |
|
|
|
''' ensures, that the available commands are a dictionary |
|
|
|
''' ensures, that the available commands are a dictionary |
|
|
|
|
|
|
|
|
|
|
@ -333,12 +333,10 @@ class TimedCommands(object): |
|
|
|
msg = 'available commands should be a list or dict of strings' |
|
|
|
msg = 'available commands should be a list or dict of strings' |
|
|
|
raise TypeError(msg) |
|
|
|
raise TypeError(msg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run(self): |
|
|
|
def run(self): |
|
|
|
''' run the scheduled commands ''' |
|
|
|
''' run the scheduled commands ''' |
|
|
|
run(self.commands, self.serial) |
|
|
|
run(self.commands, self.serial) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def close(self): |
|
|
|
def close(self): |
|
|
|
''' closes an open serial connection ''' |
|
|
|
''' closes an open serial connection ''' |
|
|
|
self.serial.close() |
|
|
|
self.serial.close() |
|
|
|