blob: 3aed10eb73a1944f0f1c3e9d8f582446f34a0186 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpauth import SRPAuth
from leap.soledad.client import Soledad
from twisted.internet import reactor
import logging
logging.basicConfig(level=logging.DEBUG)
# EDIT THIS --------------------------------------------
user = u"USERNAME"
uuid = u"USERUUID"
_pass = u"USERPASS"
server_url = "https://soledad.server.example.org:2323"
# EDIT THIS --------------------------------------------
secrets_path = "/tmp/%s.secrets" % uuid
local_db_path = "/tmp/%s.soledad" % uuid
cert_file = "/tmp/cacert.pem"
provider_config = '/tmp/cdev.json'
provider = ProviderConfig()
provider.load(provider_config)
soledad = None
def printStuff(r):
print r
def printErr(err):
logging.exception(err.value)
def init_soledad(_):
token = srpauth.get_token()
print "token", token
global soledad
soledad = Soledad(uuid, _pass, secrets_path, local_db_path,
server_url, cert_file,
auth_token=token)
def getall(_):
d = soledad.get_all_docs()
return d
d1 = soledad.create_doc({"test": 42})
d1.addCallback(getall)
d1.addCallbacks(printStuff, printErr)
d2 = soledad.sync()
d2.addCallbacks(printStuff, printErr)
d2.addBoth(lambda r: reactor.stop())
srpauth = SRPAuth(provider)
d = srpauth.authenticate(user, _pass)
d.addCallbacks(init_soledad, printErr)
reactor.run()
|