docstrings inside moler.io.raw.terminal.Terminal
@@ -15,6 +15,8 @@ from moler.io.raw import TillDoneThread
class Terminal(IOConnection):
"""
Works on Unix (like Linux) systems only!
+
+ Terminal is shell working under Pty
"""
def __init__(self, moler_connection, cmd=['/bin/bash', '--norc', '--noprofile'], select_timeout=0.002,
@@ -32,7 +34,8 @@ class Terminal(IOConnection):
else:
self.prompt = re.compile(r'^bash-\d+\.*\d*')
- def open(self, ):
+ def open(self):
+ """Open Terminal connection & start thread pulling data from it."""
self._terminal = PtyProcessUnicode.spawn(self._cmd, dimensions=self.dimensions)
done = Event()
self.pulling_thread = TillDoneThread(target=self.pull_data,
@@ -40,7 +43,8 @@ class Terminal(IOConnection):
kwargs={'pulling_done': done})
self.pulling_thread.start()
- def close(self, ):
+ def close(self):
+ """Close Terminal connection & stop pulling thread."""
if self.pulling_thread:
self.pulling_thread.join()
self.pulling_thread = None
@@ -48,12 +52,18 @@ class Terminal(IOConnection):
self._terminal.close()
- def send(self, cmd, newline="\n"):
+ # TODO: newline should be attribute of __init__ since:
+ # 1) type of line ending is a nature of connection and not each write
+ # 2) command can't pass any other newline since it just calls:
+ # self.connection.send(self.command_string)
+ def send(self, cmd, newline="\n"): # TODO: cmd --> data
+ """Write data into Terminal connection."""
self._terminal.write(cmd)
if newline:
self._terminal.write(newline)
def pull_data(self, pulling_done):
+ """Pull data from Terminal connection."""
shell_operable = False
read_buffer = ""
