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

PyTivo Video Manager HME App for pyhme

Discussion in 'Developers Corner' started by jbernardis, Apr 20, 2011.

  1. jcthorne

    jcthorne Active Member

    2,726
    3
    Jan 28, 2002
    Houston
    OK. Thanks, I think. Where do you run those scripts? where is the output shown? I have no idea how to implement most of that, way over my head and a simple copy/paste is not going to run due to the directories all being different from mine. Why is all that necessary just to start pyhme?
     
  2. jcthorne

    jcthorne Active Member

    2,726
    3
    Jan 28, 2002
    Houston
    Running this script from a command line:

    Code:
    `sleep 60`
    cd /usr/local/pythonHME
    /opt/bin/python /usr/local/pythonHME/start.py > /usr/local/pyhme.log 2>&1 &
    yields these results:

    Code:
    : not foundtc/rc.d/startHME.sh: line 1: 
    /usr/syno/etc/rc.d/startHME.sh: cd: line 2: can't cd to /usr/local/pythonHME
    : not foundtc/rc.d/startHME.sh: line 3: 
    pyHME is running but did not read the config file. pyhme.log is a zero length file so it did not capture any output.
     
  3. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    You don't need the tick marks around sleep 60 - thats actually running sleep 60 and then trying to execute its output - which of course is null.

    I don't know why you're getting the other errors, but remove the ticks and try it again
     
  4. jcthorne

    jcthorne Active Member

    2,726
    3
    Jan 28, 2002
    Houston
    running the scripts without the tick marks yields:

    'leep: invalid number '60

    in addtion to the other errors. very strange.

    Using lrhorer's suggestion of using nohup at least lets me start it from a command line and leave it running. Still have no idea why it will not start from the startup script at boot time.

    Took me quite a while to get pytivo running from boot time but it does. pyHME starts but does not read its config.ini file. Since this is a pyHME problem and not a vidmgr problem, I'll go ask for help in that thread and quit hogging this one.

    I really do appreciate the newbee help. What was so easy for me to do in Window is a major learning curve in linux....slowly I am getting there.
     
  5. jcthorne

    jcthorne Active Member

    2,726
    3
    Jan 28, 2002
    Houston
    Thanks, this one at least lets me start it and leave it running.
     
  6. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    The nohup script is what arranges for the code itself to be loaded, detaches the process from its parent, creates the log file, and creates the PID file. This can be run from anywhere, by any process, and as long is as pyHME is not already running, it should work. You will, of course, need to adjust the directory names to match your system.

    The output from the nohup script shows up in two places. The file /var/log/pyHME.log contains the stdout and stderr produced by python when running the start.py script. The /var/run/pyHME.pid file contains the PID of the python process. This can be used to kill or reinitialize the python process. The two following commands should contain the same number when pyHME is running:

    ps -ef | grep start.py
    cat /var/log/pyHME.log

    The startup script is how Debian and Debian derivatives implement dependency based booting. I won't go into the details here, but basically different distribution families handle the init process - the thing that runs all the accessories once the kernel is up and running - in different ways. If your NAS is not Debian based (it doesn't look like it), then the init script will have a different form, but, ignoring the header, the init script I posted demonstates how to implement a script that will allow the user (or another script) to manage the pyHME load by running

    /<directory containing the startup script>/pyHME start | stop | restart

    If your system is not Debian based, it may be quite possible to merge the two scripts into a single script, perhaps implementing the nohup script as a subroutine. It's even possible under Debian, but it may not work too well, because the init scripts do not run under bash when booting.

    Note in general, this can be shortened by creating a symlink to the process in one of the directories pointed to by the $PATH variable, but since init scripts are not usually run by users, this is not usually done for init scripts.
     
  7. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    Hey, I've got a question. Is it posible for HME for Python to deliver a .gif file, specififally an animated .gif file, to the Tivo and for the TiVo to display it properly? It would be kinda neat to have some animated thumbnails.
     
  8. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    jbernardis,

    When you get a chance to peek at the code again, I think it would be a good idea to add a try block around the video listings as well as the thumbnails. The app also locks up if it encounters a broken link to a video file. I got the following response when attempting to enter the "F" directory of the alphabetically grouped links after I had deleted the target for the link to "/RAID/Recordings/First Wives Club, The test (Recorded Sat Apr 09, 2011, MAXHD).mpg"

    Code:
    Traceback (most recent call last):
      File "/usr/lib/python2.6/SocketServer.py", line 560, in process_request_thread
        self.finish_request(request, client_address)
      File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/usr/share/pyhme/start.py", line 141, in __init__
        client_address, server)
      File "/usr/lib/python2.6/SocketServer.py", line 617, in __init__
        self.handle()
      File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
        self.handle_one_request()
      File "/usr/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
        method()
      File "/usr/share/pyhme/start.py", line 232, in do_GET
        self._page(True)
      File "/usr/share/pyhme/start.py", line 186, in _page
        appinst.mainloop()
      File "/usr/share/pyhme/hme.py", line 1134, in mainloop
        while self.active and self.get_event():
      File "/usr/share/pyhme/hme.py", line 1187, in get_event
        handle(keynum, rawcode)
      File "/usr/share/pyhme/vidmgr/__init__.py", line 328, in handle_key_press
        self.handle_key_pressList(keynum, rawcode)
      File "/usr/share/pyhme/vidmgr/__init__.py", line 446, in handle_key_pressList
        self.createListing()
      File "/usr/share/pyhme/vidmgr/__init__.py", line 1349, in createListing
        meta = metadata.basic(fullpath)
      File "/usr/share/pyhme/vidmgr/metadata.py", line 98, in basic
        mtime = os.stat(full_path).st_mtime
    OSError: [Errno 2] No such file or directory: '/usr/share/pyTivo/alphagroup/F/First Wives Club, The test (Recorded Sat Apr 09, 2011, MAXHD).mpg'
    Until then, everyone should be advised they need to delete any broken links caused by deleting, moving, or renaming a video file served by vidmgr, or else the application may lock up when reading a share directory.
     
  9. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    I took a look at the code this morning - no changes yet - and I'm not so sure that a simple try block would suffice. At this point in the code, we've already assumed that the file is present because there is a directory entry for it. Now we find that we can't stat the file - we have to drop the data structure we're in the midst of building. I think I need to stat the file earlier and treat it as if the file were never found in the first place (after writing out an error message of course).

    In the meantime, I have made some changes to the code - nothing has been delivered yet. Among the new changes are:

    - I discovered that I can implement a cleanup method that is the proper place to save the image cache - so I moved the save to there,
    - I added logic to allow folder.txt to hold metadata for a folder. If I find such a file, and if it has a meta item named 'description' (like the video metafile) then this description will be shown on the folder (and share) lists above the thumbnail
    - although I widened the right hand margin in the info screen, I made it customizable via the config file.

    These will all be in the next release, as well as a fix to this broken link issue.
     
  10. reneg

    reneg Member

    699
    0
    Jun 19, 2002
    Feature creep request - Please consider adding the ability to initiate a push of a video from one tivo to another through video manager interface.
     
  11. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    You already can push a video that is managed by pytivo to ANY tivo you have defined from ANY tivo, the same one or otherwise.

    Tivo itself does not support pushing anywhere. You'd have to get the video under pytivo management first.

    I suppose you could have an HME app that can query the tivo NPL, upload a chosen video, and then push it out somewhere else, but that is very different from the app we have today (but not a bad idea for a new app)
     
  12. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    Oh, that's nice.

    Oh, that's nice, too. What are the limits?
     
  13. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    I don't know - what do you think they ought to be?

    Right now, the value is expressed in pixels. Obviously it should be a positive number, so the minimum would be 0, but there should be a maximum value too. How about 50 or 100? ANything higher than that is probably not practical. The default value is 20 (although in the version last released, I was using a value of 15)
     
  14. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    As promised, version 0.6a is now on github. I put try block protection around the stat operation in metadata.basic routine. The action if the file cannot be stat'ed is to simply state that fact in the description field of the metadata. That way, there is an on-screen indication of the problem.

    The full change log for this version:

    - put a try block around the stat operation in metadata.basic to catch broken links and other errors. The action
    is to simply put an error message into the metadata description field
    - made use of the cleanup method as the correct place to save the cache
    - added support for folder/share metadata. If a folder or share has a file named folder.txt (or .meta/folder.txt)
    then the contents will be read as metadata, and any description field that is found will be displayed on the screen
    above the thumbnail
    - added inforightmargin to configuration file - the number of pixels of right margin to leave on the info screen, default=20
     
  15. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    I'll have to take a look, but I would think anything beyond 100 would start to be too much under any circumstances.
     
  16. innocentfreak

    innocentfreak Active Member

    8,950
    3
    Aug 25, 2001
    Florida
    Hmm looks like at least with the latest release, some of my series cover art pulled from theTVDB isn't displaying correctly. Some of the older shows are fine, but it seems the newer images are too large so they are cut off on the screen.

    I haven't been keeping up like I should as far as options. Is there a way to have the image resize so that the full image displays?

    Also it appears some of the images aren't pulling even though they are named folder.jpg. For example Breaking In pulls, but is cut off halfway, yet Breaking Bad doesn't.
     
  17. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    Yeah, looking at it, 100 seems more than plenty to me.

    What does everyone else think?
     
  18. lrhorer

    lrhorer Active Member

    6,924
    0
    Aug 31, 2003
    San...
    I suggest you run the images through an image converter that has a maximum image size setting.

    We went around about this issue a couple of days ago, concerning producing an auto-scale function. My vote was, "definitely not". An acceptable compromize solution to me would be, "only if the image is too large." I'd rather handle all the scaling myself.

    My guess would be there is an error in the image.
     
  19. innocentfreak

    innocentfreak Active Member

    8,950
    3
    Aug 25, 2001
    Florida
    I would agree only if the image is too large. My metadata program automatically pulls the image so I don't want to deal with the hassle of running every image through an image converter.

    Hmm the image displays fine on everything else.
     
  20. jbernardis

    jbernardis New Member

    1,072
    0
    Oct 21, 2003
    Princeton NJ
    I can put image scaling back in if the image is too large. Actually there weren't too many versions released that did any scaling, and they were only available for a few hours somewhere in the flurry of releases a few days ago.

    One fact that everyone needs to know about the versions that did scaling - the image cache I implemented cached the scaled image. This means that unless the jpg file is touched, or unless the image drops off the 100 least recently used images, you will still see the scaled image even though I no longer do scaling. The simplest solution for this is to stop the server, delete the cache (thumbs.cache in the vidmgr directory), and then restart the server.

    This will still be true after I add scaling back in - the cache will have unscaled images, so unless the image drops off or the LRU list or the file is touched, the cache will not change.
     

Share This Page