Refactored codes
This commit is contained in:
@@ -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, show_status: bool = True) -> Optional[str]:
|
||||
def __terminal(self, command: str, stream_output: bool = False) -> Optional[str]:
|
||||
command = textwrap.dedent(command)
|
||||
# send input
|
||||
if not isinstance(command, bytes):
|
||||
@@ -236,7 +236,7 @@ class Pyboard(object):
|
||||
raise Exception('Terminal: could not execute command')
|
||||
|
||||
# catch output
|
||||
data = self.read_until(b'\x04', stream_output=stream_output, show_status=show_status)
|
||||
data = self.read_until(b'\x04', stream_output=stream_output, show_status=not stream_output)
|
||||
|
||||
if not data:
|
||||
raise Exception('Terminal: timeout waiting for first EOF reception')
|
||||
@@ -501,10 +501,10 @@ class FileSystem(object):
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
def terminal(self, command: str, stream_output: bool = False, show_status: bool = True) -> str:
|
||||
def terminal(self, command: str, stream_output: bool = False) -> str:
|
||||
with self._pyboard as terminal:
|
||||
try:
|
||||
return terminal(command, stream_output=stream_output, show_status=show_status)
|
||||
return terminal(command, stream_output=stream_output)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
@@ -616,7 +616,7 @@ class Picowatch(object):
|
||||
filename = './' + filename
|
||||
|
||||
with open(filename, 'r') as fh:
|
||||
self._fs.terminal(fh.read(), stream_output=True, show_status=False)
|
||||
self._fs.terminal(fh.read(), stream_output=True)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user