def SendDeleteBackup(SupplierID, BackupID): if _Debug: lg.out(_DebugLevel, "p2p_service.SendDeleteBackup SupplierID=%s BackupID=%s" % (SupplierID, BackupID)) MyID = my_id.getLocalID() PacketID = packetid.RemotePath(BackupID) RemoteID = SupplierID result = signed.Packet(commands.DeleteBackup(), MyID, MyID, PacketID, "", RemoteID) gateway.outbox(result) return result
def SendDeleteBackup(SupplierID, BackupID): if _Debug: lg.out( _DebugLevel, "p2p_service.SendDeleteBackup SupplierID=%s BackupID=%s" % (SupplierID, BackupID)) MyID = my_id.getIDURL() PacketID = packetid.RemotePath(BackupID) RemoteID = SupplierID result = signed.Packet( Command=commands.DeleteBackup(), OwnerID=MyID, CreatorID=MyID, PacketID=PacketID, Payload="", RemoteID=RemoteID, ) gateway.outbox(result) return result
def doScanAndQueue(self, arg): global _ShutdownFlag if _Debug: lg.out(_DebugLevel, 'data_sender.doScanAndQueue _ShutdownFlag=%r' % _ShutdownFlag) if _Debug: log = open(os.path.join(settings.LogsDir(), 'data_sender.log'), 'w') log.write('doScanAndQueue %s\n' % time.asctime()) if _ShutdownFlag: if _Debug: log.write('doScanAndQueue _ShutdownFlag is True\n') self.automat('scan-done') if _Debug: log.flush() log.close() return for customer_idurl in contactsdb.known_customers(): if '' not in contactsdb.suppliers(customer_idurl): from storage import backup_matrix for backupID in misc.sorted_backup_ids( backup_matrix.local_files().keys(), True): packetsBySupplier = backup_matrix.ScanBlocksToSend(backupID) if _Debug: log.write('%s\n' % packetsBySupplier) for supplierNum in packetsBySupplier.keys(): supplier_idurl = contactsdb.supplier(supplierNum, customer_idurl=customer_idurl) if not supplier_idurl: lg.warn('?supplierNum? %s for %s' % (supplierNum, backupID)) continue for packetID in packetsBySupplier[supplierNum]: backupID_, _, supplierNum_, _ = packetid.BidBnSnDp(packetID) if backupID_ != backupID: lg.warn('?backupID? %s for %s' % (packetID, backupID)) continue if supplierNum_ != supplierNum: lg.warn('?supplierNum? %s for %s' % (packetID, backupID)) continue if io_throttle.HasPacketInSendQueue( supplier_idurl, packetID): if _Debug: log.write('%s already in sending queue for %s\n' % (packetID, supplier_idurl)) continue if not io_throttle.OkToSend(supplier_idurl): if _Debug: log.write('ok to send %s ? - NO!\n' % supplier_idurl) continue # tranByID = gate.transfers_out_by_idurl().get(supplier_idurl, []) # if len(tranByID) > 3: # log.write('transfers by %s: %d\n' % (supplier_idurl, len(tranByID))) # continue filename = os.path.join( settings.getLocalBackupsDir(), global_id.UrlToGlobalID(customer_idurl), packetid.RemotePath(packetID), ) if not os.path.isfile(filename): if _Debug: log.write('%s is not a file\n' % filename) continue if io_throttle.QueueSendFile( filename, packetID, supplier_idurl, my_id.getLocalID(), self._packetAcked, self._packetFailed, ): if _Debug: log.write('io_throttle.QueueSendFile %s\n' % packetID) else: if _Debug: log.write('io_throttle.QueueSendFile FAILED %s\n' % packetID) # lg.out(6, ' %s for %s' % (packetID, backupID)) # DEBUG # break self.automat('scan-done') if _Debug: log.flush() log.close()