if path_u not in self._pending:
self._append_to_deque(path_u)
+ def _print(self, res, msg):
+ print msg
+ return res
+
def _process(self, path):
+ print "herez1"
d = defer.succeed(None)
# FIXME (ticket #1712): if this already exists as a mutable file, we replace the
d.addCallback(_maybe_upload)
def _succeeded(ign):
+ d.addCallback(self._print, "herez2")
self._stats_provider.count('drop_upload.objects_queued', -1)
self._stats_provider.count('drop_upload.objects_uploaded', 1)
def _failed(f):
+ d.addCallback(self._print, "herez3")
self._stats_provider.count('drop_upload.objects_queued', -1)
if os.path.exists(path):
self._log("drop-upload: %r failed to upload due to %r" % (path, f))
return None
d.addCallbacks(_succeeded, _failed)
+ d.addCallback(self._print, "herez4")
d.addBoth(self._do_upload_callback)
return d
def _do_upload_callback(self, res):
+ print "herey"
if self._ignore_count == 0:
self._uploaded_callback(res)
else:
"""
This sets a function that will be called after a file has been uploaded.
"""
+ print "herex", ignore_count
self._uploaded_callback = callback
self._ignore_count = ignore_count
return service.MultiService.disownServiceParent(self)
def _log(self, msg):
+ print msg
self._client.log(msg)
#open("events", "ab+").write(msg)
def test_drop_upload(self):
self.set_up_grid()
self.local_dir = os.path.join(self.basedir, self.unicode_or_fallback(u"loc\u0101l_dir", u"local_dir"))
+ print "local_dir = %r" % (self.local_dir,)
self.mkdir_nonascii(self.local_dir)
self.client = self.g.clients[0]
d.addCallback(self._made_upload_dir)
d.addCallback(self._create_uploader)
+ def _print(res, msg):
+ print msg
+ return res
# Write something short enough for a LIT file.
+ d.addCallback(_print, "here1")
d.addCallback(lambda ign: self._check_file(u"short", "test"))
# Write to the same file again with different data.
+ d.addCallback(_print, "here2")
d.addCallback(lambda ign: self._check_file(u"short", "different"))
# Test that temporary files are not uploaded.
+ d.addCallback(_print, "here3")
d.addCallback(lambda ign: self._check_file(u"tempfile", "test", temporary=True))
# Test that we tolerate creation of a subdirectory.
+ d.addCallback(_print, "here4")
d.addCallback(lambda ign: os.mkdir(os.path.join(self.local_dir, u"directory")))
# Write something longer, and also try to test a Unicode name if the fs can represent it.
name_u = self.unicode_or_fallback(u"l\u00F8ng", u"long")
+ d.addCallback(_print, "here5")
d.addCallback(lambda ign: self._check_file(name_u, "test"*100))
# TODO: test that causes an upload failure.
+ d.addCallback(_print, "here6")
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_failed'), 0))
+ d.addCallback(_print, "here7")
d.addBoth(self._cleanup)
return d
fileutil.flush_volume(path_u)
self.notify_close_write(path)
+ def _print(res, msg):
+ print msg
+ return res
if temporary:
+ d.addCallback(_print, "here8")
d.addCallback(lambda ign: self.shouldFail(NoSuchChildError, 'temp file not uploaded', None,
self.upload_dirnode.get, name_u))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_disappeared'),
previously_disappeared + 1))
else:
+ d.addCallback(_print, "here9")
d.addCallback(lambda ign: self.upload_dirnode.get(name_u))
+ d.addCallback(_print, "here10")
d.addCallback(download_to_data)
+ d.addCallback(_print, "here11")
d.addCallback(lambda actual_data: self.failUnlessReallyEqual(actual_data, data))
+ d.addCallback(_print, "here12")
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'),
previously_uploaded + 1))