[mythtv-users] Python Bindings
Michael Watson
michael at thewatsonfamily.id.au
Sun May 27 06:51:35 UTC 2012
On 27/05/2012 4:26 PM, Raymond Wagner wrote:
> On 5/27/2012 01:37, Michael Watson wrote:
>> I am trying to write a python script to cleanly close the frontend. But
>> it appears the python bindings are not functioning correctly (or more
>> likely I am doing something incorrectly)
>>
>> I have (which doesnt work, other than jump to the main menu):
>>
>> from MythTV import MythDB
>> from MythTV import Frontend
>>
>> db = MythDB()
>> frontend = db.getFrontend('tv02')
>> frontend.jump['mainmenu']
>> time.sleep(5)
>> frontend.key.escape
>
> The Key utility keeps a stored list of supported keys, that it queries
> from the frontend it is connected to. Alphanumeric keys are
> automatically accepted, but keys like 'escape' must show up in the
> queried list before it will allow them to be sent. If the key is
> allowed, the call to __getitem__ or __getattr__ returns True. If not,
> it returns False. That list is not queried until needed, which is any
> time you perform one of the following.
>
> >>> repr(frontend.key)
> >>> str(frontend.key)
> >>> frontend.key.list()
> >>> frontend.key['escape']
>
> Note, that does not include the syntax you were using. Either use one
> of the above, wait for the fix to make it into your package system, or
> apply the change yourself directly.
>
> master: http://code.mythtv.org/cgit/mythtv/commit/?id=931fe9c46d
> 0.25: http://code.mythtv.org/cgit/mythtv/commit/?id=e1f349aa05
> 0.24: http://code.mythtv.org/cgit/mythtv/commit/?id=912907942f
>
> Also note, the FEConnection.send() method does not return until it
> receives the next prompt, or hits the 10 second timeout, which ever
> comes first. There should be no need to add those additional sleeps.
Thanks, it works by changing the frontend.key.escape to
frontend.key['escape'] and so forth. I had added the sleeps whilst
trying to get it to work, thinking it may be ignoring to many commands
to quickly. Had not thought of try the keys directly. I thought that at
some point checking the return values from frontend.key.escape and
receiving True, using "print frontend.key.escape" is returning False for
me now.
(The last step in my frontend idle script):
Any idea whether I can query the frontend to see if it is playing music
/ video via AirTunes / AirVideo? A query location returns the frontends
location (obviously), butI dont see any way to query exactly what the
frontend is doing. Would be nice to be able to query in more detail
what the frontend is doing..
Regards
Michael
More information about the mythtv-users
mailing list