blind-oracle / transmission-trackers

Script to automatically add trackers from a list to all torrents in Transmission
115 stars 28 forks source link

TypeError: expected str, bytes or os.PathLike object, not NoneType #13

Open Yutao-Jin opened 2 years ago

Yutao-Jin commented 2 years ago
image

macserver@MacServer ~ % /Users/macserver/Desktop/transmission-trackers.py

Traceback (most recent call last): File "/Users/macserver/Desktop/transmission-trackers.py", line 54, in cache_file = path.join(env.get('TEMP',env.get('TMP',None)) ,'.cache/trackers.txt') File "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 76, in join a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType

I'm using python 3.9.9 on macOS

S-Riot commented 2 years ago

This error comes up on Unix based systems. Basically, the script is searching for a temporary directory on the system environment settings and, when it doesn't find it, you get that error. On Mac, specifically, go to the terminal and type: env TMP or env TEMP if those variables are not present you will receive the following message or similiar: env: TMP: No such file or directory In this case, you have to add a permanent enviromental variable. In order to do this, open a terminal window and type nano .bash_profile at the end of the file, add: export TMP=/tmp save and close the file, it's advisable to restart the computer. This should solve the problem above. In my case, just to let you know, I was working with UBUNTU 20.10 and after that, I had to tweak the permissons on the directory that is created by the python script inside the temporary directory.

trotskylenin commented 2 years ago

Same issue here. I replaced None by '' and it worked. The issue is not that TMP is not an environment variable in Unix systems, because that should be handled properly if the path is not found. The issue is that None is not a valid value type for the second parameter of env.get

trotskylenin commented 2 years ago

Go to Case 6 in this url and you will see proper usage: https://www.geeksforgeeks.org/python-os-environ-object/?ref=gcse

trotskylenin commented 2 years ago

I've just proposed a pull request to fix this.