diff options
author | efkin <efkin@riseup.net> | 2017-03-13 21:17:18 +0100 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-03-17 17:52:57 +0100 |
commit | 7562655cf4bf28a1ebd6c458334da0c166f34e61 (patch) | |
tree | 54bc2de9b71e35d56fdcc3dd1ee9642ce8fd491d /client/src/leap/soledad/client/sqlcipher.py | |
parent | ba3fcb08eafd389bdbf0ab9c59577a25c8d8126d (diff) |
[refactor] Improve python3 compatibility
With this commit all tests on py34 tox environment
are collected.
Diffstat (limited to 'client/src/leap/soledad/client/sqlcipher.py')
-rw-r--r-- | client/src/leap/soledad/client/sqlcipher.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/client/src/leap/soledad/client/sqlcipher.py b/client/src/leap/soledad/client/sqlcipher.py index a3e45228..2c995d5a 100644 --- a/client/src/leap/soledad/client/sqlcipher.py +++ b/client/src/leap/soledad/client/sqlcipher.py @@ -42,11 +42,10 @@ SQLCipher 1.1 databases, we do not implement them as all SQLCipher databases handled by Soledad should be created by SQLCipher >= 2.0. """ import os +import sys from functools import partial -from pysqlcipher import dbapi2 as sqlcipher_dbapi2 - from twisted.internet import reactor from twisted.internet import defer from twisted.enterprise import adbapi @@ -62,6 +61,10 @@ from leap.soledad.client.http_target import SoledadHTTPSyncTarget from leap.soledad.client.sync import SoledadSynchronizer from leap.soledad.client import pragmas +if sys.version_info[0] < 3: + from pysqlcipher import dbapi2 as sqlcipher_dbapi2 +else: + from pysqlcipher3 import dbapi2 as sqlcipher_dbapi2 logger = getLogger(__name__) @@ -306,7 +309,7 @@ class SQLCipherDatabase(sqlite_backend.SQLitePartialExpandDatabase): )) try: c.execute(statement, tuple(args)) - except sqlcipher_dbapi2.OperationalError, e: + except sqlcipher_dbapi2.OperationalError as e: raise sqlcipher_dbapi2.OperationalError( str(e) + '\nstatement: %s\nargs: %s\n' % (statement, args)) res = c.fetchall() |