def on_done(future: Future) -> None: mw.progress.finish() try: future.result() except zipfile.BadZipfile: showWarning(invalidZipMsg()) except V2ImportIntoV1: showWarning("""\ To import this deck, please click the Update button at the top of the deck list, then try again.""" ) except Exception as e: err = repr(str(e)) if "invalidFile" in err: msg = tr.importing_invalid_file_please_restore_from_backup( ) showWarning(msg) elif "invalidTempFolder" in err: showWarning(mw.errorHandler.tempFolderMsg()) elif "readonly" in err: showWarning( tr.importing_unable_to_import_from_a_readonly()) else: msg = f"{tr.importing_failed_debug_info()}\n" msg += str(e) showText(msg) else: log = "\n".join(importer.log) if "\n" not in log: tooltip(log) else: showText(log, plain_text_edit=True) mw.reset()
def on_done(future: Future) -> None: mw.progress.finish() try: future.result() except zipfile.BadZipfile: showWarning(invalidZipMsg()) except Exception as e: err = repr(str(e)) if "invalidFile" in err: msg = tr.importing_invalid_file_please_restore_from_backup() showWarning(msg) elif "invalidTempFolder" in err: showWarning(mw.errorHandler.tempFolderMsg()) elif "readonly" in err: showWarning(tr.importing_unable_to_import_from_a_readonly()) else: msg = f"{tr.importing_failed_debug_info()}\n" msg += str(traceback.format_exc()) showText(msg) else: log = "\n".join(importer.log) if "\n" not in log: tooltip(log) else: showText(log, plain_text_edit=True) mw.reset()