Skip to content

Commit 69d333f

Browse files
committed
Rename read func
1 parent 0bc10b7 commit 69d333f

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

adafruit_shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def run_command(self, cmd, suppress_message=False, return_output=False):
6969
"""
7070
Run a shell command and show the output as it runs
7171
"""
72-
def non_block_read(output):
72+
def read_stream(output):
7373
fd = output.fileno()
7474
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
7575
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
@@ -87,10 +87,10 @@ def non_block_read(output):
8787
universal_newlines=True
8888
) as proc:
8989
while proc.poll() is None:
90-
err = non_block_read(proc.stderr)
90+
err = read_stream(proc.stderr)
9191
if err != "" and not suppress_message:
9292
self.error(err.strip(), end="\n\r")
93-
output = non_block_read(proc.stdout)
93+
output = read_stream(proc.stdout)
9494
if output != "" and not suppress_message:
9595
self.info(output.strip(), end="\n\r")
9696
full_output += output

test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
try:
2+
from adafruit_shell import Shell
3+
except ImportError:
4+
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
5+
6+
shell = Shell()
7+
shell.group="Blinka"
8+
9+
def main():
10+
#shell.clear()
11+
print("Running test")
12+
shell.run_command("./test.sh")
13+
14+
# Main function
15+
if __name__ == "__main__":
16+
main()

test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /bin/bash
2+
>&2 echo This should go to stderr
3+
echo Interactive Test
4+
>&2 echo This should also go to stderr
5+
read -p "Hello, who am I speaking to? " NAME
6+
echo It\'s Nice to meet you $NAME
7+

0 commit comments

Comments
 (0)