summaryrefslogtreecommitdiff
path: root/scripts/client-side-db.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-11-21 11:02:39 -0300
committerTomás Touceda <chiiph@leap.se>2013-11-21 11:02:39 -0300
commitd2f161e3efda601bccfc390392302f665f8a644b (patch)
tree3ace11d4b4276c86856f3e9b96080410f366ca9b /scripts/client-side-db.py
parentc17fe773748e6d07941016f608c6e7cfea0b043c (diff)
parent69fd3a11a3821468e737b8fb0e3e77abef0a4b8a (diff)
Merge remote-tracking branch 'drebs/bug/4095_add-unicode-conversion-to-put_doc' into develop
Diffstat (limited to 'scripts/client-side-db.py')
-rw-r--r--scripts/client-side-db.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/client-side-db.py b/scripts/client-side-db.py
new file mode 100644
index 00000000..0c3df7a4
--- /dev/null
+++ b/scripts/client-side-db.py
@@ -0,0 +1,36 @@
+#!/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 <uuid> <passphrase>' % 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