The branch, eden has been updated
       via  99cbd6c62a2e1255274783e82a0cb40f5a5a0c33 (commit)
      from  effe220bd0082f9015b033db5c3d77601a3d76e6 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=99cbd6c62a2e1255274783e82a0cb40f5a5a0c33

commit 99cbd6c62a2e1255274783e82a0cb40f5a5a0c33
Author: Martijn Kaijser <[email protected]>
Date:   Sun Jul 1 17:06:26 2012 +0200

    [script.moviequiz] -v0.5.4

diff --git a/script.moviequiz/about.txt b/script.moviequiz/about.txt
index e74484e..38935b4 100644
--- a/script.moviequiz/about.txt
+++ b/script.moviequiz/about.txt
@@ -6,7 +6,7 @@ I initially started working on the addon in January 2011, when 
my girlfriend got
 
 I am continuously improving on it and always glad to get feedback, so please 
don't hesitate to contact me. You can use the XBMC forums or if you understand 
Danish you may want to visit my blog, which also has information on the other 
Danish addons I am working on.
 
-Online highscores: [B]http://moviequiz.xbmc.info[/B]
+Online highscores: [B]http://tommy.winther.nu/moviequiz/[/B]
 
 My blog: [B]http://tommy.winther.nu[/B]
 
diff --git a/script.moviequiz/addon.xml b/script.moviequiz/addon.xml
index 1b6d697..9e7bca2 100644
--- a/script.moviequiz/addon.xml
+++ b/script.moviequiz/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="script.moviequiz"
        name="Movie Quiz"
-       version="0.5.3"
+       version="0.5.4"
        provider-name="twinther [[email protected]]">
     <requires>
         <import addon="xbmc.python" version="2.0"/>
diff --git a/script.moviequiz/changelog.txt b/script.moviequiz/changelog.txt
index b55323d..87d02c5 100644
--- a/script.moviequiz/changelog.txt
+++ b/script.moviequiz/changelog.txt
@@ -1,3 +1,10 @@
+[B]Version 0.5.4 - 2012-06-27[/B]
+- Online highscores are now located at http://tommy.winther.nu/moviequiz/
+  - the old URL will expire in a couple of months
+- Fixed a number of minor errors submitted via the error reporting
+- Cleaned up database cursor handling to hopefully avoid some errors
+- Removed a lot of debug messages that might have caused errors
+
 [B]Version 0.5.3 - 2012-05-29[/B]
 - Actually enable script.module.buggalo for error reporting
 - Added support for answering using the 1,2,3,4 buttons on the remote
diff --git a/script.moviequiz/quizlib/db.py b/script.moviequiz/quizlib/db.py
index 25046d2..fd2ec38 100644
--- a/script.moviequiz/quizlib/db.py
+++ b/script.moviequiz/quizlib/db.py
@@ -20,6 +20,8 @@
 
 from xml.etree import ElementTree
 from xml.parsers.expat import ExpatError
+from xml.etree.ElementTree import ParseError
+
 
 import os
 import xbmc
@@ -93,8 +95,10 @@ class Database(object):
                     settings['pass'] = doc.findtext('videodatabase/pass')
             except ExpatError:
                xbmc.log("Unable to parse advancedsettings.xml")
+            except ParseError:
+                xbmc.log("Unable to parse advancedsettings.xml")
 
-        xbmc.log("Loaded DB settings: %s" % settings)
+        xbmc.log("Successfully loaded DB settings")
 
         if settings.has_key('type') and settings['type'] is not None and 
settings['type'].lower() == 'mysql':
             return MySQLDatabase(allowedRatings, onlyWatched, settings)
@@ -134,10 +138,11 @@ class Database(object):
         elif not isinstance(parameters, tuple):
             parameters = [parameters]
 
-        xbmc.log("Fetch all SQL [%s] with params %s" % (sql, str(parameters)))
+        #xbmc.log("Fetch all SQL [%s] with params %s" % (sql, str(parameters)))
         c = self.cursor()
         c.execute(sql, parameters)
         result = c.fetchall()
+        c.close()
 
         if result is None:
             raise DbException(sql)
@@ -150,10 +155,11 @@ class Database(object):
         if not isinstance(parameters, tuple):
             parameters = [parameters]
 
-        xbmc.log("Fetch one SQL [%s] with params %s" % (sql, str(parameters)))
+        #xbmc.log("Fetch one SQL [%s] with params %s" % (sql, str(parameters)))
         c = self.cursor()
         c.execute(sql, parameters)
         result = c.fetchone()
+        c.close()
 
         if result is None:
             raise DbException(sql)
@@ -166,7 +172,7 @@ class Database(object):
         if not isinstance(parameters, tuple):
             parameters = [parameters]
 
-        xbmc.log("Execute SQL [%s] with params %s" % (sql, str(parameters)))
+        #xbmc.log("Execute SQL [%s] with params %s" % (sql, str(parameters)))
         c = self.cursor()
         c.execute(sql, parameters)
         self.conn.commit()
@@ -645,7 +651,7 @@ class SQLiteDatabase(Database):
             xbmc.log("Unable to find any known SQLiteDatabase files!")
             return
 
-        xbmc.log("Connecting to SQLite database file: %s" % db_file)
+        #xbmc.log("Connecting to SQLite database file: %s" % db_file)
         self.conn = sqlite3.connect(db_file, check_same_thread = False)
         self.conn.row_factory = _sqlite_dict_factory
         xbmc.log("SQLiteDatabase opened")
@@ -684,7 +690,7 @@ class MySQLDatabase(Database):
             db = str(dbName)
             )
 
-        xbmc.log("MySQLDatabase %s opened" % dbName)
+        #xbmc.log("MySQLDatabase %s opened" % dbName)
         super(MySQLDatabase, self).postInit()
 
     def cursor(self):
diff --git a/script.moviequiz/quizlib/gui.py b/script.moviequiz/quizlib/gui.py
index 5bf3bcb..8596b60 100644
--- a/script.moviequiz/quizlib/gui.py
+++ b/script.moviequiz/quizlib/gui.py
@@ -121,6 +121,10 @@ class MenuGui(xbmcgui.WindowXML):
         super(MenuGui, self).__init__()
         self.trivia = None
         self.database = db.Database.connect()
+
+        if self.database is None:
+            pass
+
     def close(self):
         self.database.close()
         super(MenuGui, self).close()
@@ -182,33 +186,46 @@ class MenuGui(xbmcgui.WindowXML):
             directors = self.database.fetchone('SELECT COUNT(DISTINCT 
idDirector) AS count FROM directorlinkmovie')
             studios = self.database.fetchone('SELECT COUNT(idStudio) AS count 
FROM studio')
 
-            self.trivia += [
-                    strings(M_MOVIE_COLLECTION_TRIVIA),
-                    strings(M_MOVIE_COUNT) % movies['count'],
-                    strings(M_ACTOR_COUNT) % actors['count'],
-                    strings(M_DIRECTOR_COUNT) % directors['count'],
-                    strings(M_STUDIO_COUNT) % studios['count'],
-                    strings(M_HOURS_OF_ENTERTAINMENT) % 
int(movies['total_hours'])
-            ]
-
+            self.trivia.append(strings(M_MOVIE_COLLECTION_TRIVIA))
+            if movies is not None:
+                self.trivia.append(strings(M_MOVIE_COUNT) % movies['count'])
+            if actors is not None:
+                self.trivia.append(strings(M_ACTOR_COUNT) % actors['count'])
+            if directors is not None:
+                self.trivia.append(strings(M_DIRECTOR_COUNT) % 
directors['count'])
+            if studios is not None:
+                self.trivia.append(strings(M_STUDIO_COUNT) % studios['count'])
+            if movies is not None:
+                self.trivia.append(strings(M_HOURS_OF_ENTERTAINMENT) % 
int(movies['total_hours']))
 
         if self.database.hasTVShows():
             shows = self.database.fetchone('SELECT COUNT(*) AS count FROM 
tvshow')
             seasons = self.database.fetchone('SELECT SUM(season_count) AS 
count FROM (SELECT idShow, COUNT(DISTINCT c12) AS season_count from episodeview 
GROUP BY idShow) AS tbl')
             episodes = self.database.fetchone('SELECT COUNT(*) AS count FROM 
episode')
 
-            self.trivia += [
-                strings(M_TVSHOW_COLLECTION_TRIVIA),
-                strings(M_TVSHOW_COUNT) % shows['count'],
-                strings(M_SEASON_COUNT) % seasons['count'],
-                strings(M_EPISODE_COUNT) % episodes['count']
-            ]
+            self.trivia.append(strings(M_TVSHOW_COLLECTION_TRIVIA))
+            if shows is not None:
+                self.trivia.append(strings(M_TVSHOW_COUNT) % shows['count'])
+            if seasons is not None:
+                self.trivia.append(strings(M_SEASON_COUNT) % seasons['count'])
+            if episodes is not None:
+                self.trivia.append(strings(M_EPISODE_COUNT) % 
episodes['count'])
 
     @buggalo.buggalo_try_except()
     def onAction(self, action):
         if action.getId() in [ACTION_PARENT_DIR, ACTION_PREVIOUS_MENU]:
             self.close()
 
+        listControl = self.getControl(self.C_MENU_USER_SELECT)
+        if listControl.getSelectedItem() is not None and 
listControl.getSelectedItem().getProperty('id') == '-1':
+            # A user must be selected before leaving control
+            self.getControl(self.C_MENU_MOVIE_QUIZ).setEnabled(False)
+            self.getControl(self.C_MENU_TVSHOW_QUIZ).setEnabled(False)
+        else:
+            self.getControl(self.C_MENU_MOVIE_QUIZ).setEnabled(True)
+            self.getControl(self.C_MENU_TVSHOW_QUIZ).setEnabled(True)
+
+
     @buggalo.buggalo_try_except()
     def onClick(self, controlId):
         """
@@ -219,11 +236,17 @@ class MenuGui(xbmcgui.WindowXML):
         item = listControl.getSelectedItem()
 
         if controlId == self.C_MENU_MOVIE_QUIZ:
+            if item is None:
+                xbmcgui.Dialog().ok(strings(CHOOSE_PLAYER), 
strings(CHOOSE_PLAYER_LINE_1))
+                return
             w = GameTypeDialog(game.GAMETYPE_MOVIE, item.getProperty('id'))
             w.doModal()
             del w
 
         elif controlId == self.C_MENU_TVSHOW_QUIZ:
+            if item is None:
+                xbmcgui.Dialog().ok(strings(CHOOSE_PLAYER), 
strings(CHOOSE_PLAYER_LINE_1))
+                return
             w = GameTypeDialog(game.GAMETYPE_TVSHOW, item.getProperty('id'))
             w.doModal()
             del w
@@ -254,13 +277,7 @@ class MenuGui(xbmcgui.WindowXML):
 
     @buggalo.buggalo_try_except()
     def onFocus(self, controlId):
-        if controlId != self.C_MENU_USER_SELECT:
-            listControl = self.getControl(self.C_MENU_USER_SELECT)
-            if listControl.getSelectedItem() is not None and 
listControl.getSelectedItem().getProperty('id') == '-1':
-                # A user must be selected before leaving control
-                self.setFocusId(self.C_MENU_USER_SELECT)
-
-
+        pass
 
     def onAddNewUser(self, createDefault = False):
         keyboard = xbmc.Keyboard('', strings(G_WELCOME_ENTER_NICKNAME))
diff --git a/script.moviequiz/quizlib/highscore.py 
b/script.moviequiz/quizlib/highscore.py
index 31ca368..77313c3 100644
--- a/script.moviequiz/quizlib/highscore.py
+++ b/script.moviequiz/quizlib/highscore.py
@@ -49,7 +49,7 @@ class HighscoreDatabase(object):
 
 class GlobalHighscoreDatabase(HighscoreDatabase):
     STATUS_OK = 'OK'
-    SERVICE_URL = 'http://moviequiz.xbmc.info/service.json.php'
+    SERVICE_URL = 'http://tommy.winther.nu/moviequiz/service.json.php'
 
     def __init__(self, addonVersion):
         self.addonVersion = addonVersion
@@ -153,7 +153,7 @@ class LocalHighscoreDatabase(HighscoreDatabase):
 
         self.conn = sqlite3.connect(highscoreDbPath, check_same_thread = False)
         self.conn.row_factory = db._sqlite_dict_factory
-        xbmc.log("HighscoreDatabase opened: " + highscoreDbPath)
+        #xbmc.log("HighscoreDatabase opened: " + highscoreDbPath)
 
         self._createTables()
 
@@ -186,7 +186,9 @@ class LocalHighscoreDatabase(HighscoreDatabase):
         c = self.conn.cursor()
         c.execute('SELECT h.*, u.nickname FROM highscore h, user u WHERE 
h.user_id=u.id AND h.type=? AND h.gameType=? and h.gameSubType=? ORDER BY 
h.score DESC, h.timestamp ASC',
             [game.getType(), game.getGameType(), game.getGameSubType()])
-        return c.fetchall()
+        result = c.fetchall()
+        c.close()
+        return result
 
     def getHighscoresNear(self, game, highscoreId, limit = 50):
         c = self.conn.cursor()
@@ -199,11 +201,13 @@ class LocalHighscoreDatabase(HighscoreDatabase):
 
         c.execute("SELECT h.*, u.nickname FROM highscore h, user u WHERE 
h.user_id=u.id AND h.type=? AND h.gameType=? and h.gameSubType=? AND h.position 
> ? AND h.position < ? ORDER BY h.position",
             [game.getType(), game.getGameType(), game.getGameSubType(), 
position - (limit / 2), position + (limit / 2)])
-        return c.fetchall()
+        result = c.fetchall()
+        c.close()
+        return result
 
     def createUser(self, nickname):
         c = self.conn.cursor()
-        c.execute("INSERT INTO user(nickname, last_used) VALUES(?, 
datetime('now'))", [nickname])
+        c.execute("INSERT INTO user(nickname, last_used) VALUES(?, 
datetime('now'))", [nickname.decode('utf-8', 'ignore')])
         self.conn.commit()
         rowid = c.lastrowid
         c.close()
@@ -223,6 +227,7 @@ class LocalHighscoreDatabase(HighscoreDatabase):
         c.execute('DELETE FROM user WHERE id = ?', [id])
         c.execute('DELETE FROM highscore WHERE user_id = ?', [id])
         self.conn.commit()
+        c.close()
 
     def getNickname(self, userId):
         c = self.conn.cursor()
@@ -244,7 +249,7 @@ class LocalHighscoreDatabase(HighscoreDatabase):
         except sqlite3.OperationalError:
             version = [0,0,0]
 
-        xbmc.log("Highscore Database version: " + str(version))
+        #xbmc.log("Highscore Database version: " + str(version))
 
         if version < [0,4,1]:
             xbmc.log("Migrating Highscore Database to v0.4.1")
diff --git a/script.moviequiz/quizlib/player.py 
b/script.moviequiz/quizlib/player.py
index 3abb4ee..1092943 100644
--- a/script.moviequiz/quizlib/player.py
+++ b/script.moviequiz/quizlib/player.py
@@ -96,7 +96,7 @@ class TenSecondPlayer(xbmc.Player):
         self.startingPlayback = True
 
         if not xbmcvfs.exists(file):
-            xbmc.log(">> TenSecondPlayer - file not found: %s" % 
file.encode('utf-8', 'ignore'))
+            xbmc.log(">> TenSecondPlayer - file not found")#: %s" % 
file.encode('utf-8', 'ignore'))
             return False
 
         self.lastFile = file
@@ -118,7 +118,7 @@ class TenSecondPlayer(xbmc.Player):
         # Get bookmark details, so we can restore after playback
         self.bookmark = self.database.getVideoBookmark(idFile)
 
-        xbmc.log(">> TenSecondPlayer.playWindowed() - about to play file %s" % 
file.encode('utf-8', 'ignore'))
+        #xbmc.log(">> TenSecondPlayer.playWindowed() - about to play file %s" 
% file.encode('utf-8', 'ignore'))
 
         self.isAudioFile = False
         self.playBackEventReceived = False
@@ -137,10 +137,10 @@ class TenSecondPlayer(xbmc.Player):
         self.startingPlayback = True
 
         if not xbmcvfs.exists(file):
-            xbmc.log(">> TenSecondPlayer - file not found: %s" % file)
+            xbmc.log(">> TenSecondPlayer - file not found")
             return False
 
-        xbmc.log(">> TenSecondPlayer.playWindowed() - about to play file %s" % 
file)
+        #xbmc.log(">> TenSecondPlayer.playWindowed() - about to play file %s" 
% file)
 
         self.bookmark = None
         self.isAudioFile = True
@@ -153,7 +153,10 @@ class TenSecondPlayer(xbmc.Player):
             retries += 1
 
     def _getRandomDvdVob(self, ifoFile):
-        xbmc.log(">> TenSecondPlayer._getRandomDvdVob() - ifoFile = %s" % 
ifoFile)
+        #xbmc.log(">> TenSecondPlayer._getRandomDvdVob() - ifoFile = %s" % 
ifoFile)
+
+        if not os.path.exists(ifoFile):
+            return ifoFile
 
         files = []
         path = os.path.dirname(ifoFile)
@@ -163,7 +166,7 @@ class TenSecondPlayer(xbmc.Player):
 
         random.shuffle(files)
         file = os.path.join(path, files[0])
-        xbmc.log(">> TenSecondPlayer._getRandomDvdVob() - file = %s" % file)
+        #xbmc.log(">> TenSecondPlayer._getRandomDvdVob() - file = %s" % file)
         return file
 
     def onTenSecondsPassed(self):
diff --git a/script.moviequiz/quizlib/question.py 
b/script.moviequiz/quizlib/question.py
index ca89c4c..bd08473 100644
--- a/script.moviequiz/quizlib/question.py
+++ b/script.moviequiz/quizlib/question.py
@@ -28,6 +28,7 @@ import re
 import imdb
 import game
 
+import xbmc
 import xbmcvfs
 
 from strings import *
@@ -246,7 +247,7 @@ class ActorNotInMovieQuestion(MovieQuestion):
                 actor = row
                 break
             else:
-                print "Actor %s doesn't have a local photoFile" % 
row['strActor']
+                print "Actor doesn't have a local photoFile"
                 photoFile = None
 
         if actor is None:
@@ -1022,12 +1023,8 @@ def getRandomQuestion(gameInstance, database):
     for candidate in questionCandidates:
         try:
             return candidate(database)
-        except QuestionException, ex:
-            print "QuestionException in %s: %s" % (candidate, ex)
-        except db.DbException, ex:
-            print "DbException in %s: %s" % (candidate, ex)
         except Exception, ex:
-            print "Exception in %s: %s" % (candidate, ex)
+            xbmc.log("%s in %s" % (ex.__class__.__name__, candidate.__name__))
             import traceback, sys
             traceback.print_exc(file = sys.stdout)
 
diff --git a/script.moviequiz/quizlib/strings.py 
b/script.moviequiz/quizlib/strings.py
index 10ec037..48b2d8e 100644
--- a/script.moviequiz/quizlib/strings.py
+++ b/script.moviequiz/quizlib/strings.py
@@ -22,6 +22,9 @@ import xbmcaddon
 
 ADDON = xbmcaddon.Addon(id = 'script.moviequiz')
 
+CHOOSE_PLAYER = 30014
+CHOOSE_PLAYER_LINE_1 = 30016
+
 Q_WHAT_MOVIE_IS_THIS = 30400
 Q_WHAT_MOVIE_IS_ACTOR_NOT_IN = 30401
 Q_WHAT_YEAR_WAS_MOVIE_RELEASED = 30402
diff --git a/script.moviequiz/resources/language/Danish/strings.xml 
b/script.moviequiz/resources/language/Danish/strings.xml
index eac2b01..1fc726e 100644
--- a/script.moviequiz/resources/language/Danish/strings.xml
+++ b/script.moviequiz/resources/language/Danish/strings.xml
@@ -21,6 +21,7 @@
 
     <string id="30014">Vælg spiller</string>
     <string id="30015">Ny spiller</string>
+    <string id="30016">Du skal vælge en spiller for at spille!</string>
 
     <string id="30050">Advarsel</string>
     <string id="30051">Alle film spørgsmål er slået fra,</string>
diff --git a/script.moviequiz/resources/language/English/strings.xml 
b/script.moviequiz/resources/language/English/strings.xml
index 3a6a8a1..fd5274d 100644
--- a/script.moviequiz/resources/language/English/strings.xml
+++ b/script.moviequiz/resources/language/English/strings.xml
@@ -21,6 +21,7 @@
 
     <string id="30014">Choose player</string>
     <string id="30015">Add player</string>
+    <string id="30016">You must choose a player to play a game!</string>
 
     <string id="30050">Warning</string>
     <string id="30051">All movie questions types are disabled,</string>

-----------------------------------------------------------------------

Summary of changes:
 script.moviequiz/about.txt                         |    2 +-
 script.moviequiz/addon.xml                         |    2 +-
 script.moviequiz/changelog.txt                     |    7 ++
 script.moviequiz/quizlib/db.py                     |   18 ++++--
 script.moviequiz/quizlib/gui.py                    |   61 +++++++++++++-------
 script.moviequiz/quizlib/highscore.py              |   17 ++++--
 script.moviequiz/quizlib/player.py                 |   15 +++--
 script.moviequiz/quizlib/question.py               |    9 +--
 script.moviequiz/quizlib/strings.py                |    3 +
 .../resources/language/Danish/strings.xml          |    1 +
 .../resources/language/English/strings.xml         |    1 +
 11 files changed, 88 insertions(+), 48 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to