Closed jwrober closed 6 years ago
I am getting the same issue but for both when I run it as a service and directly. Can't seem to figure out why it won't connect to tvheadend.
/Edit: I managed to resolve this by upgrading pip, python, etc in the virtualenv.
@hirenshah - what version of pip, python, etc are running in the virtualenv? I am running python 2.7
@jwrober - To be honest I wasn't 100% sure about what I was doing, so I've fished out my bash log so you can see what I did:
apt-get install python3-venv
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
python tvhProxy.py
[I GOT ERRORS HERE WHEN INSTALLED REQUIREMENTS & RUNNING TVHPROXY - START AGAIN]
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
pip install python3
pip install --upgrade pip
pip install requests
pip install requests[security]
pip install --upgrade requests
python3 -m venv --upgrade venv
pip install requests
pip install requests[security]
pip install --upgrade pip
pip install -r requirements.txt
[ERRORS AGAIN WHEN INSTALLING REQUIREMENTS]
pip install wheel
[THE ABOVE TO RESOLVE THE ERROR I GOT - UNINSTALL AND REINSTALL STUFF FOR THE SAKE OF IT]
pip check
pip install setuptools --upgrade
pip uninstall requests
pip install requests
pip uninstall -r requirements.txt
pip install -r requirements.txt
reboot
These are my installation steps taken from yours.
sudo apt-get install -y python3 python3-pip python3-gevent python3-flask python3-requests python3-venv
sudo useradd -m tvh -s /bin/bash
sudo su - tvh
nano ~/.profile
[ create entries for TVH_URL and TVH_PROXY environment variables to be picked up by the tvhProxy.py script ]
git clone https://github.com/jkaberg/tvhProxy.git
python3 -m venv venv
. venv/bin/activate
pip3 install setuptools --upgrade
pip3 install wheel
pip3 install -r requirements.txt
python3 tvhProxy.py
Go into Plex and attempt to connect to the tvhProxy service from DVR menu. Everything works great here, no issues running from interactive command line. Able to scan the channels and setup just fine.
CTRL-c
(to break out of the command line running process)
exit
Now as sudoer user, setup the systemd service file
sudo cp /home/tvh/tvhProxy/tvhProxy.service /etc/systemd/system/tvhProxy.service
sudo nano /etc/systemd/system/tvhProxy.service
[ change the ExecStart parameter to python3 ]
[ add User=tvh and Group=tvh to same section ]
[ Change Environment to EnvironmentFile=/home/tvh/.profile]
sudo systemctl daemon-reload
sudo systemctl enable tvhProxy.service
sudo systemctl start tvhProxy.service
Go into Plex and attempt connect to the tvhProxy service from DVR menu. Get error that channels cannot be scanned. Here is excerpt from /var/log/syslog
::ffff:10.0.0.202 - - [2018-02-05 10:39:18] "GET /lineup.json HTTP/1.0" 500 431 0.028337
::ffff:10.0.0.202 - - [2018-02-05 10:39:23] "POST /lineup.post?scan=start&source=Cable HTTP/1.0" 200 134 0.001198
::ffff:10.0.0.202 - - [2018-02-05 10:39:23] "GET /discover.json HTTP/1.0" 200 462 0.002931
::ffff:10.0.0.202 - - [2018-02-05 10:39:23] "GET /lineup_status.json HTTP/1.0" 200 234 0.001568
::ffff:10.0.0.202 - - [2018-02-05 10:40:26] "GET /discover.json HTTP/1.0" 200 462 0.001673
::ffff:10.0.0.202 - - [2018-02-05 10:40:26] "GET /lineup_status.json HTTP/1.0" 200 234 0.001676
::ffff:10.0.0.202 - - [2018-02-05 10:40:26] "GET /discover.json HTTP/1.0" 200 462 0.002455
::ffff:10.0.0.202 - - [2018-02-05 10:40:26] "GET /lineup_status.json HTTP/1.0" 200 234 0.001577
[2018-02-05 10:40:28,409] ERROR in app: Exception on /lineup.json [GET]
Traceback (most recent call last):
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/tvh/tvhProxy/venv/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/tvh/tvhProxy/tvhProxy.py", line 56, in lineup
for c in _get_channels():
TypeError: 'NoneType' object is not iterable
So now with a python3 virtual environment, still not working. Getting pretty much the same error when running as a service.
Only differences I can see is that I still run it using "python" rather than "python3" as it's basically a shortcut to "python3". Also I used "pip" and not "pip3".
I didn't set up any environment variables or change any profiles, and based on the error (it can't connect to Tvheadend) if I was to guess you have a difference in permissions between a manual execution and it running as service. Maybe try removing all the profile and variable stuff?
ok, not sure what I did "different" per se, but got everything working great on a Ubuntu 16.04.03 server with these steps.
sudo apt-get install -y git python python-pip python-gevent python-flask python-requests python-virtualenv
git clone https://github.com/jkaberg/tvhProxy.git
cd tvhProxy
virtualenv venv
. venv/bin/activate
pip install setuptools --upgrade
pip install wheel
pip install -r requirements.txt
Edited the script for my logon details to tvheadend and then followed readme to get the service running. For what ever reason, using environment variables does not work. Need to have everything in the script.
Anyone know how I can do this using the QNAP tvhProxy docker image?
tvhProxy works fine for me when I run it from a command line as shown on the readme. However when I setup the systemd tvhProxy.service file, I get a traceback in the /var/log/syslog file when trying to connect with Plex.
I added two environment directives to the tvhProxy.service file for my environment instead of hacking the actual tvhProxy.py file
where userid, passwd, and x.x.x.x are real in my config and obfuscated here. I have these same environment variables in the tvh user's .profile file as well which are picked up fine during the interactive command line startup/run.
I am running tvheadend and plex on debian 9 tvheadend -- v4.2.5-18~g951777a51 plex -- v1.11.1.4753 (beta channel), same issue on current stable v1.10.1.4602
Ideas?