diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-01-22 14:04:23 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-01-22 14:04:23 -0300 |
commit | f5a5a7e3a8adfbc1f7bf450cb72cc50901dfade4 (patch) | |
tree | 5e2eb1813799744bac7c8031f21d1f774d7a1b67 /scripts/server_side_db.py | |
parent | 1388f5bc6563f3b8ca5d3c70ef22a9b6966cff04 (diff) | |
parent | d834422a48fda0ad1a5b1bd1db5edd0a4a35c823 (diff) |
Merge remote-tracking branch 'refs/remotes/drebs/add-debian-package-build-script' into develop
Diffstat (limited to 'scripts/server_side_db.py')
-rw-r--r-- | scripts/server_side_db.py | 42 |
1 files changed, 42 insertions, 0 deletions
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 <uuid> + +import sys +from ConfigParser import ConfigParser + +from leap.soledad.common.couch import CouchDatabase + +if len(sys.argv) != 2: + print 'Usage: %s <uuid>' % 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) |