summaryrefslogtreecommitdiff
path: root/scripts/db_access/server_side_db.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-04-09 15:47:02 -0500
committerKali Kaneko <kali@leap.se>2014-04-09 15:47:02 -0500
commit62c03e86a21f1fdc7940f4ae8d771d8bccfdf82c (patch)
treedffb1feb349f6198e80e5195bc2adddecfdbe731 /scripts/db_access/server_side_db.py
parent5bb1e90dda3e6e23646b426255327a3b0f0e5fc0 (diff)
parentce22976cc0e203e53799e771aa5e3717d498cc5c (diff)
Merge tag '0.5.0' into deb-0.5.0
Tag leap.soledad 0.5.0
Diffstat (limited to 'scripts/db_access/server_side_db.py')
-rw-r--r--scripts/db_access/server_side_db.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/db_access/server_side_db.py b/scripts/db_access/server_side_db.py
new file mode 100644
index 00000000..18641a0f
--- /dev/null
+++ b/scripts/db_access/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)