xxyzz / WordDumb

A calibre plugin that generates Kindle Word Wise and X-Ray files for KFX, AZW3, MOBI and EPUB eBook.
https://xxyzz.github.io/WordDumb/
GNU General Public License v3.0
386 stars 19 forks source link

`'NoneType' object has no attribute 'close'` when creating word wise without x-ray #106

Closed Vuizur closed 1 year ago

Vuizur commented 1 year ago

Checkboxes

Describe the bug

For the two books I tested creating Word Wise + Xray worked well, but Word Wise without X-Ray failed with the error below.

System Information

Win 10 Python 3.10

Error message

Starting job: Generating Word Wise for Desde Rusia con amor 
Job: "Generating Word Wise for Desde Rusia con amor" failed with error: 
Traceback (most recent call last):
  File "calibre\gui2\threaded_jobs.py", line 82, in start_work
  File "calibre_plugins.worddumb.parse_job", line 188, in do_job
  File "calibre_plugins.worddumb.utils", line 51, in run_subprocess
  File "subprocess.py", line 524, in run
subprocess.CalledProcessError: Command '['py', 'C:\\Users\\hanne\\AppData\\Roaming\\calibre\\plugins\\WordDumb.zip', '{"create_ww": true, "create_x": false, "asin": "", "book_path": "C:\\\\Users\\\\hanne\\\\Calibre-Bibliothek\\\\Ian Fleming\\\\Desde Rusia con amor (204)\\\\Desde Rusia con amor - Ian Fleming.epub", "acr": "", "revision": "", "model": "es_core_news_md", "lemma_lang": "es", "mobi_codec": "", "useragent": "WordDumb/3.29.0 (https://github.com/xxyzz/WordDumb)", "book_fmt": "EPUB", "plugin_path": "C:\\\\Users\\\\hanne\\\\AppData\\\\Roaming\\\\calibre\\\\plugins\\\\WordDumb.zip"}', '{"use_pos": false, "search_people": false, "model_size": "md", "zh_wiki_variant": "cn", "fandom": "", "add_locator_map": false, "preferred_formats": ["KFX", "AZW3", "AZW", "MOBI", "EPUB"], "use_all_formats": false, "minimal_x_ray_count": 1, "en_ipa": "ga_ipa", "zh_ipa": "pinyin", "choose_format_manually": true, "wiktionary_gloss_lang": "en", "kindle_gloss_lang": "en", "use_gpu": false, "cuda": "cu117", "last_opened_kindle_lemmas_language": "ca", "last_opened_wiktionary_lemmas_language": "es", "use_wiktionary_for_kindle": false, "ca_wiktionary_difficulty_limit": 5, "da_wiktionary_difficulty_limit": 5, "de_wiktionary_difficulty_limit": 5, "el_wiktionary_difficulty_limit": 5, "en_wiktionary_difficulty_limit": 5, "fi_wiktionary_difficulty_limit": 5, "fr_wiktionary_difficulty_limit": 5, "hr_wiktionary_difficulty_limit": 5, "it_wiktionary_difficulty_limit": 5, "ja_wiktionary_difficulty_limit": 5, "ko_wiktionary_difficulty_limit": 5, "lt_wiktionary_difficulty_limit": 5, "mk_wiktionary_difficulty_limit": 5, "nl_wiktionary_difficulty_limit": 5, "no_wiktionary_difficulty_limit": 5, "pl_wiktionary_difficulty_limit": 5, "pt_wiktionary_difficulty_limit": 5, "ro_wiktionary_difficulty_limit": 5, "ru_wiktionary_difficulty_limit": 5, "es_wiktionary_difficulty_limit": 2, "sv_wiktionary_difficulty_limit": 5, "uk_wiktionary_difficulty_limit": 5, "zh_wiktionary_difficulty_limit": 5}']' returned non-zero exit status 1.

Called with args: ((204, 'EPUB', 'C:\\Users\\hanne\\Calibre-Bibliothek\\Ian Fleming\\Desde Rusia con amor (204)\\Desde Rusia con amor - Ian Fleming.epub', <calibre.ebooks.metadata.book.base.Metadata object at 0x00000270CA1A7AF0>, {'spacy': 'es_core_news_', 'wiki': 'es', 'kaikki': 'Spanish', 'gloss': False, 'has_trf': False}), True, False) {'notifications': <queue.Queue object at 0x00000270CA1A7B20>, 'abort': <threading.Event object at 0x00000270CA1A7070>, 'log': <calibre.utils.logging.GUILog object at 0x00000270CA1A74C0>} 
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\hanne\AppData\Roaming\calibre\plugins\WordDumb.zip\__main__.py", line 41, in <module>
  File "C:\Users\hanne\AppData\Roaming\calibre\plugins\WordDumb.zip\parse_job.py", line 309, in create_files
  File "C:\Users\hanne\AppData\Roaming\calibre\plugins\WordDumb.zip\epub.py", line 237, in modify_epub
AttributeError: 'NoneType' object has no attribute 'close'

Reproduce steps

Clicking on the WordDumb symbol -> Create Word Wise.

(I did not have the spaCy POS selected, but I think one gets the error in both cases.)

Screenshots or videos

No response

xxyzz commented 1 year ago

I forgot to check mediawiki is not None, https://github.com/xxyzz/WordDumb/commit/23ae93a71f25c096069d8970c7e601d8cc08c101 fixes the error. Thanks!

Vuizur commented 1 year ago

Awesome, thanks!