openpyn-nordvpn
openpyn-nordvpn copied to clipboard
shutil.which("openpyn") Failing with None
I have installed openpyn in my anaconda envrionment as I normally use that for all my python dependencies (and don't install system python from apt/yum/etc.)
I ran:
$ apt install openvpn
$ pip install openpyn
And it worked. Then I tried:
$ openpyn --init
2022-01-11 00:12:33 [ERROR] Option '--init' requires sudo access. run 'sudo openpyn --init' instead.
and it forced me to use sudo. So, I did:
$ sudo openpyn --init
sudo: openpyn: command not found
Now, because I don't add anaconda to my root path ... it gave an error that openpyn not found. So, I tried:
$ sudo /home/abdealijk/python37/bin/openpyn --init
Downloading ovpn.zip: 100%|█████████████████████| 24.1M/24.1M [00:04<00:00, 5.70MB/s]
Extracting ovpn.zip: 100%|██████████████████████| 30.0M/30.0M [00:01<00:00, 23.4MB/s]
2022-01-11 00:10:25 [INFO] Storing credentials in '/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/credentials' with openvpn compatible 'auth-user-pass' file format
Enter your username for NordVPN, i.e [email protected]:
Enter the password for NordVPN:
2022-01-11 00:10:37 [INFO] Awesome, the credentials have been saved in '/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/credentials'
Enter Openpyn options to be stored in systemd service file (/etc/systemd/system/openpyn.service, Default(Just Press Enter) is, uk :
Traceback (most recent call last):
File "/home/abdealijk/python37/bin/openpyn", line 8, in <module>
sys.exit(main())
File "/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/openpyn.py", line 187, in main
args.show_status, args.show_stats)
File "/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/openpyn.py", line 299, in run
initialise(detected_os, asuswrt_os, openwrt_os)
File "/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/openpyn.py", line 677, in initialise
systemd.install_service()
File "/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/systemd.py", line 26, in install_service
update_service(openpyn_options)
File "/home/abdealijk/python37/lib/python3.7/site-packages/openpyn/systemd.py", line 57, in update_service
+ "\nStandardOutput=syslog\nStandardError=syslog\n[Install]\nWantedBy=multi-user.target\n"
TypeError: can only concatenate str (not "NoneType") to str
I did a bit of debugging and it looks like in openpyn/systemd.py
it does openpyn_location = shutil.which("openpyn")
- which is returning None. Causing a None+str concatenation.
Would be great if this detection could be improved in some way.
Maybe sys.argv[0]
could be a backup in case shutil.which()
is unable to find the path.
The workaround that I did:
$ sudo su
$ export PATH="$PATH:/home/abdealijk/python37/bin/"
$ openpyn --init