service.MultiService.__init__(self)
- print "MagicFolder __init__"
db = backupdb.get_backupdb(dbfile, create_version=(backupdb.SCHEMA_v3, 3))
if db is None:
return Failure(Exception('ERROR: Unable to load magic folder db.'))
# TODO: why is this being called more than once?
if self.running:
return defer.succeed(None)
- print "%r.startService" % (self,)
+ #print "%r.startService" % (self,)
service.MultiService.startService(self)
return self.uploader.start_monitoring()
return d
def finish(self):
- print "finish"
+ #print "finish"
d = self.uploader.stop()
d2 = self.downloader.stop()
d.addCallback(lambda ign: d2)
def _log(self, msg):
s = "Magic Folder %s: %s" % (self._name, msg)
self._client.log(s)
- print s
+ #print s
#open("events", "ab+").write(msg)
def _append_to_deque(self, path):
def __init__(self, client, local_path_u, db, upload_dircap, pending_delay):
QueueMixin.__init__(self, client, local_path_u, db, 'uploader')
- print "Magic-Folder: Uploader: __init__"
self.is_ready = False
# TODO: allow a path rather than a cap URI.
recursive=True)
def start_monitoring(self):
- print "start_monitoring"
+ self._log("start_monitoring")
d = defer.succeed(None)
d.addCallback(lambda ign: self._notifier.startReading())
d.addCallback(lambda ign: self._count('dirs_monitored'))
return d
def stop(self):
+ self._log("stop")
self._notifier.stopReading()
self._count('dirs_monitored', -1)
if hasattr(self._notifier, 'wait_until_stopped'):
return d
def start_scanning(self):
- print "start_scanning self._db = %r" % (self._db,)
+ self._log("start_scanning")
self.is_ready = True
all_files = self._db.get_all_files()
d = self._scan(self._local_path_u)
return d
def _scan(self, local_path_u): # XXX should this take a FilePath?
+ self._log("scan %r" % (local_path_u))
if not os.path.isdir(local_path_u):
raise AssertionError("Programmer error: _scan() must be passed a directory path.")
quoted_path = quote_local_unicode_path(local_path_u)
def __init__(self, client, local_path_u, db, collective_dircap):
QueueMixin.__init__(self, client, local_path_u, db, 'downloader')
- print "Magic-Folder: Downloader: __init__"
# TODO: allow a path rather than a cap URI.
self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
return bdb
def _restart_client(self, ign):
- print "_restart_client"
+ #print "_restart_client"
d = self.restart_client()
d.addCallback(self._wait_until_started)
return d
def _wait_until_started(self, ign):
- print "_wait_until_started"
+ #print "_wait_until_started"
self.magicfolder = self.get_client().getServiceNamed('magic-folder')
return self.magicfolder.ready()
self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
return d2
d.addCallback(lambda ign: create_test_file(u"what1"))
- def fu(res):
- print "upload complete"
- return res
- d.addBoth(fu)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
d.addCallback(self.cleanup)
+
d.addCallback(self._restart_client)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
d.addCallback(lambda ign: create_test_file(u"what2"))
-
- def fu2(res):
- print "2nd upload complete"
- return res
- d.addBoth(fu2)
-
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 2))
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
d.addBoth(self.cleanup)
# XXX are these used?
(self.alice_collective_dircap, self.alice_upload_dircap, self.alice_magicfolder,
self.bob_collective_dircap, self.bob_upload_dircap, self.bob_magicfolder) = result
- print "Alice magicfolderdb is at %r" % (self.alice_magicfolder._client.basedir)
- print "Bob magicfolderdb is at %r" % (self.bob_magicfolder._client.basedir)
+ #print "Alice magicfolderdb is at %r" % (self.alice_magicfolder._client.basedir)
+ #print "Bob magicfolderdb is at %r" % (self.bob_magicfolder._client.basedir)
d.addCallback(get_results)
def Alice_write_a_file(result):
- print "Alice writes a file\n"
+ #print "Alice writes a file\n"
self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader._local_path_u)
fileutil.write(self.file_path, "meow, meow meow. meow? meow meow! meow.")
self.magicfolder = self.alice_magicfolder
d.addCallback(Alice_write_a_file)
def Alice_wait_for_upload(result):
- print "Alice waits for an upload\n"
+ #print "Alice waits for an upload\n"
d2 = self.alice_magicfolder.uploader.set_hook('processed')
return d2
d.addCallback(Alice_wait_for_upload)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.directories_created', client=self.alice_magicfolder._client), 0))
def Bob_wait_for_download(result):
- print "Bob waits for a download\n"
+ #print "Bob waits for a download\n"
d2 = self.bob_magicfolder.downloader.set_hook('processed')
return d2
d.addCallback(Bob_wait_for_download)
# test deletion of file behavior
def Alice_delete_file(result):
- print "Alice deletes the file!\n"
+ #print "Alice deletes the file!\n"
os.unlink(self.file_path)
self.notify(to_filepath(self.file_path), self.inotify.IN_DELETE)
def Alice_rewrite_file(result):
- print "Alice rewrites file\n"
+ #print "Alice rewrites file\n"
self.file_path = abspath_expanduser_unicode(u"file1", base=self.alice_magicfolder.uploader._local_path_u)
fileutil.write(self.file_path, "Alice suddenly sees the white rabbit running into the forest.")
self.magicfolder = self.alice_magicfolder