The branch, eden has been updated
via c902d5038cb20c381c872c554679d6dd94bd1dd9 (commit)
from 6f8852569fd58dbf763c9f99feaa767144dbe052 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=c902d5038cb20c381c872c554679d6dd94bd1dd9
commit c902d5038cb20c381c872c554679d6dd94bd1dd9
Author: M. Kaijser <[email protected]>
Date: Thu May 2 10:19:05 2013 +0200
[script.tvguide] 1.4.2
diff --git a/script.tvguide/addon.xml b/script.tvguide/addon.xml
index 8a084d1..d78d3f9 100644
--- a/script.tvguide/addon.xml
+++ b/script.tvguide/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.tvguide" name="TV Guide" version="1.4.1"
provider-name="twinther [[email protected]]">
+<addon id="script.tvguide" name="TV Guide" version="1.4.2"
provider-name="twinther [[email protected]]">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="script.module.simplejson" version="2.0.10"/>
diff --git a/script.tvguide/changelog.txt b/script.tvguide/changelog.txt
index a81304a..0bd339b 100644
--- a/script.tvguide/changelog.txt
+++ b/script.tvguide/changelog.txt
@@ -1,3 +1,6 @@
+[B]Version 1.4.2 - 2013-04-25[/B]
+- Improved handling of database initalization errors
+
[B]Version 1.4.1 - 2013-03-06[/B]
- Fixed minor problems with stream setup UI
- Fixed problem with the hour being displayed twice in start/end times
diff --git a/script.tvguide/gui.py b/script.tvguide/gui.py
index e59caf6..bfc7ff3 100644
--- a/script.tvguide/gui.py
+++ b/script.tvguide/gui.py
@@ -736,9 +736,10 @@ class TVGuide(xbmcgui.WindowXML):
def isSourceInitializationCancelled(self):
return xbmc.abortRequested or self.isClosing
- def onSourceInitialized(self):
- self.notification = Notification(self.database,
ADDON.getAddonInfo('path'))
- self.onRedrawEPG(0, self.viewStartDate)
+ def onSourceInitialized(self, success):
+ if success:
+ self.notification = Notification(self.database,
ADDON.getAddonInfo('path'))
+ self.onRedrawEPG(0, self.viewStartDate)
def onSourceProgressUpdate(self, percentageComplete):
control = self.getControl(self.C_MAIN_LOADING_PROGRESS)
diff --git a/script.tvguide/notification.py b/script.tvguide/notification.py
index 1ecfbcb..ca31d86 100644
--- a/script.tvguide/notification.py
+++ b/script.tvguide/notification.py
@@ -78,8 +78,11 @@ if __name__ == '__main__':
def onNotificationsCleared():
xbmcgui.Dialog().ok(strings(CLEAR_NOTIFICATIONS), strings(DONE))
- def onInitialized():
- database.clearAllNotifications()
- database.close(onNotificationsCleared)
-
- database.initialize(onInitialized, None)
+ def onInitialized(success):
+ if success:
+ database.clearAllNotifications()
+ database.close(onNotificationsCleared)
+ else:
+ database.close()
+
+ database.initialize(onInitialized)
diff --git a/script.tvguide/service.py b/script.tvguide/service.py
index 8a8b1bd..31b88eb 100644
--- a/script.tvguide/service.py
+++ b/script.tvguide/service.py
@@ -22,13 +22,17 @@ import notification
import xbmc
import source
+
class Service(object):
def __init__(self):
self.database = source.Database()
- self.database.initialize(self.onInit, None)
+ self.database.initialize(self.onInit)
- def onInit(self):
- self.database.updateChannelAndProgramListCaches(self.onCachesUpdated)
+ def onInit(self, success):
+ if success:
+
self.database.updateChannelAndProgramListCaches(self.onCachesUpdated)
+ else:
+ self.database.close()
def onCachesUpdated(self):
@@ -42,6 +46,7 @@ try:
ADDON = xbmcaddon.Addon(id = 'script.tvguide')
if ADDON.getSetting('cache.data.on.xbmc.startup') == 'true':
Service()
-
+except source.SourceNotConfiguredException:
+ pass # ignore
except Exception, ex:
xbmc.log('[script.tvguide] Uncaugt exception in service.py: %s' % str(ex)
, xbmc.LOGDEBUG)
diff --git a/script.tvguide/source.py b/script.tvguide/source.py
index f00cd6f..89edfa7 100644
--- a/script.tvguide/source.py
+++ b/script.tvguide/source.py
@@ -84,15 +84,19 @@ class Program(object):
class SourceException(Exception):
pass
+
class SourceUpdateCanceledException(SourceException):
pass
+
class SourceNotConfiguredException(SourceException):
pass
+
class DatabaseSchemaException(sqlite3.DatabaseError):
pass
+
class Database(object):
SOURCE_DB = 'source.db'
CHANNELS_PER_PAGE = 9
@@ -107,7 +111,6 @@ class Database(object):
self.updateInProgress = False
self.updateFailed = False
- self.sourceNotConfigured = False
self.settingsChanged = None
#buggalo.addExtraData('source', self.source.KEY)
@@ -141,7 +144,10 @@ class Database(object):
self.eventResults[command.__name__] = result
if callback:
- threading.Thread(name = 'Database callback', target =
callback).start()
+ if self._initialize == command:
+ threading.Thread(name='Database callback',
target=callback, args=[result]).start()
+ else:
+ threading.Thread(name='Database callback',
target=callback).start()
if self._close == command:
del self.eventQueue[:]
@@ -167,7 +173,7 @@ class Database(object):
del self.eventResults[method.__name__]
return result
- def initialize(self, callback, cancel_requested_callback):
+ def initialize(self, callback, cancel_requested_callback=None):
self.eventQueue.append([self._initialize, callback,
cancel_requested_callback])
self.event.set()
@@ -175,7 +181,7 @@ class Database(object):
sqlite3.register_adapter(datetime.datetime, self.adapt_datetime)
sqlite3.register_converter('timestamp', self.convert_datetime)
- self.sourceNotConfigured = False
+ self.alreadyTriedUnlinking = False
while True:
if cancel_requested_callback is not None and
cancel_requested_callback():
break
@@ -199,22 +205,26 @@ class Database(object):
if cancel_requested_callback is None:
xbmc.log('[script.tvguide] Database is locked, bailing
out...', xbmc.LOGDEBUG)
break
- else: # ignore 'database is locked'
+ else: # ignore 'database is locked'
xbmc.log('[script.tvguide] Database is locked,
retrying...', xbmc.LOGDEBUG)
except sqlite3.DatabaseError:
self.conn = None
- try:
- os.unlink(self.databasePath)
- except OSError:
- pass
- xbmcgui.Dialog().ok(ADDON.getAddonInfo('name'),
strings(DATABASE_SCHEMA_ERROR_1),
- strings(DATABASE_SCHEMA_ERROR_2),
strings(DATABASE_SCHEMA_ERROR_3))
-
- if self.conn is None:
- self.sourceNotConfigured = True
-
- def close(self, callback):
+ if self.alreadyTriedUnlinking:
+ xbmc.log('[script.tvguide] Database is broken and unlink()
failed', xbmc.LOGDEBUG)
+ break
+ else:
+ try:
+ os.unlink(self.databasePath)
+ except OSError:
+ pass
+ self.alreadyTriedUnlinking = True
+ xbmcgui.Dialog().ok(ADDON.getAddonInfo('name'),
strings(DATABASE_SCHEMA_ERROR_1),
+ strings(DATABASE_SCHEMA_ERROR_2),
strings(DATABASE_SCHEMA_ERROR_3))
+
+ return self.conn is not None
+
+ def close(self, callback=None):
self.eventQueue.append([self._close, callback])
self.event.set()
@@ -224,8 +234,9 @@ class Database(object):
if self.conn:
self.conn.rollback()
except sqlite3.OperationalError:
- pass # no transaction is active
- self.conn.close()
+ pass # no transaction is active
+ if self.conn:
+ self.conn.close()
def _wasSettingsChanged(self, addon):
settingsChanged = False
@@ -257,7 +268,6 @@ class Database(object):
print 'Settings changed: ' + str(settingsChanged)
return settingsChanged
-
def _isCacheExpired(self, date):
if self.settingsChanged:
return True
@@ -293,7 +303,6 @@ class Database(object):
return expired
-
def updateChannelAndProgramListCaches(self, callback, date =
datetime.datetime.now(), progress_callback = None, clearExistingProgramList =
True):
self.eventQueue.append([self._updateChannelAndProgramListCaches,
callback, date, progress_callback, clearExistingProgramList])
self.event.set()
-----------------------------------------------------------------------
Summary of changes:
script.tvguide/addon.xml | 2 +-
script.tvguide/changelog.txt | 3 ++
script.tvguide/gui.py | 7 +++--
script.tvguide/notification.py | 13 ++++++----
script.tvguide/service.py | 13 +++++++---
script.tvguide/source.py | 49 +++++++++++++++++++++++----------------
6 files changed, 54 insertions(+), 33 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons