diff --git a/src/common/check_paths.py b/src/common/check_paths.py index a504c054d..1008e8c4f 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -20,7 +20,14 @@ import stat from common import gajim import logger -from pysqlite2 import dbapi2 as sqlite # DO NOT MOVE ABOVE OF import gajim +# DO NOT MOVE ABOVE OF import gajim +try: + import sqlite3 as sqlite # python 2.5 +except ImportError: + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable def create_log_db(): print _('creating logs database') diff --git a/src/common/optparser.py b/src/common/optparser.py index 570e68f73..170cc24a0 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -207,9 +207,12 @@ class OptionsParser: '''create table unread_messages if there is no such table''' import exceptions try: - from pysqlite2 import dbapi2 as sqlite + import sqlite3 as sqlite # python 2.5 except ImportError: - raise exceptions.PysqliteNotAvailable + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable import logger con = sqlite.connect(logger.LOG_DB_PATH) @@ -283,9 +286,12 @@ class OptionsParser: '''create table transports_cache if there is no such table''' import exceptions try: - from pysqlite2 import dbapi2 as sqlite + import sqlite3 as sqlite # python 2.5 except ImportError: - raise exceptions.PysqliteNotAvailable + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable import logger con = sqlite.connect(logger.LOG_DB_PATH) @@ -309,9 +315,12 @@ class OptionsParser: '''apply indeces to the logs database''' import exceptions try: - from pysqlite2 import dbapi2 as sqlite + import sqlite3 as sqlite # python 2.5 except ImportError: - raise exceptions.PysqliteNotAvailable + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable import logger print _('migrating logs database to indeces') con = sqlite.connect(logger.LOG_DB_PATH) @@ -333,7 +342,13 @@ class OptionsParser: def update_config_to_01015(self): '''clean show values in logs database''' - from pysqlite2 import dbapi2 as sqlite + try: + import sqlite3 as sqlite # python 2.5 + except ImportError: + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable import logger con = sqlite.connect(logger.LOG_DB_PATH) cur = con.cursor() diff --git a/src/history_manager.py b/src/history_manager.py index 86810d3db..bde306c32 100755 --- a/src/history_manager.py +++ b/src/history_manager.py @@ -44,10 +44,14 @@ C_SUBJECT, C_NICKNAME ) = range(2, 6) + try: - from pysqlite2 import dbapi2 as sqlite + import sqlite3 as sqlite # python 2.5 except ImportError: - raise exceptions.PysqliteNotAvailable + try: + from pysqlite2 import dbapi2 as sqlite + except ImportError: + raise exceptions.PysqliteNotAvailable class HistoryManager: