Example #1
0
 def start_upload(self, key, path, size, parent):
     """
     Starts a FileReceiver server for the given C{key}.
     """
     if key in self.uploads:
         log.warn("Can't start another upload for {0}: already uploading".format(key))
         raise AlreadyUploading(key)
     
     path = os.path.join(self.root, key)
     
     handler = FileReceiver(key, path, size, parent)
     self.task_register.add(handler)
     address = Address(routing_key=key)
     
     queues = (
         queue('', (
             binding('transfers', '{routing_key}'),
         ), extra={
             'exclusive': True,
             'auto_delete': True,
         }),
     )
     
     self.uploads[key] = handler
     yield self.amq_server(address, ThriftReceiver, handler, queues)
Example #2
0
    def run(self, application, destinations):
        yield self.setup(application, destinations)

        if not self.destinations:
            log.warn("No destinations selected, aborting transfer")
            return

        self.transfer()
Example #3
0
 def remove(self, task_id):
     try:
         task = self.tasks[task_id]
     except KeyError:
         raise ValueError("Invalid task ID: '{0}'".format(task_id))
     
     if task.status not in (TaskStatus.COMPLETED, TaskStatus.CANCELLED,
             TaskStatus.FAILED):
         log.warn("Removing non completed task '{0}'".format(task_id))
     
     del self.tasks[task_id]
Example #4
0
 def finalize_upload(self, key, checksum):
     """
     Waits for the FileReceiver server to succeed and return its response
     to the caller.
     
     @todo: Requests for inexistent uploads are ignored, raise an exception
            instead.
     """
     try:
         return self.uploads.pop(key).finish(checksum)
     except KeyError:
         log.warn("Upload with key {0} not found. Can't finalize".format(key))
         return
Example #5
0
 def parse_message(self, msg, channel, queue, client):
     tag = msg.delivery_tag
     
     transport = TTransport.TMemoryBuffer(msg.content.body)
     iprot = self.iprot_factory.getProtocol(transport)
     
     (fname, mtype, rseqid) = iprot.readMessageBegin()
     
     if rseqid not in client._reqs:
         log.warn('Missing rseqid! fname = %r, rseqid = %s, mtype = %r, routing key = %r, client = %r, msg.content.body = %r' % (fname, rseqid, mtype, msg.routing_key, client, msg.content.body))
         
     method = getattr(client, 'recv_' + fname)
     method(iprot, mtype, rseqid)
     channel.basic_ack(tag, True)
     
     self.get_next_message(channel, queue, client)
Example #6
0
 def timeout(deferred):
     log.warn("Some modules are not available.")
     deferred.errback(ModuleNotAvailable())