mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
tweak sync messages
This commit is contained in:
parent
64ed220fba
commit
1fe48b0c3a
1 changed files with 19 additions and 30 deletions
49
aqt/sync.py
49
aqt/sync.py
|
@ -51,6 +51,7 @@ class SyncManager(QObject):
|
||||||
self.mw.progress.finish()
|
self.mw.progress.finish()
|
||||||
|
|
||||||
def onEvent(self, evt, *args):
|
def onEvent(self, evt, *args):
|
||||||
|
pu = self.mw.progress.update
|
||||||
if evt == "badAuth":
|
if evt == "badAuth":
|
||||||
tooltip(
|
tooltip(
|
||||||
_("AnkiWeb ID or password was incorrect; please try again."),
|
_("AnkiWeb ID or password was incorrect; please try again."),
|
||||||
|
@ -59,30 +60,27 @@ class SyncManager(QObject):
|
||||||
self.pm.profile['syncKey'] = args[0]
|
self.pm.profile['syncKey'] = args[0]
|
||||||
self.pm.save()
|
self.pm.save()
|
||||||
elif evt == "sync":
|
elif evt == "sync":
|
||||||
self.mw.progress.update(label="sync: "+args[0])
|
m = None; t = args[0]
|
||||||
elif evt == "mediaSync":
|
if t == "login":
|
||||||
self.mw.progress.update(label="media: "+args[0])
|
m = _("Syncing...")
|
||||||
|
elif t == "upload":
|
||||||
|
m = _("Uploading to AnkiWeb...")
|
||||||
|
elif t == "download":
|
||||||
|
m = _("Downloading from AnkiWeb...")
|
||||||
|
elif t == "sanity":
|
||||||
|
m = _("Checking...")
|
||||||
|
if m:
|
||||||
|
print m
|
||||||
|
self.mw.progress.update(label=m)
|
||||||
elif evt == "error":
|
elif evt == "error":
|
||||||
showWarning(_("Syncing failed:\n%s")%
|
showWarning(_("Syncing failed:\n%s")%
|
||||||
self._rewriteError(args[0]))
|
self._rewriteError(args[0]))
|
||||||
elif evt == "clockOff":
|
elif evt == "clockOff":
|
||||||
print "clock is wrong"
|
self._clockOff()
|
||||||
elif evt == "noChanges":
|
elif evt == "noChanges":
|
||||||
pass
|
pass
|
||||||
elif evt == "fullSync":
|
elif evt == "fullSync":
|
||||||
self._confirmFullSync()
|
self._confirmFullSync()
|
||||||
elif evt == "success":
|
|
||||||
print "sync successful"
|
|
||||||
elif evt == "upload":
|
|
||||||
print "upload successful"
|
|
||||||
elif evt == "download":
|
|
||||||
print "download successful"
|
|
||||||
elif evt == "noMediaChanges":
|
|
||||||
print "no media changes"
|
|
||||||
elif evt == "mediaSuccess":
|
|
||||||
print "media sync successful"
|
|
||||||
else:
|
|
||||||
print "unknown evt", evt
|
|
||||||
|
|
||||||
def _rewriteError(self, err):
|
def _rewriteError(self, err):
|
||||||
if "Errno 61" in err:
|
if "Errno 61" in err:
|
||||||
|
@ -149,15 +147,10 @@ do you want to keep the AnkiWeb version, overwriting the version here?"""),
|
||||||
else:
|
else:
|
||||||
self.thread.fullSyncChoice = "cancel"
|
self.thread.fullSyncChoice = "cancel"
|
||||||
|
|
||||||
def syncClockOff(self, diff):
|
def _clockOff(self):
|
||||||
showWarning(
|
showWarning(_("""\
|
||||||
_("The time or date on your computer is not correct.\n") +
|
Syncing requires the clock on your computer to be set correctly. Please \
|
||||||
ngettext("It is off by %d second.\n\n",
|
fix the clock and try again."""))
|
||||||
"It is off by %d seconds.\n\n", diff) % diff +
|
|
||||||
_("Since this can cause many problems with syncing,\n"
|
|
||||||
"syncing is disabled until you fix the problem.")
|
|
||||||
)
|
|
||||||
self.onSyncFinished()
|
|
||||||
|
|
||||||
def badUserPass(self):
|
def badUserPass(self):
|
||||||
aqt.preferences.Preferences(self, self.pm.profile).dialog.tabWidget.\
|
aqt.preferences.Preferences(self, self.pm.profile).dialog.tabWidget.\
|
||||||
|
@ -181,10 +174,7 @@ class SyncThread(QThread):
|
||||||
self.client = Syncer(self.col, self.server)
|
self.client = Syncer(self.col, self.server)
|
||||||
def syncEvent(type):
|
def syncEvent(type):
|
||||||
self.fireEvent("sync", type)
|
self.fireEvent("sync", type)
|
||||||
def mediaSync(type):
|
|
||||||
self.fireEvent("mediaSync", type)
|
|
||||||
addHook("sync", syncEvent)
|
addHook("sync", syncEvent)
|
||||||
addHook("mediaSync", mediaSync)
|
|
||||||
# run sync and catch any errors
|
# run sync and catch any errors
|
||||||
try:
|
try:
|
||||||
self._sync()
|
self._sync()
|
||||||
|
@ -195,6 +185,7 @@ class SyncThread(QThread):
|
||||||
finally:
|
finally:
|
||||||
# don't bump mod time unless we explicitly save
|
# don't bump mod time unless we explicitly save
|
||||||
self.col.close(save=False)
|
self.col.close(save=False)
|
||||||
|
removeHook("sync", syncEvent)
|
||||||
|
|
||||||
def _sync(self):
|
def _sync(self):
|
||||||
if self.auth:
|
if self.auth:
|
||||||
|
@ -239,10 +230,8 @@ class SyncThread(QThread):
|
||||||
self.client = FullSyncer(self.col, self.hkey, self.server.con)
|
self.client = FullSyncer(self.col, self.hkey, self.server.con)
|
||||||
if f == "upload":
|
if f == "upload":
|
||||||
self.client.upload()
|
self.client.upload()
|
||||||
self.fireEvent("upload")
|
|
||||||
else:
|
else:
|
||||||
self.client.download()
|
self.client.download()
|
||||||
self.fireEvent("download")
|
|
||||||
# move on to media sync
|
# move on to media sync
|
||||||
self._syncMedia()
|
self._syncMedia()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue