jdlorimer / incremental-reading

Anki add-on providing incremental reading features
https://ankiweb.net/shared/info/935264945
ISC License
216 stars 38 forks source link

<class 'TypeError'>: 'NoneType' object is not subscriptable #13

Closed PiotrSss closed 7 years ago

PiotrSss commented 7 years ago

Hi, I'm testing Anki 2.1 and I saw your extension, I wanted to try it, but I'm getting this error on Anki startup:

Caught exception: File "aqt/progress.py", line 65, in handler File "aqt/main.py", line 115, in setupProfile File "aqt/main.py", line 254, in loadProfile File "anki/hooks.py", line 28, in runHook File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/main.py", line 39, in onProfileLoaded self.importer = Importer(mw.settingsManager.settings) File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/importer.py", line 17, in __init__ self.did = mw.col.decks.byName(settings['importDeck'])['id'] <class 'TypeError'>: 'NoneType' object is not subscriptable

Doesn't matter if I install this by pasting code from Anki addons website or by copying 'ir' from github master.

jdlorimer commented 7 years ago

Thanks for testing. I was able to reproduce this when trying to import a webpage. I assume that's what you were doing when you got that error?

I've updated the add-on on GitHub (direct link), which should solve the problem for now.

That said, something different breaks almost every time Damien releases a new beta. Just let me know if you run into anything else. At the moment I'm working to make the add-on compatible with Beta 16, but for now it only works with 13, 14 and 15.

PiotrSss commented 7 years ago

No, it was on Anki (beta 15, OS X) startup after adding 'ir' folder to addons. But it's working now after your last commit :) Adding things manually works fine, but:

  1. When I want to import https webpage (https://www.wired.com/story/physicists-want-to-rebuild-quantum-theory-from-scratch/) I'm getting different error:

Caught exception: File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/importer.py", line 45, in importWebpage webpage = self._fetchWebpage(url) File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/importer.py", line 23, in _fetchWebpage html = urlopen(url).read().decode('utf-8') File "urllib/request.py", line 223, in urlopen File "urllib/request.py", line 526, in open File "urllib/request.py", line 544, in _open File "urllib/request.py", line 504, in _call_chain File "urllib/request.py", line 1361, in https_open File "urllib/request.py", line 1320, in do_open <class 'urllib.error.URLError'>: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>

  1. When I want to import http webpage it's this:

Caught exception: File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/importer.py", line 47, in importWebpage self._createNote(webpage.title.string, body, url) File "/Users/piotr/Library/Application Support/Anki2/addons21/ir/importer.py", line 33, in _createNote did = mw.col.decks.byName(self.settings['importDeck'])['id'] <class 'TypeError'>: 'NoneType' object is not subscriptable

jdlorimer commented 7 years ago

The first error is a Mac-only thing. As a work-around, I've disabled certificate checks on Mac.

I can't reproduce the second error, but I've changed the behaviour so that webpages are imported into whatever is the current deck.

Please try the updated add-on (here) and let me know how it goes.

PiotrSss commented 7 years ago

It's working, thank you :)

jdlorimer commented 7 years ago

Not a problem.