Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use config detection in Python bindings for stored smolt data.

This makes the Python bindings to store the location of the config.xml
it used for database access. This path is then used by the smolt
hardware profile for storage of its UUID files, replacing the hard coded
use of $HOME.

Fixes #10982
  • Loading branch information...
commit c96ded16b2d01a2d11e252a09103004843bf7438 1 parent b5e154f
@wagnerrp wagnerrp authored
View
12 mythtv/bindings/python/MythTV/database.py
@@ -846,6 +846,7 @@ def test(self, log):
confdir = os.environ.get('MYTHCONFDIR', '')
if confdir and (confdir != '/'):
obj = self.copy()
+ obj.confdir = confdir
if obj.readXML(confdir):
log(log.GENERAL, log.DEBUG,
"Trying database credentials from: {0}"\
@@ -864,20 +865,21 @@ def test(self, log):
homedir = os.environ.get('HOME', '')
if homedir and (homedir != '/'):
obj = self.copy()
+ obj.confdir = os.path.join(homedir, '.mythtv')
if obj.readXML(os.path.join(homedir,'.mythtv')):
log(log.GENERAL, log.DEBUG,
"Trying database credentials from: {0}"\
- .format(os.path.join(confdir,'config.xml')))
+ .format(os.path.join(homedir,'config.xml')))
yield obj
elif obj.readOldXML(os.path.join(homedir, '.mythtv')):
log(log.GENERAL, log.DEBUG,
"Trying old format database credentials from: {0}"\
- .format(os.path.join(confdir,'config.xml')))
+ .format(os.path.join(homedir,'config.xml')))
yield obj
else:
log(log.GENERAL, log.DEBUG,
"Failed to read database credentials from: {0}"\
- .format(os.path.join(confdir,'config.xml')))
+ .format(os.path.join(homedir,'config.xml')))
# try UPnP
for conn in XMLConnection.fromUPNP(5.0):
@@ -1004,13 +1006,15 @@ def writeXML(self, log):
log(log.GENERAL, log.DEBUG, "Writing new database credentials: {0}"\
.format(os.path.join(confdir,'config.xml')))
fp = open(os.path.join(confdir,'config.xml'), 'w')
+ self.confdir = confdir
else:
homedir = os.environ.get('HOME', '')
if homedir and (homedir != '/'):
log(log.GENERAL, log.DEBUG,
"Writing new database credentials: {0}"\
- .format(os.path.join(confdir,'config.xml')))
+ .format(os.path.join(homedir,'config.xml')))
fp = open(os.path.join(homedir, '.mythtv', 'config.xml'), 'w')
+ self.confdir = os.path.join(homedir, '.mythtv')
else:
raise MythError("Cannot find home directory to write to")
View
11 mythtv/programs/scripts/hardwareprofile/config.py
@@ -6,12 +6,13 @@
SMOON_URL = "http://smolt.mythtv.org/"
SECURE = 0
-from user import home
-HW_UUID = home + "/.mythtv/HardwareProfile/hw-uuid"
-PUB_UUID= home + "/.mythtv/HardwareProfile/pub-uuid"
-UUID_DB = home + '/.mythtv/HardwareProfile/uuiddb.cfg'
-ADMIN_TOKEN = home + "/.mythtv/HardwareProfile/smolt_token"
+from MythTV import MythDB
+confdir = os.path.join(MythDB().dbconfig.confdir, 'HardwareProfile')
+HW_UUID = os.path.join(confdir, 'hw-uuid')
+PUB_UUID = os.path.join(confdir, 'pub-uuid')
+UUID_DB = os.path.join(confdir, 'uuiddb.cfg')
+ADMIN_TOKEN = os.path.join(confdir, 'smolt_token')
#These are the defaults taken from the source code.
#fs_types = get_config_attr("FS_TYPES", ["ext2", "ext3", "xfs", "reiserfs"])
Please sign in to comment.
Something went wrong with that request. Please try again.