nstrydom2 / anonfile-api

An unofficial Python Anonfiles.com API
MIT License
62 stars 24 forks source link

not working with FreeBSD #83

Closed alma359 closed 1 year ago

alma359 commented 1 year ago

Running the command anonfile --help on FreeBSD gives the following error message:

Traceback (most recent call last):
  File "/usr/local/bin/anonfile", line 5, in <module>
    from anonfile.__init__ import main
  File "/usr/local/lib/python3.8/site-packages/anonfile/__init__.py", line 12, in <module>
    from .anonfile import *
  File "/usr/local/lib/python3.8/site-packages/anonfile/anonfile.py", line 84, in <module>
    file_handler = logging.FileHandler(get_logfile_path())
  File "/usr/local/lib/python3.8/site-packages/anonfile/anonfile.py", line 75, in get_logfile_path
    config_dir = get_config_dir()
  File "/usr/local/lib/python3.8/site-packages/anonfile/anonfile.py", line 65, in get_config_dir
    return {
KeyError: 'FreeBSD'
nstrydom2 commented 1 year ago

I'm pretty sure I know what caused this error. Thank you for bringing it to my attention! I'll look into it tonight.

nstrydom2 commented 1 year ago

This is caused by a lack of support for 'FreeBSD' based operating systems. However, this shouldn't effect functionality. I will patch this issue before the end of the day.

StefanGreve commented 1 year ago

However, this shouldn't affect functionality

I am not sure about that, the logger configuration on line 84 should be still invoked when you import this library on a FreeBSD system (which is dependent on the function you identified), so it's definitely a critical error for these users as it prevents them from using this library in any shape or form.

Maybe you can add a fallback value that can be used as a platform-neutral location to prevent similar errors from taking place in the future (though one could still argue that failing silently is dangerous as a concept, but I don't think it's important enough to make this library stop working altogether).

nstrydom2 commented 1 year ago

Yes, @StefanGreve is correct. The logger configuration is loaded during logger initialization. As a result, when accessing the default location, we encounter a 'KeyError' type error. This issue renders the library ineffective for users with different operating systems, which is inconvenient. However, I am currently working on a fix and will push it soon.

We should consider testing the library in different environments to address these issues.

StefanGreve commented 1 year ago

We should consider testing the library in different environments to address these issues.

Compare PR #86. According to the docs there are no runners with FreeBSD hosts, but testing for the big 3 platforms should provide sufficient coverage. The vast majority of the code is platform independent, so as long as Python can run, so should this package (with the next release).