diff options
author | drebs <drebs@leap.se> | 2014-03-14 16:04:28 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2014-03-14 17:00:36 -0300 |
commit | 5a2e9ac138faca940e10920be008a229a7a54cca (patch) | |
tree | fd5e3a2e84667eb790f6afb8ab0c483d856b2804 /scripts/db_access | |
parent | e51d656532294fa1bdf2a78ccd8426ccb97dd07c (diff) |
Improve client db access script.
Diffstat (limited to 'scripts/db_access')
-rw-r--r-- | scripts/db_access/client_side_db.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/db_access/client_side_db.py b/scripts/db_access/client_side_db.py index 15980f5d..2bf4ab5e 100644 --- a/scripts/db_access/client_side_db.py +++ b/scripts/db_access/client_side_db.py @@ -13,17 +13,24 @@ import requests import json import srp._pysrp as srp import binascii +import logging from leap.common.config import get_path_prefix from leap.soledad.client import Soledad +# create a logger +logger = logging.getLogger(__name__) +LOG_FORMAT = '%(asctime)s %(message)s' +logging.basicConfig(format=LOG_FORMAT, level=logging.INFO) + + safe_unhexlify = lambda x: binascii.unhexlify(x) if ( len(x) % 2 == 0) else binascii.unhexlify('0' + x) def fail(reason): - print 'Fail: ' + reason + logger.error('Fail: ' + reason) exit(2) @@ -94,6 +101,8 @@ def get_soledad_instance(username, provider, passphrase, basedir): # setup soledad info uuid, server_url, cert_file, token = \ get_soledad_info(username, provider, passphrase, basedir) + logger.info('UUID is %s' % uuid) + logger.info('Server URL is %s' % server_url) secrets_path = os.path.join( basedir, '%s.secret' % uuid) local_db_path = os.path.join( @@ -138,7 +147,7 @@ if __name__ == '__main__': basedir = args.basedir if basedir is None: basedir = tempfile.mkdtemp() - print 'Using %s as base directory.' % basedir + logger.info('Using %s as base directory.' % basedir) # get the soledad instance s = get_soledad_instance( |