datashaman / putio-automator

A suite of commands for managing torrents, transfers and files on put.io. Works well with SickRage, Sonarr, etc.
MIT License
70 stars 17 forks source link

AttributeError: 'NoneType' object has no attribute 'loader' #42

Closed mtauberjr closed 3 years ago

mtauberjr commented 3 years ago

putio config init Traceback (most recent call last): File "/home/mtauberjr/.local/bin/putio", line 5, in from putio_automator.cli import main File "/home/mtauberjr/.local/lib/python3.9/site-packages/putio_automator/cli.py", line 16, in config = importlib.util.module_from_spec(spec) File "", line 562, in module_from_spec AttributeError: 'NoneType' object has no attribute 'loader'

datashaman commented 3 years ago

please tell me a bit more about your operating system.

q3k commented 3 years ago

Same problem here on NixOS (both Py3.8 and Py3.9).

What is the expected behaviour from the following snippet when there's no config.py in any of the locations defined in find_config?

config_file = find_config()
spec = importlib.util.spec_from_file_location('config', config_file)
config = importlib.util.module_from_spec(spec)
spec.loader.exec_module(config)

In my case, config_file is None (because there's no config.py in any of the expected locations), and so is spec. Passing None to module_from_spec raises the aforementioned AttributeError.

q3k commented 3 years ago

(if I copy etc/config.py.dist to ~/.local/share/putio-automator/config.py I can then do putio config init which then writes the config file correctly)

datashaman commented 3 years ago

I've duplicated this in a docker container. On it.