tehmaze/cli — pull request #1 by kokke (2014-05-28 21:51:53+00:00)
Title: Update __init__.py

Added guard: "# TCP sockets don't have a flush method"

This is a fix for an Exception I got when trying to bind the cli to a TCP socket, using your example code in the readme. I am running Linux 3.2.0 on a Debian-type distro FWIW. Below is the traceback of the Exception this change fixes:

AttributeError Traceback (most recent call last)
in ()
6 s.listen(1)
7 c, a = s.accept()
----> 8 cli = CLI(c)
9 while True:
10 cli.read()

/tmp/cli/__init__.pyc in __init__(self, socket, name, prompt)
89 self.errors = []
90 self.is_running = True
---> 91 self.send(self.prompt)
92
93 @property

/tmp/cli/__init__.pyc in send(self, data)
116 data = '\r\n'.join(RE_NEWLINE.split(data))
117 self.socket.send(data)
--> 118 if hasattr(self.socket, "flush"):
119 self.socket.flush()
120

AttributeError: '_socketobject' object has no attribute 'flush'