]>
code.delx.au - mediapc-tools/blob - mythlib.py
10 with
open(os
.path
.expanduser("~/.mythtv/config.xml")) as f
:
11 return lxml
.etree
.parse(f
, lxml
.etree
.XMLParser(encoding
="utf-8"))
13 def get_db_connection(config_xml
):
14 return MySQLdb
.connect(
15 host
= config_xml
.xpath("/Configuration/Database/Host/text()")[0],
16 port
= int(config_xml
.xpath("/Configuration/Database/Port/text()")[0]),
17 user
= config_xml
.xpath("/Configuration/Database/UserName/text()")[0],
18 passwd
= config_xml
.xpath("/Configuration/Database/Password/text()")[0],
19 db
= config_xml
.xpath("/Configuration/Database/DatabaseName/text()")[0],
22 def get_recordings_dir(config_xml
, db_connection
):
24 localhostname
= config_xml
.xpath("/Configuration/LocalHostName/text()")[0]
26 localhostname
= socket
.gethostname()
28 with db_connection
.cursor(MySQLdb
.cursors
.DictCursor
) as cursor
:
30 SELECT * FROM settings
31 WHERE value='RecordFilePrefix' AND hostname='%s'
34 return cursor
.fetchone()["data"]