jdlorimer / chinese-support-redux

Anki add-on providing support for Chinese study
https://ankiweb.net/shared/info/1128979221
GNU General Public License v3.0
101 stars 50 forks source link

'NoneType' object has no attribute 'group' #25

Closed fultonm closed 5 years ago

fultonm commented 5 years ago

Describe the bug Error occurs when editing an existing card or adding a new card using Chinese Support Redux add-on.

To Reproduce Steps to reproduce the behavior:

  1. Edit an existing card or
  2. Add a new card

Expected behavior Fields are populated as expected

Screenshots

Error 
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Mac 10.14.1
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 80, in _onCmd
  File "aqt/webview.py", line 333, in _onBridgeCmd
  File "aqt/editor.py", line 268, in onBridgeCmd
  File "anki/hooks.py", line 34, in runFilter
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/edit.py", line 74, in onFocusLost
    if updateFields(note, field, allFields):
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 469, in updateFields
    update_all_Sound_fields(hanzi, fieldsCopy)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 350, in update_all_Sound_fields
    updated1, errors1 = update_Sound_fields(hanzi, d)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/behavior.py", line 315, in update_Sound_fields
    s = sound(hanzi)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/sound.py", line 54, in sound
    return '[sound:%s]' % download_sound(hanzi, options[source])
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
    tts.save(path)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 247, in save
    self.write_to_fp(f)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 187, in write_to_fp
    part_tk = self.token.calculate_token(part)
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "/Users/m/Library/Application Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line 57, in _get_token_key
    tkk_expr = re.search(".*?(TKK=.*?;)W.*?", line).group(1)
<class 'AttributeError'>: 'NoneType' object has no attribute 'group'

**Specs (please complete the following information):**
 - OS: [e.g. Windows, iOS, Ubuntu]
 - Anki Version [e.g. v2.0.52, v2.1.5]
- Chinese Support Version [e.g. v0.5.3-beta]

Additional context Add any other context about the problem here.

fultonm commented 5 years ago

I want to try my hand at fixing this issue in the coming days unless someone gets to it first. Just wanted to document this frequently-recurring error.

jdlorimer commented 5 years ago

I'll have a look at this tonight. The traceback indicates the error is in the gTTS library, not the add-on as such.

On 30 November 2018 4:11:22 am ACST, Michael Fulton notifications@github.com wrote:

Describe the bug Error occurs when editing an existing card or adding a new card using Chinese Support Redux add-on.

To Reproduce Steps to reproduce the behavior:

  1. Edit an existing card or
  2. Add a new card

Expected behavior Fields are populated as expected

Screenshots

Error 
An error occurred. Please start Anki while holding down the shift key,
which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the
Tools>Add-ons menu item to disable some add-ons and restart Anki,
repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please
report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Mac 10.14.1
Flags: frz=True ao=True sv=1

Caught exception:
 File "aqt/webview.py", line 27, in cmd
 File "aqt/webview.py", line 80, in _onCmd
 File "aqt/webview.py", line 333, in _onBridgeCmd
 File "aqt/editor.py", line 268, in onBridgeCmd
 File "anki/hooks.py", line 34, in runFilter
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/edit.py", line 74, in onFocusLost
   if updateFields(note, field, allFields):
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/behavior.py", line 469, in
updateFields
   update_all_Sound_fields(hanzi, fieldsCopy)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/behavior.py", line 350, in
update_all_Sound_fields
   updated1, errors1 = update_Sound_fields(hanzi, d)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/behavior.py", line 315, in
update_Sound_fields
   s = sound(hanzi)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/sound.py", line 54, in sound
   return '[sound:%s]' % download_sound(hanzi, options[source])
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/tts.py", line 35, in download_sound
   tts.save(path)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 247, in save
   self.write_to_fp(f)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/lib/gtts/tts.py", line 187, in
write_to_fp
   part_tk = self.token.calculate_token(part)
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line
28, in calculate_token
   seed = self._get_token_key()
File "/Users/m/Library/Application
Support/Anki2/addons21/1128979221/lib/gtts_token/gtts_token.py", line
57, in _get_token_key
   tkk_expr = re.search(".*?(TKK=.*?;)W.*?", line).group(1)
<class 'AttributeError'>: 'NoneType' object has no attribute 'group'

**Specs (please complete the following information):**
- OS: [e.g. Windows, iOS, Ubuntu]
- Anki Version [e.g. v2.0.52, v2.1.5]
- Chinese Support Version [e.g. v0.5.3-beta]

Additional context Add any other context about the problem here.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/luoliyan/chinese-support-redux/issues/25

jdlorimer commented 5 years ago

Libraries have been updated. Problem should be fixed now.