SF.net SVN: fclient: [636] trunk/fclient/src/fclient/lib/fcp2/client.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-15 23:51:02
|
Revision: 636
http://fclient.svn.sourceforge.net/fclient/?rev=636&view=rev
Author: jUrner
Date: 2008-07-15 16:51:04 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
some smaller fixes
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/client.py
Modified: trunk/fclient/src/fclient/lib/fcp2/client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-15 23:49:14 UTC (rev 635)
+++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-15 23:51:04 UTC (rev 636)
@@ -210,7 +210,6 @@
import atexit
import copy
-import logging
import random
import subprocess
import time
@@ -284,7 +283,8 @@
for event in self.events:
event += self._captureEvent
- self.setDebugVerbosity(consts.ConstDebugVerbosity.Warning if debugVerbosity is None else debugVerbosity)
+ if not debugVerbosity is None:
+ self.setDebugVerbosity(debugVerbosity)
atexit.register(self.close)
###############################################################
@@ -299,7 +299,7 @@
consts.ConstLogger.Event.debug(consts.ConstLogMessages.EventTriggered + event.name)
- def _close(self, msg):
+ def _close(self, msg=None):
"""Closes the client
@param msg: message to pass to the ClientDisconnected event or None to not inform listeners
@@ -413,7 +413,9 @@
"""Closes the client
@note: make shure to call close() when done with the client
"""
- msg = message.MsgClientDisconnected(
+ msg = None
+ if self.isConnected():
+ msg = message.MsgClientDisconnected(
DisconnectReason=consts.ConstDisconnectReason.Close,
)
self._close(msg)
@@ -538,8 +540,13 @@
@param debugVerbosity: L{consts.ConstDebugVerbosity}
"""
consts.ConstLogger.Client.setLevel(debugVerbosity)
-
+
+ def getNodeHelloMessage(self):
+ """returns the node hello message the client received or None if no message has arrived yet """
+ return self._nodeHelloMessage
+
+
def newIdentifier(self, identifiers=None):
"""Creates a new identifier to be used as request identifer or whatever
@param identifiers: if desired any iterable containing identifiers to enshure the identifier is unique within the iterable
@@ -852,7 +859,7 @@
return True
# check if it is one of our requests for key information
- if code == consts.ConstFetchError.TooBig and initialRequest['RequestType'] == consts.ConstRequestType.GetKeyInfo:
+ if code == consts.ConstFetchError.TooBig and initialRequest['RequestType'] & consts.ConstRequestType.GetKeyInfo:
initialRequest['MetadataContentType'] = msg.get('ExpectedMetadata.ContentType', '')
initialRequest['DataLength'] = msg.get('ExpectedDataLength', -1)
initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success
@@ -877,7 +884,6 @@
)
return True
- requestType = msg['RequestType']
if msg == message.MsgPersistentGet:
initialRequest = message.MsgClientGet()
elif msg == message.MsgPersistentPut:
@@ -1084,7 +1090,7 @@
insertURI = msg['InsertURI']
requestURI = msg['RequestURI']
- if initialRequest['RequestType'] == consts.ConstRequestType.GenerateUSKKeypair:
+ if initialRequest['RequestType'] & consts.ConstRequestType.GenerateUSKKeypair:
insertURI = key.KeyUSK(insertURI.keyData, docName=insertURI.docName)
insertURI = key.KeyUSK(insertURI.keyData, docName=insertURI.docName)
requestURI = key.KeyUSK(requestURI.keyData, docName=requestURI.docName)
@@ -1214,13 +1220,13 @@
#########################################################
def getConfig(self,
withCurrent=True,
- withDefaults=True,
- withExpertFlag=True,
- withForceWriteFlag=True,
- withSortOrder=True,
- withShortDescription=True,
- withLongDescription=True,
- withDataTypes=True,
+ withDefaults=False,
+ withExpertFlag=False,
+ withForceWriteFlag=False,
+ withSortOrder=False,
+ withShortDescription=False,
+ withLongDescription=False,
+ withDataTypes=False,
):
"""
@event: ConfigData(event, msg)
@@ -1546,9 +1552,9 @@
# find out wich message to use
if requestType & (consts.ConstRequestType.PutData | consts.ConstRequestType.PutFile | consts.ConstRequestType.PutRedirect):
msgClass = message.MsgClientPut
- elif requestType == consts.ConstRequestType.PutDir:
+ elif requestType & consts.ConstRequestType.PutDir:
msgClass = message.MsgClientPutDiskDir
- elif requestType == consts.ConstRequestType.PutMultiple:
+ elif requestType & consts.ConstRequestType.PutMultiple:
msgClass = message.MsgClientPutComplexDir
else:
raise ValueError('Unsupported request type')
@@ -1573,12 +1579,12 @@
msg[param] = value
if data is not None:
- if requestType != consts.ConstRequestType.PutData:
+ if not requestType & consts.ConstRequestType.PutData:
raise ValueError('Data can only be passed along with putData uploads')
msg.data = data
if items is not None:
- if requestType != consts.ConstRequestType.PutMultiple:
+ if not requestType & consts.ConstRequestType.PutMultiple:
raise ValueError('Items can only be passed along with PutMultiple uploads')
uploadTypeMapping = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|