SF.net SVN: fclient: [459] trunk/fcp2/src/fcp2/iohandler.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-01 11:27:20
|
Revision: 459
http://fclient.svn.sourceforge.net/fclient/?rev=459&view=rev
Author: jUrner
Date: 2008-07-01 04:27:28 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
for ease of use, all necessary symbols are now imported to main
Modified Paths:
--------------
trunk/fcp2/src/fcp2/iohandler.py
Modified: trunk/fcp2/src/fcp2/iohandler.py
===================================================================
--- trunk/fcp2/src/fcp2/iohandler.py 2008-07-01 11:27:21 UTC (rev 458)
+++ trunk/fcp2/src/fcp2/iohandler.py 2008-07-01 11:27:28 UTC (rev 459)
@@ -23,7 +23,7 @@
from fcp2 import message
from fcp2 import types
-del hack
+del hack, _RelImportHack
#<-- rel import hack
#*****************************************************************************
#
@@ -50,7 +50,7 @@
@return: always None
@raise L{consts.IOConnectFailedError}: in case something goes wrong
"""
- raise consts.IOConnectFailedError('Failed', consts.Logger.IO.error)
+ raise consts.ErrorIOConnectFailed('Failed', consts.ConstLogger.IO.error)
def read(self, n):
"""Should read n bytes from the device
@@ -59,7 +59,7 @@
@raise L{consts.IOBrokenError}: in case something goes wrong
@raise L{consts.IOTimeoutError}: if the read operation times out
"""
- raise consts.IOBrokenError('Broken', consts.Logger.IO.error)
+ raise consts.ErrorIOBroken('Broken', consts.ConstLogger.IO.error)
def write(self, bytes):
"""Should write bytes to the device
@@ -67,7 +67,7 @@
@return: always None
@raise L{consts.IOBrokenError}: in case something goes wrong
"""
- raise consts.IOBrokenError('Broken', consts.Logger.IO.error)
+ raise consts.ErrorIOBroken('Broken', consts.ConstLogger.IO.error)
def close(self):
"""Should close the io device
@@ -75,7 +75,7 @@
@return: always None
@raise L{consts.IOClosedError}: if the device is already closed
"""
- raise consts.IOClosedError('Closed', consts.Logger.IO.error)
+ raise consts.ErrorIOClosed('Closed', consts.ConstLogger.IO.error)
def isOpen(self):
"""Should check if the device is open
@@ -117,7 +117,7 @@
try:
self.socket.connect((host, port))
except socket.error, details:
- raise consts.IOConnectFailedError(details, consts.Logger.IO.error)
+ raise consts.ErrorIOConnectFailed(details, consts.ConstLogger.IO.error)
def read(self, n):
try:
@@ -125,10 +125,10 @@
if p == '':
raise socket.error('Socket closed by host')
except socket.timeout, details:
- raise consts.IOTimeoutError(details, consts.Logger.IO.log, consts.DebugVerbosity.Chatty)
+ raise consts.ErrorIOTimeout(details, consts.ConstLogger.IO.log, consts.DebugVerbosity.Chatty)
except socket.error, details:
self.close()
- raise consts.IOBrokenError(details, consts.Logger.IO.error)
+ raise consts.ErrorIOBroken(details, consts.ConstLogger.IO.error)
else:
return p
@@ -140,11 +140,11 @@
totalSend += n
except socket.error, details:
self.close()
- raise consts.IOBrokenError(details, consts.Logger.IO.error)
+ raise consts.ErrorIOBroken(details, consts.ConstLogger.IO.error)
def close(self):
if self.socket is None:
- raise consts.IOClosedError('Closed', consts.Logger.IO.error)
+ raise consts.ErrorIOClosed('Closed', consts.ConstLogger.IO.error)
self.socket.close()
self.socket = None
@@ -204,21 +204,21 @@
if self.isOpen():
self.close()
- consts.Logger.IOHandler.info(consts.LogMessages.Connecting + ' %r' % kwargs)
+ consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.Connecting + ' %r' % kwargs)
self.io = self._ioPrototype()
yield False # have to yield at least once to make unittests work (io has to be created!!)
try:
self.io.connect(**kwargs)
- except consts.IOConnectFailedError, details:
- consts.Logger.IOHandler.info(consts.LogMessages.ConnectingFailed + ' (%s)' % details)
+ except consts.ErrorIOConnectFailed, details:
+ consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.ConnectingFailed + ' (%s)' % details)
yield False
else:
- consts.Logger.IOHandler.info(consts.LogMessages.Connected)
+ consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.Connected)
yield True
break
# continue polling
- consts.Logger.IOHandler.info(consts.LogMessages.Retry)
+ consts.ConstLogger.IOHandler.info(consts.ConstLogMessages.Retry)
timeElapsed += timeout
time.sleep(timeout)
@@ -227,7 +227,7 @@
def close(self):
"""Closes the handler"""
- consts.Logger.IOHandler.debug(consts.LogMessages.Closing)
+ consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.Closing)
self._receiveBuffer = ''
if self.io is not None:
self.io.close()
@@ -254,8 +254,8 @@
if not p:
raise RuntimeError('No bytes received and IO did not raise as expected?!?')
self._receiveBuffer += p
- except consts.IOTimeoutError, details: # nothing in queue
- raise consts.IOTimeoutError(details)
+ except consts.ErrorIOTimeout, details: # nothing in queue
+ raise consts.ErrorIOTimeout(details)
def readMessage(self, hackyInvalidMessageCallback=None):
@@ -297,11 +297,11 @@
p = [i for i in chunk.split('\n') if i] # Fcp ignores empty lines, so do we
p.pop()
if not p:
- raise self.MessageParseError('No message name present')
+ raise self.ErrorMessageParse('No message name present')
msgName = p.pop(0)
msgClass = message.MessagesAll.get(msgName, None)
if msgClass is None:
- consts.Logger.IOHandler.debug(consts.LogMessages.CreatingNewMessageType + ' "%s"' % msgClassname)
+ consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.CreatingNewMessageType + ' "%s"' % msgClassname)
msgClass = message.newMessageClass(msgName)
msg = msgClass()
@@ -311,7 +311,7 @@
#HACK:
if hackyInvalidMessageCallback is not None:
hackyInvalidMessageCallback(msg)
- raise consts.MessageParseError('Invalid message parameters: ' + msg.pprint(), consts.Logger.IOHandler.error)
+ raise consts.ErrorMessageParse('Invalid message parameters: ' + msg.pprint(), consts.ConstLogger.IOHandler.error)
# get associated data if necessary
if mayHaveData:
@@ -320,7 +320,7 @@
#HACK:
if hackyInvalidMessageCallback is not None:
ackyInvalidMessageCallback(msg)
- raise consts.MessageParseError('DataLength must be type(int)')
+ raise consts.ErrorMessageParse('DataLength must be type(int)')
if n > 0:
while self._receiveBuffer:
@@ -329,11 +329,11 @@
break
try:
self.readBytes(self.io.BufferSize)
- except IOTimeout, details: # try again later
+ except ErrorIOTimeout, details: # try again later
self._receiveBuffer = chunk + self._receiveBuffer
- raise IOTimeout(details)
+ raise ErrorIOTimeout(details)
- consts.Logger.IOHandler.debug(consts.LogMessages.Received + msg.pprint())
+ consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.Received + msg.pprint())
return msg
@@ -343,7 +343,7 @@
@return: Message
@raise L{consts.IOBrokenError}: if the connection to the io dies unexpectedly
"""
- consts.Logger.IOHandler.debug(consts.LogMessages.Sending + msg.pprint())
+ consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.Sending + msg.pprint())
self.io.write(msg.toString())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|