Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move all exceptions into lib (prelude to catching config)

  • Loading branch information...
commit 8661ae0c1631921a6b8078e02fb6c7331ae2a9fc 1 parent 9532a73
@richo richo authored
Showing with 34 additions and 25 deletions.
  1. +2 −16 ircSocket.py
  2. +24 −0 lib.py
  3. +2 −5 modules.d/000_core.py
  4. +6 −4 pyBawt.py
View
18 ircSocket.py
@@ -13,21 +13,7 @@
import auth
import logging
-class ModuleError(Exception):
- pass
-
-class IrcDisconnected(Exception):
- pass
-
-class IrcTerminated(Exception):
- pass
-class FlushQueue(Exception):
- """ Flush the event queue, don't wait for IO"""
- pass
-class ModulesDidntLoadDueToSyntax(Exception):
- def __nonzero__(self):
- # This allows us to retain the logical "if status" test.
- return False
+from lib import *
def should_reconnect():
"""This hook lies in here because it'll give the rest of the structure a fairly central place
@@ -542,7 +528,7 @@ def do_chores(self):
try:
# TODO - implement a signal stop
i.handle(msg)
- except bModules.StopHandling:
+ except StopHandling:
break
def SockConnect(host, port, use_ssl):
View
24 lib.py
@@ -15,3 +15,27 @@ def lower(n):
return n
def __contains__(self, value):
return self.lower(value) in map(self.lower, self)
+
+# Put all exceptions in lib.py
+
+class ModuleError(Exception):
+ pass
+
+class IrcDisconnected(Exception):
+ pass
+
+class IrcTerminated(Exception):
+ pass
+class FlushQueue(Exception):
+ """ Flush the event queue, don't wait for IO"""
+ pass
+class ModulesDidntLoadDueToSyntax(Exception):
+ def __nonzero__(self):
+ # This allows us to retain the logical "if status" test.
+ return False
+
+class Restart(Exception):
+ pass
+class StopHandling(Exception):
+ pass
+
View
7 modules.d/000_core.py
@@ -7,6 +7,8 @@
import sys
import logging
+from lib import *
+
VERSION="$Rev: 1252 $".split(" ")[1]
def get_help(mdl):
@@ -22,11 +24,6 @@ def get_help(mdl):
# CORE
#-----
-class Restart(Exception):
- pass
-class StopHandling(Exception):
- pass
-
class BawtM2(object):
"""I'm a lazy programmer who doesn't write help files"""
View
10 pyBawt.py
@@ -22,6 +22,8 @@
import logging
import traceback
+from lib import *
+
logging.info("pyBawt started")
# Have a crack at sweet argparsing
@@ -67,20 +69,20 @@ def restart_stub():
while True:
try:
net.recv_wait()
- except ircSocket.FlushQueue:
+ except FlushQueue:
pass
net.dump_queue()
except KeyboardInterrupt:
logging.error("Shutting down due to user intervention")
net.quit("Killed from terminal")
-except bModules.Restart:
+except Restart:
# TODO Include the user who did this
logging.error("Restarting due to user intervention")
restart_stub()
-except ircSocket.IrcDisconnected:
+except IrcDisconnected:
if ircSocket.should_reconnect():
restart_stub()
-except ircSocket.IrcTerminated:
+except IrcTerminated:
# Catch but don't handle, die gracefully
pass
except Exception:
Please sign in to comment.
Something went wrong with that request. Please try again.