Exemple #1
0
def init_couch_state(conf):
    try:
        _app.state = _get_couch_state(conf)
    except Exception as e:
        logger = getLogger()
        logger.error(str(e))
        reactor.stop()
Exemple #2
0
from twisted.enterprise import adbapi
from twisted.internet.defer import DeferredSemaphore
from zope.proxy import ProxyBase, setProxiedObject

from leap.soledad.common.log import getLogger
from leap.soledad.common.errors import DatabaseAccessError
from leap.soledad.client import sqlcipher as soledad_sqlcipher
from leap.soledad.client.pragmas import set_init_pragmas

if sys.version_info[0] < 3:
    from pysqlcipher import dbapi2
else:
    from pysqlcipher3 import dbapi2


logger = getLogger(__name__)


"""
How long the SQLCipher connection should wait for the lock to go away until
raising an exception.
"""
SQLCIPHER_CONNECTION_TIMEOUT = 5

"""
How many times a SQLCipher query should be retried in case of timeout.
"""
SQLCIPHER_MAX_RETRIES = 10


def getConnectionPool(opts, openfun=None, driver="pysqlcipher"):
Exemple #3
0
This is mainly used for tests, but can also be used to recover data from a
Soledad database (public/private keys, export documents, etc).

To speed up testing/debugging, this script can dump the auth data after
logging in. Use the --export-auth-data option to export auth data to a file.
The contents of the file is a json dictionary containing the uuid, server_url,
cert_file and token, which is enough info to instantiate a soledad client
without having to interact with the webapp again. Use the --use-auth-data
option to use the auth data stored in a file.

Use the --help option to see available options.
"""


# create a logger
logger = getLogger(__name__)
from twisted.python import log
log.startLogging(sys.stdout)


safe_unhexlify = lambda x: binascii.unhexlify(x) if (
    len(x) % 2 == 0) else binascii.unhexlify('0' + x)


def _fail(reason):
    logger.error('Fail: ' + reason)
    exit(2)


def _get_api_info(provider):
    info = requests.get(