예제 #1
0
파일: mediasync.py 프로젝트: zzzdeb/anki
    def _on_finished(self, future: Future) -> None:
        self._syncing = False
        gui_hooks.media_sync_did_start_or_stop(False)

        exc = future.exception()
        if exc is not None:
            self._handle_sync_error(exc)
        else:
            self._log_and_notify(tr(TR.SYNC_MEDIA_COMPLETE))
예제 #2
0
    def _on_finished(self, future: Future) -> None:
        self._syncing = False
        gui_hooks.media_sync_did_start_or_stop(False)

        exc = future.exception()
        if exc is not None:
            self._handle_sync_error(exc)
        else:
            self._log_and_notify(tr(StringsGroup.SYNC, "media-complete"))
예제 #3
0
    def _on_finished(self, future: Future) -> None:
        self._syncing = False
        if self._progress_timer:
            self._progress_timer.stop()
            self._progress_timer = None
        gui_hooks.media_sync_did_start_or_stop(False)

        exc = future.exception()
        if exc is not None:
            self._handle_sync_error(exc)
        else:
            self._log_and_notify(tr.sync_media_complete())
예제 #4
0
파일: mediasync.py 프로젝트: zzzdeb/anki
    def start(self) -> None:
        "Start media syncing in the background, if it's not already running."
        if self._syncing:
            return

        hkey = self.mw.pm.sync_key()
        if hkey is None:
            return

        if not self.mw.pm.media_syncing_enabled():
            self._log_and_notify(tr(TR.SYNC_MEDIA_DISABLED))
            return

        self._log_and_notify(tr(TR.SYNC_MEDIA_STARTING))
        self._syncing = True
        self._want_stop = False
        gui_hooks.media_sync_did_start_or_stop(True)

        def run() -> None:
            self.mw.col.backend.sync_media(hkey, self._endpoint())

        self.mw.taskman.run_in_background(run, self._on_finished)
예제 #5
0
    def start(self) -> None:
        "Start media syncing in the background, if it's not already running."
        if self._syncing:
            return

        if not self.mw.pm.media_syncing_enabled():
            self._log_and_notify(tr(TR.SYNC_MEDIA_DISABLED))
            return

        auth = self.mw.pm.sync_auth()
        if auth is None:
            return

        self._log_and_notify(tr(TR.SYNC_MEDIA_STARTING))
        self._syncing = True
        self._progress_timer = self.mw.progress.timer(1000, self._on_progress,
                                                      True, True)
        gui_hooks.media_sync_did_start_or_stop(True)

        def run() -> None:
            self.mw.col.sync_media(auth)

        self.mw.taskman.run_in_background(run, self._on_finished)