[mythtv-users] Python3 interface: Could not find setting 'BackendServerAddr' on host '192.168.1.10'

Bill Meek keemllib at gmail.com
Mon Feb 24 00:56:03 UTC 2020


On 2/23/20 6:15 PM, Ross Boylan wrote:
> Running mythtv 30 with fixes + the python3 code from https://github.com/rcrdnalor/mythtv, develop/python3. I gather that code has been merged 
> into Myth v31.
> I have no idea if my problem is specific to these version, as I've made no serious use of the python interface before.
> 
> I did a --user install of the libraries (and added that location to sys.path).  It seems there are actually 2 interfaces, one based fairly 
> directly on the Services API and one in a more pythonic style.  It's the latter I'm trying to use.
> 
> db=MythTV.MythDB()  # I can startup the frontend from this account, and I assume MythDB() gets info from my config
> bb=db.searchRecorded(title="Blue Bloods")
> a = next(bb)
> # various queries of a
> a.delete()
> ---------------------------------------------------------------------------
> MythDBError                               Traceback (most recent call last)
> <ipython-input-42-adfa98f44cbd> in <module>()
> ----> 1 a.delete()
> 
> /home/ross/.local/lib/python3.7/site-packages/MythTV/dataheap.py in delete(self, force, rerecord)
>      375         """
>      376         try:
> --> 377             return self.getProgram().delete(force, rerecord)
>      378         except AttributeError:
>      379             raise MythError("Program could not be found")
> 
> /home/ross/.local/lib/python3.7/site-packages/MythTV/dataheap.py in getProgram(self)
>      387     def getProgram(self):
>      388         """Recorded.getProgram() -> Program object"""
> --> 389         return Program.fromRecorded(self)
>      390
>      391     def getRecordedFile(self):
> 
> /home/ross/.local/lib/python3.7/site-packages/MythTV/mythproto.py in fromRecorded(cls, rec)
>      953     @classmethod
>      954     def fromRecorded(cls, rec):
> --> 955         be = FileOps(db=rec._db)
>      956         return be.getRecording(rec.chanid, rec.starttime)
>      957
> 
> /home/ross/.local/lib/python3.7/site-packages/MythTV/mythproto.py in __init__(self, backend, blockshutdown, events, db)
>       78             # no backend given, use master
>       79             self.host = self.db.settings.NULL.MasterServerIP
> ---> 80             self.hostname = self.db._gethostfromaddr(self.host)
>       81
>       82         else:
> 
> /home/ross/.local/lib/python3.7/site-packages/MythTV/database.py in _gethostfromaddr(self, addr, value)
>     1346             else:
>     1347                 raise MythDBError(MythError.DB_SETTING,
> -> 1348                                     'BackendServerAddr', addr)
>     1349
>     1350         with self as cursor:
> 
> MythDBError: Could not find setting 'BackendServerAddr' on host '192.168.1.10'
> 
> Comments:
> Maybe it is expecting a name, not an IP address?  If so, how do I fix it?
> OTOH, the method name is gethostfromaddr.
> dig -x on the IP returns the fully qualified host name.
> The database and myth backend are both on the same IP.

Correct, the PR is in v31. There were more v3 commits made in the v31 cycle.
I see ~46 commits total. There is no plan to support Python v3 in earlier
MythTV versions.

This works in v31:

#!/usr/bin/python3
import MythTV
db=MythTV.MythDB()
bb=db.searchRecorded(title="Blue Bloods")
for a in bb:
     print(a.title, '\t', a.starttime)

Blue Bloods 	 2020-01-03 21:00:00-06:00
Blue Bloods 	 2020-01-31 21:00:00-06:00
Blue Bloods 	 2019-10-04 21:00:00-05:00
Blue Bloods 	 2020-02-14 21:00:00-06:00
Blue Bloods 	 2020-01-10 21:00:00-06:00

Or, you can use the python services_api module. It works with
v2 or v3. https://www.mythtv.org/wiki/Python_API_Examples

#!/usr/bin/python2
# -*- coding: utf-8 -*-

'''
Example: print_recordings.py <'optional recording title'>
'''

from __future__ import print_function
import sys
from MythTV.services_api import send as api


def main():
     """Check host, get recorded programs and print"""

     try:
         host = sys.argv[1]
     except IndexError:
         host = 'localhost'

     backend = api.Send(host=host)

     try:
         resp_dict = backend.send(endpoint='Dvr/GetRecordedList')
     except RuntimeError as error:
         sys.exit('\nFatal error: "{}"'.format(error))

     count = int(resp_dict['ProgramList']['Count'])
     progs = resp_dict['ProgramList']['Programs']

     if count < 1:
         sys.exit('\nNo upcoming recordings found.\n')

     for upcoming in range(count):
         print('  {}  {:45.45}  {:15.15}'.format(
             progs[upcoming]['Recording']['StartTs'],
             progs[upcoming]['Title'],
             progs[upcoming]['SubTitle']))


if __name__ == '__main__':
     main()

# vim: set expandtab tabstop=4 shiftwidth=4 smartindent noai colorcolumn=80:

-- 
Bill


More information about the mythtv-users mailing list