Browse Source

test p≡p JSON protocol

master
Volker Birk 4 months ago
parent
commit
4a4cb4ef11
2 changed files with 15 additions and 15 deletions
  1. +9
    -7
      pEp_JSON.py
  2. +6
    -8
      pEp_import.py

+ 9
- 7
pEp_JSON.py View File

@@ -5,7 +5,6 @@ import sys
import os
import json
from httplib import HTTPConnection
from urllib import urlencode


if sys.platform == 'darwin':
@@ -30,22 +29,25 @@ class Connection:

def __enter__(self):
self.http_connection = HTTPConnection(str(self.config[u'address']), int(self.config[u'port']))
return self

def __exit__(self, type, value, traceback):
self.http_connection.close()

def __call__(self, method, *params):
func = {'method': method}
func['params': params]
func['params'] = params
func['id'] = self.next_id
self.next_id += 1
func['jsonrpc'] = '2.0'
func['security_token'] = str(self.config[u'security_token'])
params = urlencode(func)
params = json.dumps(func)
headers = {"Connection": "Keep-Alive"}
self.http_connection.request("POST", str(self.config[u'path']), params, headers)
response = conn.getresponse()
self.http_connection.request("POST", str(self.config[u'path']) + "callFunction", params, headers)
response = self.http_connection.getresponse()
data = None
if int(response.status) < 400:
if response.status < 400:
data = response.read()
return data
else:
print response.status
return json.loads(data)['result']

+ 6
- 8
pEp_import.py View File

@@ -14,13 +14,11 @@ from enigmail import thunderbird_base
own_pgp_keys = enigmail.own_pgp_keys()
identities = enigmail.identities()

print identities
#print identities
#print thunderbird.enigmail_assignKeysByEmailAddr(thunderbird_base)
#print enigmail.rules.test_address("vb@pibit.ch")
#print enigmail.comm_partner_pgp_keys()

with pEp_JSON.Connection() as connect:
pass
with pEp_JSON.Connection() as call:
print call("serverVersion")[u'return']

print thunderbird.enigmail_assignKeysByEmailAddr(thunderbird_base)

print enigmail.rules.test_address("vb@pibit.ch")

print enigmail.comm_partner_pgp_keys()

Loading…
Cancel
Save