Opened 8 years ago

Closed 8 years ago

#12520 closed Patch - Bug Fix (Fixed)

MythArchive stops after trying to get details from database

Reported by: Ben Klopfenstein <benklop@…> Owned by: Karl Egly
Priority: minor Milestone: 0.28
Component: Plugin - MythArchive Version: Unspecified
Severity: medium Keywords: backtrace
Cc: Ticket locked: no

Description

MythArchive?'s python script, mythburn, fails when running with the following backtrace:

reborn ~ # /usr/share/mythtv/mytharchive/scripts/mythburn.py
Using simple_fix_rtl
mythburn.py (0.1.20131119-1) starting up...
script path:/usr/share/mythtv/mytharchive/scripts
myth share path:/usr/share/mythtv
Found 6 CPUs
Obtaining MythTV settings from MySQL database for hostname MythTV-Frontend
Traceback (most recent call last):
  File "/usr/share/mythtv/mytharchive/scripts/mythburn.py", line 5298, in <module>
    main()
  File "/usr/share/mythtv/mytharchive/scripts/mythburn.py", line 5165, in main
    defaultsettings = getDefaultParametersFromMythTVDB()
  File "/usr/share/mythtv/mytharchive/scripts/mythburn.py", line 883, in getDefaultParametersFromMythTVDB
    cursor.execute(sqlstatement, configHostname)
  File "/usr/lib64/python2.7/site-packages/MythTV/_conn_mysqldb.py", line 71, in execute
    raise MythDBError(MythDBError.DB_RAW, e.args)
MythTV.exceptions.MythDBError: MySQL error: not all arguments converted during string formatting

This seems to be due to string formatting not working correctly for the hostname. I have submitted a PR in github with the fix - https://github.com/MythTV/mythtv/pull/98 - this allows proper operation, at least for me.

Patch diff (from the PR linked above):

diff --git a/mythplugins/mytharchive/mythburn/scripts/mythburn.py b/mythplugins/mytharchive/mythburn/scripts/mythburn.py
index ccd9861..73b65ec 100755
--- a/mythplugins/mytharchive/mythburn/scripts/mythburn.py
+++ b/mythplugins/mytharchive/mythburn/scripts/mythburn.py
@@ -846,7 +846,7 @@ def getDefaultParametersFromMythTVDB():
                         'DBSchemaVer',
                         'ISO639Language0',
                         'ISO639Language1')
-                    OR (hostname=%s AND value IN(
+                    OR (hostname='{0}' AND value IN(
                         'VideoStartupDir',
                         'GalleryDir',
                         'MusicLocation',
@@ -880,7 +880,7 @@ def getDefaultParametersFromMythTVDB():
     # create a cursor
     cursor = DB.cursor()
     # execute SQL statement
-    cursor.execute(sqlstatement, configHostname)
+    cursor.execute(sqlstatement.format(configHostname))
     # get the resultset as a tuple
     result = cursor.fetchall()

Change History (5)

comment:1 Changed 8 years ago by J.Pilk@…

This looks very similar to

http://www.gossamer-threads.com/lists/mythtv/users/586809#586809[[BR]]

(which is buried in a long thread; firefox takes me first to the start-of-thread)

I've been using that patch since Jaska first suggested it - although I never saw the original problem.

For convenience, here it is:

And here is the fix: File: mythburn.py line: 883 Change line from:


cursor.execute(sqlstatement, configHostname)

to:

cursor.execute(sqlstatement, (configHostname,))


MySQLdb requires that parameters are passed as a sequence:

http://mysql-python.sourceforge.net/MySQLdb.html#some-examples

comment:2 Changed 8 years ago by Ben Klopfenstein <benklop@…>

Is the fix you mentioned in a ticket somewhere or to be included in the repository at some point?

I've updated by linked PR to fix this the way you describe.

comment:3 Changed 8 years ago by J.Pilk@…

I haven't seen it anywhere else, and a quick search shows that Jaska's other 8 posts on the user list date from 2008 or earlier.

comment:4 Changed 8 years ago by Karl Egly

Milestone: unknown0.28
Owner: set to Karl Egly
Status: newaccepted
Type: Bug Report - CrashPatch - Bug Fix

thank you for the contribution, fixed in 9ce6aaa2f08d57a86068e65c6078492b03880b23

comment:5 Changed 8 years ago by Karl Egly

Resolution: Fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.