Fixed visual bug
This commit is contained in:
@@ -163,7 +163,7 @@ class Pyboard(object):
|
||||
self.serial.write(b'\x04')
|
||||
return b'soft reboot\r\n'
|
||||
|
||||
def read_until(self, delimiter: bytes, stream_output: bool = False) -> Optional[bytes]:
|
||||
def read_until(self, delimiter: bytes, stream_output: bool = False, show_status: bool = False) -> Optional[bytes]:
|
||||
data = self.serial.read(1)
|
||||
|
||||
if stream_output:
|
||||
@@ -183,7 +183,7 @@ class Pyboard(object):
|
||||
if stream_output:
|
||||
self.stdout_write_bytes(stream_data)
|
||||
data = data[-max_len:]
|
||||
else:
|
||||
elif show_status:
|
||||
self.loading()
|
||||
else:
|
||||
timeout += 1
|
||||
@@ -216,7 +216,7 @@ class Pyboard(object):
|
||||
def __exit__(self, a, b, c):
|
||||
self.send_ctrl_b()
|
||||
|
||||
def __terminal(self, command: str, stream_output: bool = False, catch_output: bool = True) -> Optional[str]:
|
||||
def __terminal(self, command: str, stream_output: bool = False, show_status: bool = True) -> Optional[str]:
|
||||
command = textwrap.dedent(command)
|
||||
# send input
|
||||
if not isinstance(command, bytes):
|
||||
@@ -226,18 +226,17 @@ class Pyboard(object):
|
||||
raise Exception('Terminal: prompt has been lost')
|
||||
|
||||
for i in range(0, len(command), BUFFER_SIZE):
|
||||
if not stream_output:
|
||||
self.loading()
|
||||
|
||||
self.serial.write(command[i: min(i + BUFFER_SIZE, len(command))])
|
||||
time.sleep(0.001)
|
||||
|
||||
if not self.read_until(self.send_ok()):
|
||||
raise Exception('Terminal: could not execute command')
|
||||
|
||||
if not catch_output:
|
||||
return
|
||||
|
||||
# catch output
|
||||
data = self.read_until(b'\x04', stream_output=stream_output)
|
||||
data = self.read_until(b'\x04', stream_output=stream_output, show_status=show_status)
|
||||
|
||||
if not data:
|
||||
raise Exception('Terminal: timeout waiting for first EOF reception')
|
||||
@@ -502,10 +501,10 @@ class FileSystem(object):
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
def terminal(self, command: str, stream_output: bool = False) -> str:
|
||||
def terminal(self, command: str, stream_output: bool = False, show_status: bool = True) -> str:
|
||||
with self._pyboard as terminal:
|
||||
try:
|
||||
return terminal(command, stream_output=stream_output)
|
||||
return terminal(command, stream_output=stream_output, show_status=show_status)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
@@ -617,7 +616,7 @@ class Picowatch(object):
|
||||
filename = './' + filename
|
||||
|
||||
with open(filename, 'r') as fh:
|
||||
self._fs.terminal(fh.read(), stream_output=True)
|
||||
self._fs.terminal(fh.read(), stream_output=True, show_status=False)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user