Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/netconify/cmdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def _tty_login(self):
host, port = re.split('[,:]', self._args.telnet)
tty_args['host'] = host
tty_args['port'] = port
tty_args['baud'] = self._args.baud
self.console = ('telnet', host, port)
self._tty = netconify.Telnet(**tty_args)
elif self._args.ssh is not None:
Expand Down
31 changes: 27 additions & 4 deletions lib/netconify/tty_telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, host, port, **kvargs):
self.host = host
self.port = port
self.timeout = kvargs.get('timeout', self.TIMEOUT)
self.baud = kvargs.get('baud', 9600)
self._tty_name = "{0}:{1}".format(host, port)

Terminal.__init__(self, **kvargs)
Expand Down Expand Up @@ -62,12 +63,34 @@ def _tty_close(self):
# -------------------------------------------------------------------------

def write(self, content):
""" write content + <ENTER> """
self._tn.write(content + '\n')
# If baud set to 0 write full speed
if (int(self.baud) == 0):
self._tn.write(content + '\n')
return None

# Write data according to defined baud
# per 8 bit of data there are 2 additional bits on the line
# (parity and stop bits)
for char in content:
self._tn.write(char)
wtime = 10/float(self.baud)
sleep(wtime) # do not remove
self._tn.write('\n')

def rawwrite(self, content):
""" write content as-is """
self._tn.write(content)
# If baud set to 0 write full speed
if (int(self.baud) == 0):
self._tn.write(content + '\n')
return None

# Write data according to defined baud
# per 1 byte of data there are 2 additional bits on the line
# (parity and stop bits)
for char in content:
self._tn.write(char)
wtime = 10/float(self.baud)
sleep(wtime) # do not remove
self._tn.write('\n’)

def read(self):
""" read a single line """
Expand Down