aboutsummaryrefslogtreecommitdiff
path: root/addons/script.module.pysqlite
diff options
context:
space:
mode:
authorJim Carroll <thecarrolls@jiminger.com>2011-04-16 19:51:00 -0400
committerJim Carroll <thecarrolls@jiminger.com>2011-04-18 13:18:01 -0400
commit9c356e2944be07bb77a45c54745aca529fb0ff7f (patch)
tree6063fa9c72231ca791366a657c20b161f235fb31 /addons/script.module.pysqlite
parent7c4cb239b1601f1c9a10c8117b272a0e8c678454 (diff)
Added a backward compatibility stub for pysqlite2.
Diffstat (limited to 'addons/script.module.pysqlite')
-rw-r--r--addons/script.module.pysqlite/addon.xml4
-rw-r--r--addons/script.module.pysqlite/lib/pysqlite2/__init__.py29
2 files changed, 31 insertions, 2 deletions
diff --git a/addons/script.module.pysqlite/addon.xml b/addons/script.module.pysqlite/addon.xml
index 6b17794989..fb90f31a44 100644
--- a/addons/script.module.pysqlite/addon.xml
+++ b/addons/script.module.pysqlite/addon.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.pysqlite"
- name="Python SQLite library"
+ name="Python SQLite library hook"
version="2.5.6"
provider-name="Gerhard Haering">
<requires>
- <import addon="xbmc.python" version="1.0"/>
+ <import addon="xbmc.python" version="2.0"/>
</requires>
<extension point="xbmc.python.module"
library="lib" />
diff --git a/addons/script.module.pysqlite/lib/pysqlite2/__init__.py b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
new file mode 100644
index 0000000000..f8c66ec1fc
--- /dev/null
+++ b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
@@ -0,0 +1,29 @@
+
+# if we got here then someone tried to import pysqlite.dbapi2
+# this will only be allowed if the script is greater that version 1.0
+
+import warnings
+
+# Not sure why this might fail but ....
+try:
+ import __main__
+ xbmcapiversion = __main__.__xbmcapiversion__
+except:
+ xbmcapiversion = "1.0"
+ warnings.warn("For some reason the module'" + std(__name__) + "' couldn't get access to '__main__'. This may prevent certain backward compatility modes from operating correctly.")
+
+# if the xbmcapiversion is either not set (because trying to get it failed or
+# the script was invoked in an odd manner from xbmc) ...
+if (float(xbmcapiversion) <= 1.0):
+ # then import sqlite3 in place of dbapi2
+ try:
+ import sqlite3 as dbapi2
+ except Exception, e:
+ warnings.warn("Unable to import sqlite3. This probably means you're on a version of python prior to 2.5 and trying to run an old script.")
+ raise e
+
+ # whine like a sissy ...
+ warnings.warn("DeprecationWarning: the pysqlite2 module is deprecated; stop being lazy and change your script to use sqlite3.")
+else:
+ raise DeprecationWarning("You cannot use pysqlite2 while depending on version " + str(xbmcapiversion) + " of the xbmc.python api. Please use sqlite3 instead.")
+