Mercurial > xib
comparison irclib.py @ 146:229a59acde0f
fixes in irclib, needed because ServerConnection.socket can be a string since 42d7b622776196149c9a9a05da134a85ee9509c6
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sun, 17 Jan 2010 19:14:41 +0100 |
parents | e077dc9f14e5 |
children | 0aa31a2b9316 |
comparison
equal
deleted
inserted
replaced
145:ddc87b605019 | 146:229a59acde0f |
---|---|
239 This method should be called periodically to check and process | 239 This method should be called periodically to check and process |
240 incoming data, if there are any. If that seems boring, look | 240 incoming data, if there are any. If that seems boring, look |
241 at the process_forever method. | 241 at the process_forever method. |
242 """ | 242 """ |
243 sockets = map(lambda x: x._get_socket(), self.connections) | 243 sockets = map(lambda x: x._get_socket(), self.connections) |
244 sockets = filter(lambda x: x != None, sockets) | 244 sockets = filter(lambda x: x and not isinstance(x, basestring), sockets) |
245 if sockets: | 245 if sockets: |
246 (i, o, e) = select.select(sockets, [], [], timeout) | 246 (i, o, e) = select.select(sockets, [], [], timeout) |
247 self.process_data(i) | 247 self.process_data(i) |
248 else: | 248 else: |
249 time.sleep(timeout) | 249 time.sleep(timeout) |
903 def send_raw(self, string): | 903 def send_raw(self, string): |
904 """Send raw string to the server. | 904 """Send raw string to the server. |
905 | 905 |
906 The string will be padded with appropriate CR LF. | 906 The string will be padded with appropriate CR LF. |
907 """ | 907 """ |
908 if not self.socket or self.socket == 'closed': | 908 if not self.socket or isinstance(self.socket, basestring): |
909 raise ServerNotConnectedError, self | 909 raise ServerNotConnectedError, self |
910 try: | 910 try: |
911 if self.ssl: | 911 if self.ssl: |
912 self.ssl.write(string.encode('utf-8') + "\r\n") | 912 self.ssl.write(string.encode('utf-8') + "\r\n") |
913 elif self.socket and self.socket != 'closed': | 913 else: |
914 self.socket.send(string.encode('utf-8') + "\r\n") | 914 self.socket.send(string.encode('utf-8') + "\r\n") |
915 if DEBUG: | 915 if DEBUG: |
916 print "TO SERVER:", string | 916 print "TO SERVER:", string |
917 except socket.error, x: | 917 except socket.error, x: |
918 # Ouch! | 918 # Ouch! |