Opened 11 years ago

Closed 11 years ago

#4265 closed defect (fixed)

Perl Bindings depend on mysql.txt for DB Connection

Reported by: stuartm Owned by: Nigel
Priority: blocker Milestone: 0.21
Component: perl / nuvexport Version: head
Severity: medium Keywords:
Cc: Ticket locked: no


The perl bindings require mysql.txt for actions which involve the database e.g.

Mysql.txt is deprecated and may not exist on new systems.

Change History (12)

comment:1 Changed 11 years ago by Nigel

1) Scripting environments should probably have the "default" values hard-coded in, just in case there isn't a mysql.txt?

2) If there is a local mythbackend running, a query to a particular port (e.g. the default 6543) could provide one for Perl/Python/Java? scripts to parse? It is only on random frontend only machines that this is really difficult.

3) UPnP is also possible, as is prompting the user for dbHostName, dbUserName, dbPassword, but hopefully that won't be necessary?

comment:2 Changed 11 years ago by xris

It would also be nice if the UPnP detector wrote some of this useful information into the config.xml file. The initial spec asked for this, anyway, so if there was no UPnP connection, the frontend could try to contact the last server directly, too.

comment:3 Changed 11 years ago by xris

Milestone: unknown0.21
Priority: majorblocker

comment:4 Changed 11 years ago by Nigel

Writing the last successful connection into config.xml is pretty easy. Something like this (untested) should do it:

% svn diff mythcontext.cpp
Index: mythcontext.cpp
--- mythcontext.cpp     (revision 15473)
+++ mythcontext.cpp     (working copy)
@@ -69,8 +69,9 @@
 // Some common UPnP search and XML value strings
 const QString gBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
-const QString kDefaultPIN = "UPnP/MythFrontend/DefaultBackend/SecurityPin";
-const QString kDefaultUSN = "UPnP/MythFrontend/DefaultBackend/USN";
+const QString kDefaultBE  = "UPnP/MythFrontend/DefaultBackend/";
+const QString kDefaultPIN = kDefaultBE + "SecurityPin";
+const QString kDefaultUSN = kDefaultBE + "USN";
 int parse_verbose_arg(QString arg)
@@ -663,6 +664,12 @@
     //VERBOSE(VB_GENERAL, "FindDatabase() - Success!");
+    m_XML->SetValue(kDefaultBE + "lastDBhostName", m_DBparams.dbHostName);
+    m_XML->SetValue(kDefaultBE + "lastDBuserName", m_DBparams.dbUserName);
+    m_XML->SetValue(kDefaultBE + "lastDBpassword", m_DBparams.dbPassword);
+    m_XML->SetValue(kDefaultBE + "lastDBname",     m_DBparams.dbName);
+    m_XML->SetValue(kDefaultBE + "lastDBport",     m_DBparams.dbPort);
+    m_XML->Save();
     return true;

Note, it would be just as easy to write these into mysql.txt instead of config.xml (and that would automatically handle the "contact the last server directly"), or to only write them when the user elects to "Save backend details" (just move these SetValue?()s to line 1288). It just depends on whether we want to keep the config.xml for UPnP only.

comment:5 Changed 11 years ago by Nigel

(In [15618]) Store some more stuff from mysql.txt in config.xml. 1) LocalHostName? can now be specified in the file. No UI editing yet, though. 2) The database connection parameters, as at the time the user chose it,

are also saved there. Having it stored breaks the whole UPnP paradigm, (if the backend host is reconfigured, the saved details will be wrong) but if the backend is down, it allows connection, and it should also help scrips to connect when there is no mysql.txt. See #4265

comment:6 Changed 11 years ago by Nigel

Resolution: fixed
Status: newclosed

(In [15632]) Default DB connection settings, and last location of the saved UPnP backend from config.xml, for Perl scripts. Won't help in the situation where there is neither mysql.txt nor config.xml, but unless someone wants to implement a full UPnP locator in Perl, this will have to do for now. Closes #4265

comment:7 Changed 11 years ago by xris

Resolution: fixed
Status: closednew

Running [15633] and I don't see this change working like I suspect that it should. I even blew away my config.xml and it comes back with just the upnp MediaRenderer? tag, nothing else.

comment:8 Changed 11 years ago by Nigel

The backend connection details are only saved in the file if the user uses the backend selector (mythfrontend -p), selects a backend, and then clicks the "Save backend details" button. I will think about saving the file in other situations, but saving it in every situation is a big code change that I would rather not commit right now.

comment:9 Changed 11 years ago by xris

No way to make it just add those extra pieces of data to the file whenever the file gets saved? The whole point of this ticket was to get that info into the file without the users having to do anything special. Having them wipe the file so it re-creates is one thing, but requiring a mythfrontend -p (which currently appears to require manual configuration -- doesn't see the backend running on the same host) seems a bit overkill.

comment:10 Changed 11 years ago by Nigel

Owner: changed from xris to Nigel
Status: newassigned

I can make it save the details each time the DB connection succeeds. It is the UPnP autoconfig scenario (possibly no config.xml) which is the problem. Still testing.

comment:11 Changed 11 years ago by Nigel

(In [15647]) Save last backend location in config.xml whenever mythfrontend connects. See #4265. Will not currently do anything for mythtv-setup, mythbackend, et c. That is fixable, if need be, but is a large code change I'd rather not do now.

comment:12 Changed 11 years ago by xris

Resolution: fixed
Status: assignedclosed

Perfect, thanks!

Note: See TracTickets for help on using tickets.