コード例 #1
0
ファイル: io_throttle.py プロジェクト: StasEvseev/devel
 def __init__(self,
              fileName,
              packetID,
              remoteID,
              ownerID,
              callOnAck=None,
              callOnFail=None):
     self.fileName = fileName
     try:
         self.fileSize = os.path.getsize(os.path.abspath(fileName))
     except:
         lg.exc()
         self.fileSize = 0
     self.packetID = global_id.CanonicalID(packetID)
     parts = global_id.ParseGlobalID(packetID)
     self.customerID = parts['customer']
     self.remotePath = parts['path']
     self.customerIDURL = parts['idurl']
     customerGlobalID, remotePath, versionName, _ = packetid.SplitVersionFilename(
         packetID)
     self.backupID = packetid.MakeBackupID(customerGlobalID, remotePath,
                                           versionName)
     self.remoteID = remoteID
     self.ownerID = ownerID
     self.callOnAck = callOnAck
     self.callOnFail = callOnFail
     self.sendTime = None
     self.ackTime = None
     self.sendTimeout = 10 * 2 * (
         max(int(self.fileSize / settings.SendingSpeedLimit()), 5) + 5
     )  # maximum 5 seconds to get an Ack
     self.result = ''
     self.created = utime.get_sec1970()
     PacketReport('send', self.remoteID, self.packetID, 'init')
コード例 #2
0
 def __init__(self,
              parent, callOnReceived, creatorID, packetID, ownerID, remoteID,
              debug_level=_DebugLevel, log_events=_Debug, log_transitions=_Debug, publish_events=False, **kwargs):
     """
     Builds `file_down()` state machine.
     """
     self.parent = parent
     self.callOnReceived = []
     self.callOnReceived.append(callOnReceived)
     self.creatorID = creatorID
     self.packetID = global_id.CanonicalID(packetID)
     parts = global_id.ParseGlobalID(packetID)
     self.customerID = parts['customer']
     self.remotePath = parts['path']
     self.customerIDURL = parts['idurl']
     customerGlobalID, remotePath, versionName, fileName = packetid.SplitVersionFilename(packetID)
     self.backupID = packetid.MakeBackupID(customerGlobalID, remotePath, versionName)
     self.fileName = fileName
     self.ownerID = ownerID
     self.remoteID = remoteID
     self.requestTime = None
     self.fileReceivedTime = None
     self.requestTimeout = max(30, 2 * int(settings.getBackupBlockSize() / settings.SendingSpeedLimit()))
     self.result = ''
     self.created = utime.get_sec1970()
     super(FileDown, self).__init__(
         name="file_down_%s_%s/%s/%s" % (nameurl.GetName(self.remoteID), remotePath, versionName, fileName),
         state="AT_STARTUP",
         debug_level=debug_level,
         log_events=log_events,
         log_transitions=log_transitions,
         publish_events=publish_events,
         **kwargs
     )
コード例 #3
0
ファイル: file_up.py プロジェクト: codingcosmonaut/devel
 def __init__(self,
              parent,
              fileName,
              packetID,
              remoteID,
              ownerID,
              callOnAck=None,
              callOnFail=None,
              debug_level=_DebugLevel,
              log_events=_Debug,
              log_transitions=_Debug,
              publish_events=False,
              **kwargs):
     """
     Builds `file_up()` state machine.
     """
     self.parent = parent
     self.fileName = fileName
     try:
         self.fileSize = os.path.getsize(os.path.abspath(fileName))
     except:
         lg.exc()
         self.fileSize = 0
     self.packetID = global_id.CanonicalID(packetID)
     parts = global_id.ParseGlobalID(packetID)
     self.customerID = parts['customer']
     self.remotePath = parts['path']
     self.customerIDURL = parts['idurl']
     customerGlobalID, remotePath, versionName, fileName = packetid.SplitVersionFilename(
         packetID)
     self.backupID = packetid.MakeBackupID(customerGlobalID, remotePath,
                                           versionName)
     self.remoteID = remoteID
     self.ownerID = ownerID
     self.callOnAck = callOnAck
     self.callOnFail = callOnFail
     self.sendTime = None
     self.ackTime = None
     self.sendTimeout = 10 * 2 * (
         max(int(self.fileSize / settings.SendingSpeedLimit()), 5) + 5
     )  # maximum 5 seconds to get an Ack
     self.result = ''
     self.created = utime.get_sec1970()
     super(FileUp,
           self).__init__(name="file_up_%s_%s/%s/%s" % (nameurl.GetName(
               self.remoteID), remotePath, versionName, fileName),
                          state="AT_STARTUP",
                          debug_level=debug_level,
                          log_events=log_events,
                          log_transitions=log_transitions,
                          publish_events=publish_events,
                          **kwargs)
コード例 #4
0
 def __init__(self, callOnReceived, creatorID, packetID, ownerID, remoteID):
     self.callOnReceived = []
     self.callOnReceived.append(callOnReceived)
     self.creatorID = creatorID
     self.packetID = global_id.CanonicalID(packetID)
     parts = global_id.ParseGlobalID(packetID)
     self.customerID = parts['customer']
     self.remotePath = parts['path']
     self.customerIDURL = parts['idurl']
     customerGlobalID, remotePath, versionName, fileName = packetid.SplitVersionFilename(packetID)
     self.backupID = packetid.MakeBackupID(customerGlobalID, remotePath, versionName)
     self.fileName = fileName
     self.ownerID = ownerID
     self.remoteID = remoteID
     self.requestTime = None
     self.fileReceivedTime = None
     self.requestTimeout = max(30, 2 * int(settings.getBackupBlockSize() / settings.SendingSpeedLimit()))
     self.result = ''
     self.created = utime.get_sec1970()
     PacketReport('request', self.remoteID, self.packetID, 'init')