summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-05-25 16:17:20 -0400
committerKali Kaneko <kali@leap.se>2015-05-25 16:17:20 -0400
commit745ac11c78455e7487bef88da3c3ffeb4fe4351c (patch)
treecc14a46120a69921ba9eed6e5584012c23fc694f /scripts
parent340b0dcfbc0a819738a28f9c803fdbf848754897 (diff)
parent3e6e51649bb6206125f20ac6773f6744ec8bf175 (diff)
Merge remote-tracking branch 'leapcode/pr/216' into develop
this branch includes many changes that improve the asynchronous retrieval of the sync docs, and the parallel decryption of the encrypted documents.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/db_access/client_side_db.py40
-rwxr-xr-xscripts/run_tests.sh3
2 files changed, 34 insertions, 9 deletions
diff --git a/scripts/db_access/client_side_db.py b/scripts/db_access/client_side_db.py
index d7c54b66..1d8d32e2 100644
--- a/scripts/db_access/client_side_db.py
+++ b/scripts/db_access/client_side_db.py
@@ -10,6 +10,7 @@ import requests
import srp._pysrp as srp
import binascii
import logging
+import json
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
@@ -147,6 +148,12 @@ def _parse_args():
'--passphrase', '-p', default=None,
help='the user passphrase')
parser.add_argument(
+ '--get-all-docs', '-a', action='store_true',
+ help='get all documents from the local database')
+ parser.add_argument(
+ '--create-doc', '-c', default=None,
+ help='create a document with give content')
+ parser.add_argument(
'--sync', '-s', action='store_true',
help='synchronize with the server replica')
parser.add_argument(
@@ -196,19 +203,34 @@ def _export_incoming_messages(soledad, directory):
i += 1
+@inlineCallbacks
+def _get_all_docs(soledad):
+ _, docs = yield soledad.get_all_docs()
+ for doc in docs:
+ print json.dumps(doc.content, indent=4)
+
+
# main program
@inlineCallbacks
def _main(soledad, km, args):
- if args.sync:
- yield soledad.sync()
- if args.export_private_key:
- yield _export_key(args, km, args.export_private_key, private=True)
- if args.export_public_key:
- yield _export_key(args, km, args.expoert_public_key, private=False)
- if args.export_incoming_messages:
- yield _export_incoming_messages(soledad, args.export_incoming_messages)
- reactor.stop()
+ try:
+ if args.create_doc:
+ yield soledad.create_doc({'content': args.create_doc})
+ if args.sync:
+ yield soledad.sync()
+ if args.get_all_docs:
+ yield _get_all_docs(soledad)
+ if args.export_private_key:
+ yield _export_key(args, km, args.export_private_key, private=True)
+ if args.export_public_key:
+ yield _export_key(args, km, args.expoert_public_key, private=False)
+ if args.export_incoming_messages:
+ yield _export_incoming_messages(soledad, args.export_incoming_messages)
+ except:
+ pass
+ finally:
+ reactor.stop()
if __name__ == '__main__':
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
new file mode 100755
index 00000000..e36466f8
--- /dev/null
+++ b/scripts/run_tests.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd common
+python setup.py test