From 0bf2f9ec215f3c638701631e5676b670d7acc1b9 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 22 Jan 2014 14:51:45 -0200 Subject: Fix dev scripts doc and names. --- scripts/README.rst | 13 ------------- scripts/client-side-db.py | 36 ------------------------------------ scripts/client_side_db.py | 40 ++++++++++++++++++++++++++++++++++++++++ scripts/server-side-db.py | 38 -------------------------------------- scripts/server_side_db.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 87 deletions(-) delete mode 100644 scripts/client-side-db.py create mode 100644 scripts/client_side_db.py delete mode 100644 scripts/server-side-db.py create mode 100644 scripts/server_side_db.py diff --git a/scripts/README.rst b/scripts/README.rst index fdd1d642..37cf2c0e 100644 --- a/scripts/README.rst +++ b/scripts/README.rst @@ -2,16 +2,3 @@ Soledad Scripts =============== The scripts in this directory are meant to be used for development purposes. - -Currently, the scripts are: - - * server-side-db.py: Gives access to server-side soledad user database, - based on the configuration in /etc/leap/soledad-server.conf. One should - use it as: - - python -i server-side-db.py - - * client-side-db.py: Gives access to client-side soledad user database, - based on data stored in ~/.config/leap/soledad. One should use it as: - - python -i client-side-db.py diff --git a/scripts/client-side-db.py b/scripts/client-side-db.py deleted file mode 100644 index 0c3df7a4..00000000 --- a/scripts/client-side-db.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python - -# This script gives client-side access to one Soledad user database by using -# the data stored in ~/.config/leap/soledad/ - -import sys -import os - -from leap.common.config import get_path_prefix -from leap.soledad.client import Soledad - -if len(sys.argv) != 3: - print 'Usage: %s ' % sys.argv[0] - exit(1) - -uuid = sys.argv[1] -passphrase = unicode(sys.argv[2]) - -secrets_path = os.path.join(get_path_prefix(), 'leap', 'soledad', - '%s.secret' % uuid) -local_db_path = os.path.join(get_path_prefix(), 'leap', 'soledad', - '%s.db' % uuid) -server_url = 'http://dummy-url' -cert_file = 'cert' - -sol = Soledad(uuid, passphrase, secrets_path, local_db_path, server_url, - cert_file) -db = sol._db - -# get replica info -replica_uid = db._replica_uid -gen, docs = db.get_all_docs() -print "replica_uid: %s" % replica_uid -print "generation: %d" % gen -gen, trans_id = db._get_generation_info() -print "transaction_id: %s" % trans_id diff --git a/scripts/client_side_db.py b/scripts/client_side_db.py new file mode 100644 index 00000000..6d1843ac --- /dev/null +++ b/scripts/client_side_db.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +# This script gives client-side access to one Soledad user database by using +# the data stored in the appropriate config dir given by get_path_prefix(). +# +# Use it like this: +# +# python -i client-side-db.py + +import sys +import os + +from leap.common.config import get_path_prefix +from leap.soledad.client import Soledad + +if len(sys.argv) != 3: + print 'Usage: %s ' % sys.argv[0] + exit(1) + +uuid = sys.argv[1] +passphrase = unicode(sys.argv[2]) + +secrets_path = os.path.join(get_path_prefix(), 'leap', 'soledad', + '%s.secret' % uuid) +local_db_path = os.path.join(get_path_prefix(), 'leap', 'soledad', + '%s.db' % uuid) +server_url = 'http://dummy-url' +cert_file = 'cert' + +sol = Soledad(uuid, passphrase, secrets_path, local_db_path, server_url, + cert_file) +db = sol._db + +# get replica info +replica_uid = db._replica_uid +gen, docs = db.get_all_docs() +print "replica_uid: %s" % replica_uid +print "generation: %d" % gen +gen, trans_id = db._get_generation_info() +print "transaction_id: %s" % trans_id diff --git a/scripts/server-side-db.py b/scripts/server-side-db.py deleted file mode 100644 index 01a9aaac..00000000 --- a/scripts/server-side-db.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python - -# This script gives server-side access to one Soledad user database by using -# the configuration stored in /etc/leap/soledad-server.conf. - -import sys -from ConfigParser import ConfigParser - -from leap.soledad.common.couch import CouchDatabase - -if len(sys.argv) != 2: - print 'Usage: %s ' % sys.argv[0] - exit(1) - -uuid = sys.argv[1] - -# get couch url -cp = ConfigParser() -cp.read('/etc/leap/soledad-server.conf') -url = cp.get('soledad-server', 'couch_url') - -# access user db -dbname = 'user-%s' % uuid -db = CouchDatabase(url, dbname) - -# get replica info -replica_uid = db._replica_uid -gen, docs = db.get_all_docs() -print "dbname: %s" % dbname -print "replica_uid: %s" % replica_uid -print "generation: %d" % gen - -# get relevant docs -schemes = map(lambda d: d.content['_enc_scheme'], docs) -pubenc = filter(lambda d: d.content['_enc_scheme'] == 'pubkey', docs) - -print "total number of docs: %d" % len(docs) -print "pubkey encrypted docs: %d" % len(pubenc) diff --git a/scripts/server_side_db.py b/scripts/server_side_db.py new file mode 100644 index 00000000..18641a0f --- /dev/null +++ b/scripts/server_side_db.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +# This script gives server-side access to one Soledad user database by using +# the configuration stored in /etc/leap/soledad-server.conf. +# +# Use it like this: +# +# python -i server-side-db.py + +import sys +from ConfigParser import ConfigParser + +from leap.soledad.common.couch import CouchDatabase + +if len(sys.argv) != 2: + print 'Usage: %s ' % sys.argv[0] + exit(1) + +uuid = sys.argv[1] + +# get couch url +cp = ConfigParser() +cp.read('/etc/leap/soledad-server.conf') +url = cp.get('soledad-server', 'couch_url') + +# access user db +dbname = 'user-%s' % uuid +db = CouchDatabase(url, dbname) + +# get replica info +replica_uid = db._replica_uid +gen, docs = db.get_all_docs() +print "dbname: %s" % dbname +print "replica_uid: %s" % replica_uid +print "generation: %d" % gen + +# get relevant docs +schemes = map(lambda d: d.content['_enc_scheme'], docs) +pubenc = filter(lambda d: d.content['_enc_scheme'] == 'pubkey', docs) + +print "total number of docs: %d" % len(docs) +print "pubkey encrypted docs: %d" % len(pubenc) -- cgit v1.2.3