quodlibet icon indicating copy to clipboard operation
quodlibet copied to clipboard

All exports fail using the Import / Export plugin: module 'os' has no attribute 'pathconf'

Open MoonlitMonitor opened this issue 1 year ago • 3 comments

Steps to reproduce

I tried to "Export User Data" for the tracks in my library so that I could perform analysis on the resulting JSON using Python to find which genres are rated the highest.

Expected Output

The user data for the tracks should be exported to a JSON file.

Actual Output

After pressing "Run Plugin", I received a prompt saying that "An Error Occurred":

AttributeError: module 'os' has no attribute 'pathconf'
------
Traceback (most recent call last):

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\qltk\songsmenu.py", line 243, in __handle
    ret = plugin.plugin_albums(albums)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\ext\songsmenu\import_export_tags_and_track_user_data.py", line 357, in plugin_albums
    self.export_albums(albums, collect_data)

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\ext\songsmenu\import_export_tags_and_track_user_data.py", line 599, in export_albums
    self.extract_data_and_export(songs, collect_data)

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\ext\songsmenu\import_export_tags_and_track_user_data.py", line 611, in extract_data_and_export
    path = new_export_path_for_album(album_id) if prev_path is None else prev_path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\ext\songsmenu\import_export_tags_and_track_user_data.py", line 713, in new_export_path_for_album
    path = Path(join_path_with_escaped_name_of_legal_length(str(EXPORT_DIR_PATH), stem,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Program Files\Quod Libet\lib\python3.11\site-packages\quodlibet\util\path.py", line 144, in join_path_with_escaped_name_of_legal_length
    # returns the maximum possible filename length at path (subtract one for dot)
                      ^^^^^^^^^^^

AttributeError: module 'os' has no attribute 'pathconf'

Test System

Which version of Quod Libet?

4.6.0

Which operating system

Windows 11

MoonlitMonitor avatar Sep 08 '24 00:09 MoonlitMonitor

As a workaround for exporting the data for the tracks in my library for further analysis, I used the "Export to HTML" plugin instead. The format is not ideal but I can still work with it.

MoonlitMonitor avatar Sep 08 '24 00:09 MoonlitMonitor

Odds are that chunk of code only supports unix systems. os.pathconf is only available on unix according to the python docs.

Spidey01 avatar Sep 10 '24 22:09 Spidey01

Yes, it's unix only. MAX_PATH on Windows wasn't configurable and was always 260 (effectively 256). Since W10 1607, there is now an option to enable long paths, pretty much removing any limit, the filesystem itself can handle names up to 32000 characters long. Problem is that it's not default, needs to be enable in both the system and application manifest and not all system functions work with long paths yet, so hard-coding a limit of 256 on Windows is still a safe bet.

khagaroth avatar Sep 16 '24 11:09 khagaroth