[mythtv-users] How to check if a tuner is in use

Hika van den Hoven hikavdh at gmail.com
Wed Oct 15 20:10:34 UTC 2014


Hoi Bill,

Wednesday, October 15, 2014, 9:45:50 PM, you wrote:

> On 10/15/2014 02:11 PM, Hika van den Hoven wrote:
> ...
>> parser.add_argument('--host', type=str, required=False, metavar='<hostname>',
>>      help='backend hostname,  default <local hostname>')

> You could just add: default='localhost' to the above. Or,
> leave required=True and on the command line type --host=localhost
> or whatever you choose.

Ah, but I need the 'local hostname' not 'localhost'! That's what
Mythtv uses. Unless you only have one combined machine.

>> URL='http://{}:6544/Dvr/GetEncoderList'.format(host)

> Try the URL developed above (e.g. with your hostname
> where {} is), from a browser to see everything that's
> returned. And there's a lot. E.g. <DisplayName>ATSC-0</DisplayName>
> could be used assuming your cards have unique names.

>> try:
>>          request = 'SELECT `cardid` FROM `capturecard` WHERE `videodevice` = "%s" AND `hostname` = "%s"' \
>>                                  % (card, host)
>>          c = DB.cursor()
>>          c.execute(request)
>>          if c.rowcount == 1:
>>                  for row in c.fetchall():
>>                          cardid = str(row[0])

> One intent of the Services API is to avoid direct access to the
> MythTV DB. I thought that was the intent of the bindings too.
> I'd strive to get rid of the code above.

I'm running 0.27.3 from gentoo, but all I get per encoder on that page
is:
    <Id>1</Id>
    <HostName>GentooServer</HostName>
    <Local>true</Local>
    <Connected>true</Connected>
    <State>7</State>
    <SleepStatus>8</SleepStatus>
    <LowOnFreeSpace>false</LowOnFreeSpace>
and then a lot of info about the recording but no 'Inputs/Input'? So I
see no other way to retrieve it.

>>                          try:
>>                                  response = ET.parse(urlopen(URL))
>>                          except:
>>                                  raise SystemExit('GetEncoderList failed, is the backend running?')
>>                          for element in response.findall('Encoders/Encoder'):
>>                                  if element.findtext('Id') == cardid:
>>                                          print '%s' % (element.findtext('State'))
>                                             break


> Added the break above because once you've found the
> card if interest, there's no reason to keep looking.

Thanks, what I would do in bash or VB. 

> To answer your other question. Yes, import sys and then
> if the script fails, use: sys.exit(2), when the card is
> idle, sys.exit(0) otherwise 1 etc.

Can I return the state? Like:
    state = element.findtext('State')
    sys.exit(state)
or even:
    sys.exit(element.findtext('State'))


Tot mails,
  Hika                            mailto:hikavdh at gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens



More information about the mythtv-users mailing list