1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running pyTivo on a QNAP

Discussion in 'Developers Corner' started by hmspain, Nov 9, 2017.

Tags:
  1. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    It runs “kinda”... at least it does not abort, but here is the dialog (HOPING someone can see what I’m missing). Prepare for an eye chart...

    File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 158, in do_command method(self, query) File "/share/CACHEDEV1_DATA/pyTivo/plugins/video/video.py", line 481, in QueryContainer t = Template(XML_CONTAINER_TEMPLATE, filter=EncodeUnicode) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1192, in __init__ self._compile(source, file, compilerSettings=compilerSettings) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1480, in _compile keepRefToGeneratedCode=True) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 754, in compile mod = new.module(uniqueModuleName) NameError: name 'new' is not defined ERROR:pyTivo:Exception during request from ('192.168.1.131', 47190) Traceback (most recent call last): File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 593, in process_request_thread File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 334, in finish_request File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 91, in __init__ client_address, server) File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 649, in __init__ File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/BaseHTTPServer.py", line 340, in handle File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 126, in do_GET self.handle_query(query, tsn) File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 173, in handle_query self.root_container() File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 320, in root_container filter=EncodeUnicode) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1192, in __init__ self._compile(source, file, compilerSettings=compilerSettings) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1480, in _compile keepRefToGeneratedCode=True) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 754, in compile mod = new.module(uniqueModuleName) NameError: name 'new' is not defined ERROR:pyTivo:Exception during request from ('192.168.1.131', 47191) Traceback (most recent call last): File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 593, in process_request_thread File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 334, in finish_request File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 91, in __init__ client_address, server) File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/SocketServer.py", line 649, in __init__ File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/BaseHTTPServer.py", line 340, in handle File "/root/daily_build/64_23/4.3.3/SysUtil/Python-2.7.5-cross/install_path_full/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 126, in do_GET self.handle_query(query, tsn) File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 173, in handle_query self.root_container() File "/share/CACHEDEV1_DATA/pyTivo/httpserver.py", line 320, in root_container filter=EncodeUnicode) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1192, in __init__ self._compile(source, file, compilerSettings=compilerSettings) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 1480, in _compile keepRefToGeneratedCode=True) File "/share/CACHEDEV1_DATA/pyTivo/Cheetah/Template.py", line 754, in compile mod = new.module(uniqueModuleName)
    NameError: name 'new' is not defined

    The smoking gun appears to be the “name ‘new’ is not defined. It can’t find the new module because it was replaced by the types module, and somehow the new module is not in this version of 2.7.
     
  2. Dan203

    Dan203 Super Moderator Staff Member TCF Club

    41,343
    1,501
    Apr 17, 2000
    Nevada
    Can you run pip on the NAS? Maybe you can install the new module that way?
     
  3. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    Good thought Dan203, but unfortunately pip is an unknown command. I worked around the problem using a Rpi and Samba mounting the share from my QNAP.

    I would still ike to get pyTivo running on the QNAP directly... I just wanted to both thank everyone for the awesome help, and let you know I’m up and running albiet slowly :).
     
  4. Rowan

    Rowan Member

    35
    0
    Jun 29, 2000
    Carrollton, TX
    I have had pyTivo running on my QNAP NAS for a few years now. I have been meaning to update the code to use the new code that Dan has and modify the tray program to talk to the NAS instead of the local pyTivo.

    The steps I took to install it are:

    • Install Python 2.7.3 package
    • Install Qffmpeg (more about this later)
    • Install my pyTivo.qpkg
    • Setup the correct paths to movies, music pictures shared folders and set the ffmpeg setting to point to the version thta you just installed. I use: /opt/Qffmpeg/bin/ffmpeg
    There are a few Qnap programs that have ffmpeg included but they are all not complied correctly and do not support the features that tyTivo requires. To download the package visit this site: Qnapclub Store: ffmpeg there are lots of versions and the latest ones are for the latest QNAP OS that my older QNAP (TS-259) does not support, so you have to click on the "older versions" tab and select the proper version for the type of NAS you have. You can then download the .qpkg file and install it.

    Here is a link to the pyTivo_0.3.qpkg that I created:

    If anyone wants the source for the qpkg I can zip it up. To build it you need to have the QDK package installed

    There is a small issue that sometimes pops up and that is during some OS upgrades/reboots the python program does not always start backup correctly. I just log into the NAS and then open the pyTivo app and at the menu select "restart pyTivo" and it is back up and running again.


    Rowan
     
  5. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    Thank you SO much! I had to try this right away.

    I'm running Python 2.7.12.1 (the latest on the 2 branch I guess). If I downgrade Python, the QNAP continues to whine about it being out of date. I tried downgrading it once when I was using my own pyTivo files; no luck.

    The best ffmpeg for my QNAP TVS-871 (64-bit) appears to be the latest 3.4.0 64 bit. The site says it was tested with with 4.2.1 (I'm running 4.3.3). I installed it no problem.

    I then installed the 0.3 pyTivo package and started it. I can't see a process using "ps -ef | grep -i pytivo", and can't connect to port 9032 using a browser.

    Any ideas?
     
  6. wmcbrine

    wmcbrine Ziphead

    10,602
    121
    Aug 2, 2003
    You keep saying this, but your own /usr/bin/env python results say 2.7.5. That's what you're running, at least as far as pyTivo's concerned. NOT 2.7.12.1. And your missing "new" module indicates, further, that it's a broken installation.
     
  7. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    Good point. I installed the QNAP version of the 2 branch which says 2.7.12.1, but it appears to be 2.7.5 and broken as you say. Is there someplace elese I can go to find the 2 branch Python for QNAP?
     
  8. Rowan

    Rowan Member

    35
    0
    Jun 29, 2000
    Carrollton, TX
    I guss one thing I forgot to tell you is the application does not auto start so you will have to tell it to start but I think you already did that.

    since you have a shell to the box change into the pyTivo qpkg directory, should be: /share/MD0_DATA/.qpkg/pyTivo
    This is the place that the the package is installed to, then look at the file pyTivo.sh this is what the QNAP OS calls to control this application.

    The start part looks like this:

    # make web link here
    /bin/ln -sf ${QPKG_DIR}/$QPKG_NAME /share/${APACHE_ROOT}/$QPKG_NAME

    #echo "Starting pyTivo server" >> /tmp/pyTivo.log
    PID=`cat /tmp/pyTivo.pid`
    if [ -n "$PID" ]
    then
    #echo "Killing [$PID]" >> /tmp/pyTivo.log
    kill $PID
    sleep 2
    rm -f /tmp/pyTivo.pid
    fi

    cd $QPKG_DIR
    /usr/bin/python $QPKG_DIR/pyTivo.py &
    echo "$!" > /tmp/pyTivo.pid

    The web link and for the control in the qnap app software and just redirects to the pyTivo UX, so you can skip that for now. I then check to see if the program is running, if so I kill the currently running copy. I then start up a new copy so try manually starting it by typing in: /usr/bin/python pyTivo.py
    If there are any errors they will show up on the console. Could be your python is not in the usr/bin directory?

    You can modify the files in this directory as you see fit and then will not get changed unless you stop or uninstall the application
     
  9. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    /usr/bin/python says no such file, but plain "python" runs 2.7.5 (I can change the pyTivo.sh file I suppose).

    cd to ... /share/CACHEDEV1_DATA/.qpkg/pyTivo

    and ... python ./pyTivo.py

    gives me:

    [/share/CACHEDEV1_DATA/.qpkg/pyTivo] # python ./pyTivo.py
    Traceback (most recent call last):
    File "./pyTivo.py", line 21, in <module>
    import httpserver
    File "/share/CACHEDEV1_DATA/.qpkg/pyTivo/httpserver.py", line 16, in <module>
    from Cheetah.Template import Template
    File "/share/CACHEDEV1_DATA/.qpkg/pyTivo/Cheetah/Template.py", line 23, in <module>
    import new # used to bind methods and create dummy modules
    ImportError: No module named new
    [/share/CACHEDEV1_DATA/.qpkg/pyTivo] #
     
  10. Rowan

    Rowan Member

    35
    0
    Jun 29, 2000
    Carrollton, TX
    looks like you do not have a good install of python
     
  11. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    It looks that way. The missing “new” module is a red flag I think.

    I used the 2 branch QNAP install for Python. Is there another way?
     
  12. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    On the theory that my Python install is corrupt, I uninstalled the QNAP "native" version of Phython 2, and installed Python 2 (64-bit) from the Qnapclub Store. It is branch 2, appears to be 2.7.14.0.

    /usr/bin/python ... "No such file"

    python = 2.7.5
     
  13. Rowan

    Rowan Member

    35
    0
    Jun 29, 2000
    Carrollton, TX
    If you installed python from a the Qnapclub store then it will be installed under the .qpkg directory, find it and the binary, then use that path instead of /usr/bin
     
  14. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    Sorry, got all excited and replied via Email...

    Thank you for sticking with me!

    Getting real explicit on the python location, and the pyTivo location;

    /share/CACHEDEV1_DATA/.qpkg/QPython2/bin/python /share/CACHEDEV1_DATA/.qpkg/pyTivo/pyTivo.py

    and configuring it... it RUNS!
     
  15. Rowan

    Rowan Member

    35
    0
    Jun 29, 2000
    Carrollton, TX
    Great to just change the python path in the pyTivo.sh file and then you are all set.
     
  16. hmspain

    hmspain Member

    39
    1
    Oct 11, 2015
    Yup, for once ahead of ya :). The command line explcitly points to the QNAP Python, and the QNAP pyTivo.

    Works a treat!
     

Share This Page