From 3e0d12b8130a317c11da5145bb878b70b3bd8cac Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 9 Apr 2013 13:56:22 -0300 Subject: Add check for presence of a shared db. --- README | 43 +++++++++---------------------------------- src/leap/soledad/__init__.py | 10 ++++++---- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/README b/README index 923f2d7a..c03b766b 100644 --- a/README +++ b/README @@ -6,44 +6,19 @@ This software is under development. Dependencies ------------ -Soledad depends on the following python libraries: +The following Soledad dependencies have not been packaged in pypi yet, and so +are downloaded directly from their repositories (see `setup.py`): - * u1db 0.1.4 [1] - * python-gnupg 0.3.1 [2] - * CouchDB 0.8 [3] - * hmac 20101005 [4] - * pysqlcipher [5] - -[1] http://pypi.python.org/pypi/u1db/0.1.4 -[2] http://pypi.python.org/pypi/python-gnupg/0.3.1 -[3] http://pypi.python.org/pypi/CouchDB/0.8 -[4] http://pypi.python.org/pypi/hmac/20101005 -[5] Instructions for downloading and installing are below. - -pysqlcipher ------------ - -Pysqlcipher is an experimental fork of pysqlite, and is statically linked -against sqlcipher. - -To install it, do the following: - - git clone git://git.futeisha.org/pysqlcipher.git - cd pysqlcipher - python setup.py install + * pysqlcipher: pysqlite fork that binds to SQLCipher libraries. + Repository: git://git.futeisha.org/pysqlcipher.git@develop + * leap.common: Leap's common code (provides config, events, testing, etc). + Repository: ssh://code.leap.se/leap_pycommon.git@develop Tests ----- -Right now, there are 3 conditions that have to be met for all Soledad tests to -pass without problems: - - 1. Use nose2. - 2. Have CouchDB installed in the system. - 3. Have pysqlcipher module properly installed as described above. - -Soledad's tests should be run with nose2, like this: - - nose2 leap.soledad.tests +To run CouchDB tests, be sure you have CouchDB installed on your system. +Tests can be run with: + python setup.py test diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py index baf303e3..b636b744 100644 --- a/src/leap/soledad/__init__.py +++ b/src/leap/soledad/__init__.py @@ -178,6 +178,8 @@ class Soledad(object): self.shared_db_url, True, token=auth_token) + else: + self._shared_db = None def _init_config(self, **kwargs): """ @@ -472,8 +474,8 @@ class Soledad(object): @rtype: LeapDocument """ # TODO: change below to raise appropriate exceptions - #if not hasattr(self, '_shared_db'): - # return None + if not self._shared_db: + return None return self._shared_db.get_doc_unauth(self._user_hash()) def _assert_server_keys(self): @@ -481,8 +483,8 @@ class Soledad(object): Assert our key copies are the same as server's ones. """ assert self._has_keys() - #if not hasattr(self, '_shared_db'): - # return + if not self._shared_db: + return doc = self._get_keys_doc() if doc: remote_privkey = self.decrypt(doc.content['_privkey'], -- cgit v1.2.3