From 67285cd2301056b442358c4806a176c67c8d81d5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 4 Dec 2011 15:30:12 +0900 Subject: [PATCH] fix full upload --- aqt/main.py | 3 +++ aqt/sync.py | 18 +++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index affce0c9f..7f8b5f846 100755 --- a/aqt/main.py +++ b/aqt/main.py @@ -820,6 +820,9 @@ Please choose a new deck name:""")) addHook("modSchema", self.onSchemaMod) def onSchemaMod(self, arg): + # if triggered in sync, make sure we don't use the gui + if not self.inMainThread(): + return True return askUser(_("""\ This operation can't be merged when syncing, so if you have made \ changes on other devices that haven't been synced to this device yet, \ diff --git a/aqt/sync.py b/aqt/sync.py index 66e263b6e..224b71fe8 100755 --- a/aqt/sync.py +++ b/aqt/sync.py @@ -42,26 +42,22 @@ class SyncManager(QObject): t = self.thread = SyncThread( self.pm.collectionPath(), self.pm.profile['syncKey'], auth=auth, media=self.pm.profile['syncMedia']) - print "created thread" self.connect(t, SIGNAL("event"), self.onEvent) - self.mw.progress.start(immediate=True, label=_("Connecting...")) - print "starting thread" + self.mw.progress.start(immediate=True, label=_("Syncing...")) self.thread.start() while not self.thread.isFinished(): self.mw.app.processEvents() self.thread.wait(100) - print "finished" self.mw.progress.finish() def onEvent(self, evt, *args): if evt == "badAuth": - return tooltip( + tooltip( _("AnkiWeb ID or password was incorrect; please try again."), parent=self.mw) elif evt == "newKey": self.pm.profile['syncKey'] = args[0] self.pm.save() - print "saved hkey" elif evt == "sync": self.mw.progress.update(label="sync: "+args[0]) elif evt == "mediaSync": @@ -72,7 +68,7 @@ class SyncManager(QObject): elif evt == "clockOff": print "clock is wrong" elif evt == "noChanges": - print "no changes found" + pass elif evt == "fullSync": self._confirmFullSync() elif evt == "success": @@ -192,9 +188,10 @@ class SyncThread(QThread): # run sync and catch any errors try: self._sync() - except Exception, e: - print e - self.fireEvent("error", unicode(e)) + except: + err = traceback.format_exc() + print err + self.fireEvent("error", err) finally: # don't bump mod time unless we explicitly save self.col.close(save=False) @@ -203,7 +200,6 @@ class SyncThread(QThread): if self.auth: # need to authenticate and obtain host key hkey = self.server.hostKey(*self.auth) - print "hkey was", hkey if not hkey: # provided details were invalid return self.fireEvent("badAuth")