Skip to content
Snippets Groups Projects
Commit 05338ec8 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Documentation added.

parent 973a67d9
No related branches found
No related tags found
No related merge requests found
"""Connect to a telnet server via the telnetlib.Telnet class.
"""
import telnetlib import telnetlib
import pcl_expect import pcl_expect
...@@ -8,6 +11,12 @@ __all__ = [ ...@@ -8,6 +11,12 @@ __all__ = [
class Telnet(pcl_expect.Expectable): class Telnet(pcl_expect.Expectable):
def __init__(self, host, port): def __init__(self, host, port):
"""Establish a telnet session.
The host and port argument are passed to telnetlib.Telnet.
"""
self.telnet = telnetlib.Telnet(host, port) self.telnet = telnetlib.Telnet(host, port)
pcl_expect.Expectable.__init__(self, self.telnet.fileno()) pcl_expect.Expectable.__init__(self, self.telnet.fileno())
...@@ -19,9 +28,11 @@ class Telnet(pcl_expect.Expectable): ...@@ -19,9 +28,11 @@ class Telnet(pcl_expect.Expectable):
return s, False return s, False
def send(self, s): def send(self, s):
"""Send a string to the remote telnet server."""
self.telnet.write(s) self.telnet.write(s)
def close(self): def close(self):
"""Close the telnet session."""
pcl_expect.Expectable.close(self) pcl_expect.Expectable.close(self)
self.telnet.close() self.telnet.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment