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

HME for Python

Discussion in 'Developers Corner' started by wmcbrine, Jan 28, 2008.

  1. Aug 6, 2008 #81 of 231
    ebdavison

    ebdavison New Member

    4
    0
    Aug 4, 2008
    Maybe it is my misunderstanding. I do not know the difference between HMO and HME, actually.

    But, I was wanting to implement something like TivoToGo to download shows. Maybe pyTivo is the right solution, I do not know. I did not see this sort of capability in it though.

    And downloads from the Tivo via the web interface are PAINFULLY slow. I mean like 12k - 250k every 30 seconds. A download of a 30 min show (approx 600Mb) has taken 28 hours so far to download 280Mb. This is using a bash script that I cooked up. galleon just quit the download after about 2mb every time I restarted the server.
     
  2. Aug 6, 2008 #82 of 231
    windracer

    windracer joined the 10k club

    11,580
    3
    Jan 3, 2003
    St. Pete, FL
  3. Aug 7, 2008 #83 of 231
    ebdavison

    ebdavison New Member

    4
    0
    Aug 4, 2008
    I see the files but do now know how to download from the git hosting site. I have git installed on my linux box but that is all I know about it. Any pointers?
     
  4. Aug 8, 2008 #84 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    Getting back on topic:

    0.13 -- So as it turns out, version 0.12 (and prior) was already capable of video streaming (to an S3/HD with 9.4). :) This version focuses on improvements to hmeserver.py, allowing you to specify apps to run on the command line, along with other options.
     
  5. Aug 19, 2008 #85 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    I found when using HME Python 0.13 and setting the base path to 'c:/' in windows the Tivo can't find the program's icons. It doesn't prevent the programs from working but no icon is displayed.
     
  6. Aug 19, 2008 #86 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    From the point of view of hmeserver, the icons are just regular files; so, they have to be in the correct location under the basepath (basepath + program name + "icon.png", e.g., "c:/test/icon.png").
     
  7. Aug 19, 2008 #87 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    I found my problem I edited the HMEServer.py file and changed self.basepath = basepath to self.basepath = 'c:/' so I wouldn't need to use the -b option but I didn't notice that you did other checking for the base path so if I use the -b option it does work correctly.
     
  8. Sep 7, 2008 #88 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    hmeserver now separates the app and data roots, to allow keeping icons etc. together with their apps, while having data elsewhere. The new command-line option "--datapath" specifies the data root, while "--basepath" still sets the app root. Files outside of app directories (including those in the app root, which had previously been allowed) are now forbidden unless the datapath is set.

    The initial transparency of a View can now be set via the "transparency" keyword parameter when creating it, instead of being settable only by a call to set_transparency().
     
  9. Sep 8, 2008 #89 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    I never did properly answer the question about Google Apps.

    Indeed, that's what it does:

    So, I'm afraid Google Apps won't work as an HME host. :(
     
  10. Sep 25, 2008 #90 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    Some changes that I found useful now that I'm seriously working with this library (in HME/VLC) -- mainly, config file parsing for the server (which is now called "start.py", although I still expect to refer to it as "hmeserver").
     
  11. Oct 2, 2008 #91 of 231
    noseph

    noseph New Member

    58
    0
    Oct 13, 2003
    MA
    I am a noob to this. I see references that we are able to stream video to a Series 3 with this app. What configuration is required to accomplish this? I have MPG4s on my system under v:\video. How would I access them?
     
  12. Oct 2, 2008 #92 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    No, you want HME/VLC (see my sig below). HME for Python is for developers.
     
  13. Oct 26, 2008 #93 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    I am loading an image like this:

    Code:
    self.screen = View(self ,0, 0, 640, 480,visible=True,parent=self.root)
    
    self.screen.child(0, self.height, self.width, self.height, image='TEST.PNG',visible=True,id=ID_CLIENT+1)
    
    After the image is displayed on the Tivo I overwrite the TEST.PNG file with a new TEST.PNG file that is the same width and height. Can you show me the best way to update that image on the Tivo?

    I am currently using the following code but is there a better way?
    Code:
    Image(self.app,name='TEST.PNG').remove()
    self.screen.child(id=ID_CLIENT+1).remove()
    self.screen.child(0, self.height, self.width, self.height, image='TEST.PNG',visible=True,id=ID_CLIENT+1)
    
     
  14. Oct 26, 2008 #94 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    Here's what I'd do...

    becomes:
    Code:
    self.screen = self.root.child()
    Everything else is the default, so you don't need to specify it.
    could be:
    Code:
    img_view = self.screen.child(image='test.png')
    (Same notation. Actually, wait -- you have self.height as the ypos. Were you planning to do an upwards wipe? Also, height and width aren't standard attributes of an Application instance, so I don't know how you've defined these. But, the rest still applies -- you don't need to specify visible, and you should not specify id.) We'll use the name img_view to keep track of the new view rather than trying to manipulate its id.

    Now, I'm assuming here that you have a reason for wanting the image to be in a child view of self.screen -- namely, that self.screen will have its own resource assigned to it elsewhere -- otherwise, there's no reason to use two views, and both lines could be combined to:
    Code:
    self.screen = self.root.child(image='test.png')
    For that matter, if you're not going to assign a resource to self.root, you could just do this:
    Code:
    self.root.set_image('test.png')
    Note that the "id" parameter is meant for use with the built-in resources. I'd never use it for client-created resources.
    could be (following the above):
    Code:
    img_view.remove_resource()
    img_view.set_image('test.png')
    I see no reason to destroy the old view and create a new one -- you can just assign the new image to the old view -- but if you did want to, it could be done like this:
    Code:
    img_view.remove_resource()
    img_view.remove()
    img_view = self.screen.child(image='test.png')
    There are circumstances in which you'd replace an old view with a new one, but generally that would be for the purpose of doing a transition between them -- fade, wipe, etc.

    And if you really, really need to find a child of self.screen without having given it a name at creation time, you can use the self.screen.children list:
    Code:
    self.screen.children[0].remove()
    (equivalent to img_view.remove() in the above).
     
  15. Oct 26, 2008 #95 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    Thanks for the help, here is a little insight in to what I'm doing. I have a large picture that gets updated frequently that I want to display but Tivo can't display it all as one image so I broke it into 14 images that are 1024 x 240. I add all the images as children to the view so when I scale or scroll the view it moves or scales all the child images at the same time. I paired down my example in my post so it would be easier to understand. I have it working but had a feeling that I wasn't using the API correctly so I thought I would ask for the proper way to do it. Thanks again for the help.

    UPDATE:

    This is the code I am now using to load the images the first time:
    Code:
    self.screen = self.root.child()
    for i in range(1,15):
        self.screen.child(0, self.height*(i-1), self.width, self.height,image="TEST %i.PNG" % i)
    
    And this is the code I am using to update the images:
    Code:
    for i in range(1,15):
        self.screen.children[i-1].remove_resource()
        self.screen.children[i-1].set_image("TEST %i.PNG" % i)
    
    This code works good and it's much easier to read than what I had before. I can move and scale self.screen and all the images will move and scale.
     
  16. Oct 30, 2008 #96 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    This code is from the Color class code found in the hme.py file:
    Code:
       def __init__(self, app, colornum=None):
            if colornum is None:
                colornum = 0xffffffff
            # I set the alpha to full opacity here for the sake of the 
            # simulator.
            colornum |= 0xff000000
            self.colornum = colornum
            if colornum in app.colors:
                Resource.__init__(self, app, app.colors[colornum].id)
            else:
                Resource.__init__(self, app)
                self.put(_CMD_RSRC_ADD_COLOR, 'r', struct.pack('!I', colornum))
                app.colors[colornum] = self
            app.last_color = self
    
    I'm just wondering why the default code disables the alpha value making semi transparent views not work? Using an alpha value in the simulator also works so why disable it?
     
  17. Oct 30, 2008 #97 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    Using an alpha value only works in the simulator. (See the comments just above the code you quoted.) I mask it out so you get the same results in the simulator as on a real TiVo, and so you only have to specify the three color bytes, instead of having to preface every color with an ff (full opacity) for the alpha.

    Semi-transparent views work fine, BTW. You just set the transparency via the "transparency" option when creating the view, or via the set_transparency() method later -- not via a color resource. See the "test" app for an example. This is how it's done wherever you see that effect in an HME app.

    Edit: I just tested this again now, and it's not working the way I remember -- which is to say, alpha in color resources apparently is working now. Perhaps this was a change in a recent TiVo software update. Or perhaps I'm misremembering... the way I remember it, when I was first writing HME for Python, I had the alpha part unused (i.e., set to zero), and everything looked normal on the TiVo, but blank in the simulator.

    I'll revisit this in the next version.
     
  18. Oct 30, 2008 #98 of 231
    Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    I commented out the colornum |= 0xff000000 code and I'm able to create a semi transparent view using an alpha value on both the Tivo HD and simulator.
     
  19. Oct 30, 2008 #99 of 231
    wmcbrine

    wmcbrine Ziphead

    10,369
    22
    Aug 2, 2003
    Yes, as I said, it seems to work now. Thanks for bringing it to my attention.

    BTW, I should point out that, although it's supported, the TiVo really hates transparency. I quote from the HME SDK Developer's Guide:

    This probably doesn't apply to the S3/HD, but it still does on the S2. I'm not sure how this translates to non-image resources, though.
     
  20. Allanon

    Allanon Member

    581
    0
    Nov 2, 2005
    There is an odd problem with this test code:

    Code:
    self.screen = self.root.child()
    
    for i in range(0,10):
        self.screen.child(0, self.height*i, self.width, self.height,image="TEST %i.PNG" % i)
          
    for i in range(0,10):
        self.screen.children[i].remove_resource()
        self.screen.children[i].remove()
    
    The first loop loads all the images without a problem but the second loop stops at the remove_resource() line with a "list index out of range" error when i = 5. Another odd thing is if I set the second loop to stop at 4 so the error doesn't occur then it show that every other image was removed instead of the first 4 images.

    Any idea why this might occur?
     

Share This Page