Skip to content
Snippets Groups Projects
Commit 42aafbc1 authored by Eric S. Raymond's avatar Eric S. Raymond
Browse files

Improved debugging.

parent 228f4bda
No related branches found
No related tags found
No related merge requests found
...@@ -81,8 +81,6 @@ try: ...@@ -81,8 +81,6 @@ try:
except Exception: except Exception:
VERSION = () VERSION = ()
DEBUG = False
# TODO # TODO
# ---- # ----
# (maybe) thread safety # (maybe) thread safety
...@@ -581,8 +579,7 @@ class ServerConnection(Connection): ...@@ -581,8 +579,7 @@ class ServerConnection(Connection):
self.previous_buffer = lines.pop() self.previous_buffer = lines.pop()
for line in lines: for line in lines:
if DEBUG: self.irclibobj.debug(1, "FROM SERVER: %s" % repr(line))
print "FROM SERVER:", line
if not line: if not line:
continue continue
...@@ -643,16 +640,12 @@ class ServerConnection(Connection): ...@@ -643,16 +640,12 @@ class ServerConnection(Connection):
command = "ctcpreply" command = "ctcpreply"
m = list(m) m = list(m)
if DEBUG: self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, m))
print "command: %s, source: %s, target: %s, arguments: %s" % (
command, prefix, target, m)
self._handle_event(Event(command, prefix, target, m)) self._handle_event(Event(command, prefix, target, m))
if command == "ctcp" and m[0] == "ACTION": if command == "ctcp" and m[0] == "ACTION":
self._handle_event(Event("action", prefix, target, m[1:])) self._handle_event(Event("action", prefix, target, m[1:]))
else: else:
if DEBUG: self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, [m]))
print "command: %s, source: %s, target: %s, arguments: %s" % (
command, prefix, target, [m])
self._handle_event(Event(command, prefix, target, [m])) self._handle_event(Event(command, prefix, target, [m]))
else: else:
target = None target = None
...@@ -669,9 +662,7 @@ class ServerConnection(Connection): ...@@ -669,9 +662,7 @@ class ServerConnection(Connection):
if not is_channel(target): if not is_channel(target):
command = "umode" command = "umode"
if DEBUG: self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (command, prefix, target, m))
print "command: %s, source: %s, target: %s, arguments: %s" % (
command, prefix, target, arguments)
self._handle_event(Event(command, prefix, target, arguments)) self._handle_event(Event(command, prefix, target, arguments))
def _handle_event(self, event): def _handle_event(self, event):
...@@ -866,8 +857,7 @@ class ServerConnection(Connection): ...@@ -866,8 +857,7 @@ class ServerConnection(Connection):
self.ssl.write(string + "\r\n") self.ssl.write(string + "\r\n")
else: else:
self.socket.send(string + "\r\n") self.socket.send(string + "\r\n")
if DEBUG: self.irclibobj.debug(1, "TO SERVER: " + repr(string))
print "TO SERVER:", string
except socket.error: except socket.error:
# Ouch! # Ouch!
self.disconnect("Connection reset by peer.") self.disconnect("Connection reset by peer.")
...@@ -941,6 +931,7 @@ class DCCConnection(Connection): ...@@ -941,6 +931,7 @@ class DCCConnection(Connection):
""" """
def __init__(self, irclibobj, dcctype): def __init__(self, irclibobj, dcctype):
super(DCCConnection, self).__init__(irclibobj) super(DCCConnection, self).__init__(irclibobj)
self.irclibobj = irclibobj
self.connected = 0 self.connected = 0
self.passive = 0 self.passive = 0
self.dcctype = dcctype self.dcctype = dcctype
...@@ -1024,9 +1015,8 @@ class DCCConnection(Connection): ...@@ -1024,9 +1015,8 @@ class DCCConnection(Connection):
self.socket.close() self.socket.close()
self.socket = conn self.socket = conn
self.connected = 1 self.connected = 1
if DEBUG: self.irclibobj.debug(1, "DCC connection from %s:%d" % (
print "DCC connection from %s:%d" % ( self.peeraddress, self.peerport))
self.peeraddress, self.peerport)
self.irclibobj._handle_event( self.irclibobj._handle_event(
self, self,
Event("dcc_connect", self.peeraddress, None, None)) Event("dcc_connect", self.peeraddress, None, None))
...@@ -1062,12 +1052,10 @@ class DCCConnection(Connection): ...@@ -1062,12 +1052,10 @@ class DCCConnection(Connection):
prefix = self.peeraddress prefix = self.peeraddress
target = None target = None
for chunk in chunks: for chunk in chunks:
if DEBUG: self.irclibobj.debug(1, "FROM PEER: " + repr(chunk))
print "FROM PEER:", chunk
arguments = [chunk] arguments = [chunk]
if DEBUG: self.irclibobj.debug(1, "command: %s, source: %s, target: %s, arguments: %s" % (
print "command: %s, source: %s, target: %s, arguments: %s" % ( command, prefix, target, arguments))
command, prefix, target, arguments)
self.irclibobj._handle_event( self.irclibobj._handle_event(
self, self,
Event(command, prefix, target, arguments)) Event(command, prefix, target, arguments))
...@@ -1086,8 +1074,7 @@ class DCCConnection(Connection): ...@@ -1086,8 +1074,7 @@ class DCCConnection(Connection):
self.socket.send(string) self.socket.send(string)
if self.dcctype == "chat": if self.dcctype == "chat":
self.socket.send("\n") self.socket.send("\n")
if DEBUG: self.irclibobj.debug("TO PEER: %s\n" % repr(string))
print "TO PEER: %s\n" % string
except socket.error: except socket.error:
# Ouch! # Ouch!
self.disconnect("Connection reset by peer.") self.disconnect("Connection reset by peer.")
...@@ -1122,8 +1109,7 @@ class SimpleIRCClient(object): ...@@ -1122,8 +1109,7 @@ class SimpleIRCClient(object):
def _dispatcher(self, c, e): def _dispatcher(self, c, e):
"""[Internal]""" """[Internal]"""
if DEBUG: self.irclibobj.debug("dispatcher:%s" % e.eventtype())
print("irclib.py:_dispatcher:%s" % e.eventtype())
m = "on_" + e.eventtype() m = "on_" + e.eventtype()
if hasattr(self, m): if hasattr(self, m):
......
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