Open simonbcn opened 8 months ago
Have you renamed it to hola-proxy.exe ?
Have you renamed it to hola-proxy.exe ?
It's on Linux, not Windows.
Have you renamed it to hola-proxy.exe ?
It's on Linux, not Windows.
Apologies missed that part...
Shutil just checks if the program can be called, which means that it works for both current working directory (freevine) and system PATH. The name of the file should be hola-proxy
in order to be easily found on any system. If you're on linux, you'll also need to make the file executable with chmod +x
. I assume you know this already, but it's worth mentioning anyway.
Shutil just checks if the program can be called, which means that it works for both current working directory (freevine) and system PATH.
Sorry, but this is not true. See the python info about this command: https://docs.python.org/3/library/shutil.html#shutil.which
$ python
Python 3.11.7 (main, Dec 8 2023, 08:53:52) [GCC 13.2.1 20231110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, shutil
>>> shutil.which('hola-proxy')
>>> shutil.which('python')
'/usr/bin/python'
>>> os.getcwd()
'/multimedia2/scripts-descarga/freevine'
>>> os.environ
environ({'PWD': '/home/juan/scripts-descarga/freevine', 'MANPAGER': "sh -c 'col -bx | bat -l man -p'", 'LC_TIME': 'da_DK.UTF-8', 'LC_PAPER': 'da_DK.UTF-8', 'LC_IDENTIFICATION': 'da_DK.UTF-8', 'LC_TELEPHONE': 'da_DK.UTF-8', 'LC_ADDRESS': 'da_DK.UTF-8', 'LANG': 'es_ES.UTF-8', 'XDG_RUNTIME_DIR': '/run/user/1000', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'MANROFFOPT': '-c', 'SSH_CONNECTION': '192.168.1.5 49298 192.168.1.3 22', 'SHLVL': '1', '_tide_color_separator_same_color': '\x1b[38;5;246m', 'PATH': '/home/juan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl', 'USER': 'juan', 'SUDO_EDITOR': 'micro', 'LOGNAME': 'juan', 'EDITOR': 'micro', 'QT_QPA_PLATFORMTHEME': 'qt5ct', 'SHELL': '/bin/fish', '_tide_location_color': '\x1b[38;5;76m', 'XDG_SESSION_ID': '5', 'LC_MONETARY': 'da_DK.UTF-8', 'SSH_CLIENT': '192.168.1.5 49298 22', 'XDG_SESSION_CLASS': 'user', 'MAIL': '/var/spool/mail/juan', 'HOME': '/home/juan', 'SSH_TTY': '/dev/pts/1', 'MICRO_TRUECOLOR': '1', 'TERM': 'xterm-256color', 'LC_MEASUREMENT': 'da_DK.UTF-8', 'XDG_SESSION_TYPE': 'tty', 'VIRTUAL_ENV_DISABLE_PROMPT': '1', 'MOTD_SHOWN': 'pam', 'LC_NAME': 'da_DK.UTF-8', 'LC_NUMERIC': 'da_DK.UTF-8'})
$ file hola-proxy
hola-proxy: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=BteXhjX4jNL3_rcjY9GX/MKdJONoPUcMo-m0swW50/qQpT_KaNqYJDUq_j4qCW/S1JyoTmKgZ7AweL_aNwP,
stripped
$ ls -lh
Permissions Size User Date Modified Name
.rw-r--r-- 2,2k 1000 3 feb 10:21 config.yaml
.rw-r--r-- 238 1000 3 feb 09:41 freevine.py
.rwxr-xr-x 10M 1000 26 dec 2023 hola-proxy
.rw-r--r-- 1,1k 1000 3 feb 09:41 LICENSE
.rw-r--r-- 6,8k 1000 3 feb 09:41 README.md
.rw-r--r-- 149 1000 3 feb 09:41 requirements.txt
drwxr-xr-x - 1000 3 feb 09:41 services
.rw-r--r-- 627 1000 3 feb 09:41 supportedsites.md
drwxr-xr-x - 1000 3 feb 09:41 update
drwxr-xr-x - 1000 3 feb 10:00 utils
Shutil just checks if the program can be called, which means that it works for both current working directory (freevine) and system PATH.
Sorry, but this is not true. See the python info about this command: https://docs.python.org/3/library/shutil.html#shutil.which
Yes, it's true. But apparently Unix systems can't handle it and do require it to be in PATH. On Windows it works as expected.
>>> shutil.which("hola-proxy")
'.\\hola-proxy.EXE'
But as mentioned in the instructions, having everything in PATH is the recommended method no matter what system you're using. Just put them in the proper place and things should work just fine.
In Windows it works because that OS automatically adds the current directory to the PATH when you try to run something. However in Linux, for security, it does not add anything to PATH automatically. You have to explicitly tell it the path if the executable is not in any of the folders in PATH.
I think a better way to get the path to the executable on any OS would be:
def get_binary(*names: str) -> Path:
for name in names:
path = shutil.which(name)
if path:
return Path(path)
else:
try:
return Path(name).resolve(strict=True)
except:
return None
i use ubuntu with freevine an the workaround i did was add it to the global folder for binaries that is called
sudo cp NameOfBinaryHere /usr/bin/
then chmod +x the binary and freevine can find it by calling it with just the binary name
@BobHasNoSoul I know that, thanks anyway. In any case, the project documentation should be changed to indicate that the executables have to be all accessible in any of the system PATH folders or the function in question is modified (I have already put the solution, it is only 4 lines of code).
By the way, although it is not relevant, yesterday I tried this application to download something from PlutoTV and I think it is very good and very complete. Thanks for your work.
I have downloaded the latest version of
hola-proxy
and put it in the same folder asfreevine.py
, butfreevine
does not find it:The problem is
get_binary
function inutilities.py
.shutil.which
just looks for that program in some of the system's PATH folders but not infreevine
folder.