summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-05-01 16:12:33 -0300
committerdrebs <drebs@leap.se>2013-05-01 16:23:50 -0300
commitf2d588a965ee7fd76985d16b5ad93dc66b9d2be1 (patch)
tree8aecf4fb6d658a768ba2e7d7e14f43970e83e4b8
parentf0f07d240cbd5e7135076da0b1ce1dddb04fbc25 (diff)
Fix some items from second review.
Items are: * remove unused imports. * __init__.py: initialize variable before read from file. * backends/leap_backend.py: Fix mistyped exception name, fix docstring of encryption function.
-rw-r--r--src/leap/soledad/__init__.py5
-rw-r--r--src/leap/soledad/backends/couch.py5
-rw-r--r--src/leap/soledad/backends/leap_backend.py8
-rw-r--r--src/leap/soledad/backends/sqlcipher.py5
-rw-r--r--src/leap/soledad/shared_db.py2
5 files changed, 9 insertions, 16 deletions
diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py
index fb4c5520..2138e14e 100644
--- a/src/leap/soledad/__init__.py
+++ b/src/leap/soledad/__init__.py
@@ -264,7 +264,7 @@ class Soledad(object):
logger.info('Creating directory: %s.' % path)
os.makedirs(path)
else:
- logger.warning('Using existent directory: %s.' % path)
+ logger.info('Using existent directory: %s.' % path)
else:
raise NotADirectory(path)
@@ -325,7 +325,8 @@ class Soledad(object):
# does the file exist in disk?
if not os.path.isfile(self.secret_path):
return False
- # is it symmetrically encrypted?
+ # is it symfetrically encrypted?
+ content = None
with open(self.secret_path, 'r') as f:
content = f.read()
if not self._crypto.is_encrypted_sym(content):
diff --git a/src/leap/soledad/backends/couch.py b/src/leap/soledad/backends/couch.py
index 4dcea3f8..360f3211 100644
--- a/src/leap/soledad/backends/couch.py
+++ b/src/leap/soledad/backends/couch.py
@@ -29,10 +29,7 @@ except ImportError:
from base64 import b64encode, b64decode
from u1db import errors
-from u1db.sync import (
- LocalSyncTarget,
- Synchronizer,
-)
+from u1db.sync import Synchronizer
from u1db.backends.inmemory import InMemoryIndex
from u1db.remote.server_state import ServerState
from u1db.errors import DatabaseDoesNotExist
diff --git a/src/leap/soledad/backends/leap_backend.py b/src/leap/soledad/backends/leap_backend.py
index 1e9eb78f..46c787a9 100644
--- a/src/leap/soledad/backends/leap_backend.py
+++ b/src/leap/soledad/backends/leap_backend.py
@@ -21,7 +21,6 @@ A U1DB backend for encrypting data before sending to server and decrypting
after receiving.
"""
-import uuid
try:
import simplejson as json
except ImportError:
@@ -89,8 +88,9 @@ def encrypt_doc_json(crypto, doc_id, doc_json):
The returned JSON string is the serialization of the following dictionary:
{
- ENC_JSON_KEY: encrypt_sym(doc_content),
- '_encryption_scheme: 'symkey',
+ '_enc_json': encrypt_sym(doc_content),
+ '_enc_scheme': 'symkey',
+ '_mac': <mac> [Not implemented yet]
}
@param crypto: A SoledadCryto instance to perform the encryption.
@@ -160,7 +160,7 @@ def decrypt_doc_json(crypto, doc_id, doc_json):
ciphertext,
crypto.passphrase_hash(doc_id))
else:
- raise UnknownEncryptionScheme(enc_scheme)
+ raise UnknownEncryptionSchemes(enc_scheme)
return plainjson
diff --git a/src/leap/soledad/backends/sqlcipher.py b/src/leap/soledad/backends/sqlcipher.py
index f840d809..f174f0a7 100644
--- a/src/leap/soledad/backends/sqlcipher.py
+++ b/src/leap/soledad/backends/sqlcipher.py
@@ -27,10 +27,7 @@ from pysqlcipher import dbapi2
from u1db import (
errors,
)
-from leap.soledad.backends.leap_backend import (
- LeapDocument,
- EncryptionSchemes,
-)
+from leap.soledad.backends.leap_backend import LeapDocument
# Monkey-patch u1db.backends.sqlite_backend with pysqlcipher.dbapi2
diff --git a/src/leap/soledad/shared_db.py b/src/leap/soledad/shared_db.py
index 06f40466..419d8017 100644
--- a/src/leap/soledad/shared_db.py
+++ b/src/leap/soledad/shared_db.py
@@ -26,8 +26,6 @@ except ImportError:
import json # noqa
-from u1db import errors
-
from u1db.remote import http_database, http_client