SF.net SVN: fclient: [378] trunk/sandbox/fcp2/consts.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-04-09 07:30:05
|
Revision: 378
http://fclient.svn.sourceforge.net/fclient/?rev=378&view=rev
Author: jUrner
Date: 2008-04-09 00:30:07 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
moved errors and loggers to consts for easier access
Modified Paths:
--------------
trunk/sandbox/fcp2/consts.py
Modified: trunk/sandbox/fcp2/consts.py
===================================================================
--- trunk/sandbox/fcp2/consts.py 2008-04-08 21:43:58 UTC (rev 377)
+++ trunk/sandbox/fcp2/consts.py 2008-04-09 07:30:07 UTC (rev 378)
@@ -3,6 +3,48 @@
"""Freennet Client Protocol consts and type mappings"""
import logging
+#*****************************************************************************
+# exceptions
+#*****************************************************************************
+class MessageParseError(Exception):
+ """Exception raised when a message could not be parsed succesfuly"""
+ def __init__(self, message, logMethod=None):
+ if logMethod is not None:
+ logMethod(self.__class__.__name__ + message)
+ Exception.__init__(self, message)
+
+
+class IOConnectFailedError(Exception):
+ """Exception raised if the object can not be connected"""
+ def __init__(self, message, logMethod=None):
+ if logMethod is not None:
+ logMethod(self.__class__.__name__ + message)
+ Exception.__init__(self, message)
+
+
+class IOClosedError(Exception):
+ """Exception raised if the object is closed"""
+ def __init__(self, message, logMethod=None):
+ if logMethod is not None:
+ logMethod(self.__class__.__name__ + message)
+ Exception.__init__(self, message)
+
+
+class IOBrokenError(Exception):
+ """Exception raised if the IO connection is broken"""
+ def __init__(self, message, logMethod=None):
+ if logMethod is not None:
+ logMethod(self.__class__.__name__ + message)
+ Exception.__init__(self, message)
+
+
+class IOTimeoutError(Exception):
+ """Exception raised when the io connection is closed"""
+ def __init__(self, message, logMethod=None):
+ if logMethod is not None:
+ logMethod(self.__class__.__name__ + message)
+ Exception.__init__(self, message)
+
#************************************************************************
#
#************************************************************************
@@ -238,27 +280,16 @@
Invalid = ''
TypesAll = (SSK, KSK, CHK, USK, SVK)
+
+class Logger:
+ """Package loggers"""
+ Fcp = logging.getLogger('Fcp')
+ Client = logging.getLogger('Fcp.Client')
+ Event = logging.getLogger('Fcp.Client.Event')
+ IOHandler =logging.getLogger('Fcp.Client.IOHandler')
+ IO =logging.getLogger('Fcp.Client.IOHandler.IO')
+ Message = logging.getLogger('Fcp.Client.Message')
-class LoggerNames:
- """Logger names used by the the package
-
- @cvar Fcp: root logger for the packsge
- @cvar Client: root logger for the client
- @cvar ClientEvents: logs events the client emits
- @cvar ClientMessages: logs messages the client sends and receives
- @cvar ClientRuntime: logs runtime information
-
- @cvar Config: logs config related information
- """
- Fcp = 'Fcp'
-
- Client = Fcp + '.Client'
- ClientEvents = Client + '.Events'
- ClientRuntime = Client + '.Runtime'
- Config = Fcp + '.Config'
-
- IOHandler = Fcp + '.IOHandler'
-
class LogMessages:
"""Strings used for log infos"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|