[mythtv] Using the python bindings
Ian Barton
lists at manor-farm.org
Tue Mar 11 19:03:55 UTC 2008
Thanks to both of you. Both:
from MythTV import MythTV
mythtv = MythTV
and
import MythTV
mythtv = MythTV.MythTV()
work correctly. I hadn't realised that you had to import classes
explicitly from modules. Time for a bit more RTFM.
Ian.
> In the second sample, you are only importing the 'module' MythTV, but
> not the class.. In the first, you're importing the MythDB class from
> the MythTV module..
>
> You could do (I know nothing about the myth python bindings, the code
> may be incorrect..):
>
> try:
> import MythTV
> mythtv = MythTV.MythTV()
> except:
> print "can't be initialized"
>
>
>
> On Mar 11, 2008, at 5:39 AM, Ian Barton wrote:
>
>> I have written a jabber bot to return various bits of info about my
>> backend. It has been suggested that I should use the python bindings,
>> rather than try to access the database directly.
>>
>> Can someone provide me with a bit of code that shows how to create an
>> instance of the MyhtTV class? This is my first python program, so
>> please
>> excuse my stupidity:)
>>
>> If I write something like:
>>
>> try:
>> from MythTV import MythDB
>> mythdb = MythDB()
>>
>> except:
>> print "MythDB module cannot be initialized"
>>
>> that works fine. However,
>>
>> try:
>> import MythTV
>> mythtv = MythTV()
>>
>> except:
>> print "MythTV module cannot be initialized"
>>
>> throws an exception.
>>
>> Ian.
>
More information about the mythtv-dev
mailing list