Beispiel #1
0
 def xmlrpc_uploadFile(self, recipe_test_id, name, size, digest, offset,
                       data):
     log.debug("XMLRPC: results.uploadFile(%r, %r, %r, %r, %r, %r)",
               recipe_test_id, name, size, digest, offset, data)
     file_id = self.get_file(name,
                             size=size,
                             digest=(digests.which_digest(digest), None))
     if file_id is None:
         msg = "%s:xmlrpc_uploadFile: " % self.__class__.__name__ + \
                 "Can not create file '%s'." % name
         self.main.error(msg)
         return msg
     if offset < 0:
         if digest:
             digest = digests.mk_digest(digest)
             if digest:
                 evt = event.file_meta(file_id, digest=digest)
                 self.main.send_evt(evt)
         evt = event.file_close(file_id)
         self.main.send_evt(evt)
         return 0
     if data:
         # FIXME: is chunk's digest necessary?
         evt = event.file_write(file_id, data, offset=offset, digest=digest)
         self.main.send_evt(evt)
     return 0  # or "Failure reason"
Beispiel #2
0
 def xmlrpc_uploadFile(self, recipe_test_id, name, size, digest, offset,
         data):
     log.debug("XMLRPC: results.uploadFile(%r, %r, %r, %r, %r, %r)",
             recipe_test_id, name, size, digest, offset, data)
     file_id = self.get_file(name, size=size,
             digest=(digests.which_digest(digest), None))
     if file_id is None:
         msg = "%s:xmlrpc_uploadFile: " % self.__class__.__name__ + \
                 "Can not create file '%s'." % name
         self.main.error(msg)
         return msg
     if offset < 0:
         if digest:
             digest = digests.mk_digest(digest)
             if digest:
                 evt = event.file_meta(file_id, digest=digest)
                 self.main.send_evt(evt)
         evt = event.file_close(file_id)
         self.main.send_evt(evt)
         return 0
     if data:
         # FIXME: is chunk's digest necessary?
         evt = event.file_write(file_id, data, offset=offset, digest=digest)
         self.main.send_evt(evt)
     return 0 # or "Failure reason"
Beispiel #3
0
 def upload_chunk(self, offset, data):
     if offset is None:
         new_offset = self.tell() + len(data)
     else:
         new_offset = offset + len(data)
     self.send(event.file_write(self.id(), event.encode(self.CODEC, data),
         offset=offset, codec=self.CODEC))
     self.seek(new_offset)
     return None
Beispiel #4
0
 def upload_chunk(self, offset, data):
     if offset is None:
         new_offset = self.tell() + len(data)
     else:
         new_offset = offset + len(data)
     self.send(
         event.file_write(self.id(),
                          event.encode(self.CODEC, data),
                          offset=offset,
                          codec=self.CODEC))
     self.seek(new_offset)
     return None
Beispiel #5
0
 def testContructors(self):
     """test copy constructors"""
     def test_copy(e, copy):
         self.failUnless(copy.same_as(e))
         self.failUnlessEqual(copy.id(), e.id())
     def test_constructors(e):
         test_copy(e, event.Event(e))
         test_copy(e, event.Event(list(e)))
         test_copy(e, event.event(list(e)))
         if isinstance(e, event.Event):
             self.failUnless(e is event.event(e))
     test_constructors(event.pong(message='Hello World!'))
     test_constructors(event.file_write('FID', 'DATA'))
Beispiel #6
0
 def testOverridenMethods(self):
     s = "Data to be written but not displayed"
     fw = event.file_write('FID', s)
     self.failUnlessEqual(fw.__str__().find(s), -1)
     self.failUnlessEqual(fw.__repr__().find(s), -1)