driscollis / applications_with_wxpython

Code examples for the book, Creating GUI Application with wxPython
https://www.blog.pythonlibrary.org
117 stars 26 forks source link

Chapter 8 - Need error handling code #15

Closed cmcknight closed 5 years ago

cmcknight commented 5 years ago

When I run main.py, the main screen pops up but when I select a folder with mp3s, I get the following crash message:

objc[24603]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffad1bf210) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x10d49ddc8). One of the two will be used. Which one is undefined.
Traceback (most recent call last):
  File "main.py", line 88, in on_open_folder
    self.panel.load_mp3s(dlg.GetPath())
  File "main.py", line 49, in load_mp3s
    mp3_obj = Mp3(id3)
  File "main.py", line 13, in __init__
    self.artist = id3.tag.artist
AttributeError: 'NoneType' object has no attribute 'artist'

mp3s.zip

driscollis commented 5 years ago

Yeah, I only experimented with good Mp3s. I didn't have any bad ones handy. I just uploaded a new version of the code that works with your examples and probably will work with most others. I won't say it is 100% hardened, though.

cmcknight commented 5 years ago

Totally understand that not all corner cases can be caught on an example program. Just re-pulled the code and re-ran it with the following results when launching the app:

Lame tag CRC check failed
main.py:26: DeprecationWarning: Use Tag.getBestDate() instead
  if hasattr(id3.tag, 'best_release_date'):
main.py:28: DeprecationWarning: Use Tag.getBestDate() instead
  id3.tag.best_release_date, type(None)):
main.py:34: DeprecationWarning: Use Tag.getBestDate() instead
  id3.tag.best_release_date.year)

When attempting to edit a selected mp3:

Traceback (most recent call last):
  File "main.py", line 76, in edit_mp3
    with editor.Mp3TagEditorDialog(selection.id3) as dlg:
  File "/Volumes/ProjectDrive/Continuing_Education/Create_GUI_Applications_with_wxPython/applications_with_wxpython/chapter8_mp3_tagger/version_1/editor.py", line 12, in __init__
    self.create_ui()
  File "/Volumes/ProjectDrive/Continuing_Education/Create_GUI_Applications_with_wxPython/applications_with_wxpython/chapter8_mp3_tagger/version_1/editor.py", line 30, in create_ui
    size=size)
TypeError: TextCtrl(): arguments did not match any overloaded call:
  overload 1: too many arguments
  overload 2: argument 'value' has unexpected type 'NoneType'

Also, I have to manually quit Python environment because clicking the application close button on the main screen does not shut down the environment properly.

Environment:

MacOS 10.14.3 Python 3.7.2 (installed via home-brew) Using virtual environment (python3 -m venv ./directory/path/name Activating virtual environment (source ./directory/path/name/bin/activate) Installed via pip: wxPython, sqlalchemy, ObjectListView, eyeD3

Steps to recreate:

  1. Place the mp3s in a folder titled mp3s
  2. Launch app
  3. Select an MP3 to edit
  4. Click the Edit MP3 button
driscollis commented 5 years ago

Interesting. Worked fine on Linux with no issues. I will have to play around with this on my Mac when I get home.

driscollis commented 5 years ago

I take that back. I hadn't quite gotten the default tagging working the way I thought I had. I updated it again and now I can edit on my machine

cmcknight commented 5 years ago

Interesting. When I run it on my Mac but in the terminal window I see deprecation warnings on lines 29, 31, and 37. Although I'm not that interested in MP3 tag editing, I'll leave it as an exercise for someone who is to track down the current eyed3 syntax. :-)

Oddly, it didn't seem to save any of the changes when I clicked the Save button. I'll file that as a separate issue.

driscollis commented 5 years ago

Linux is giving me the deprecation warnings. I will have to play around with this example on another OS then