ari's enigmail/pEp-on-linux build system this _also_ lives in https://pep.foundation/dev/repos/enigmailpEp/ in linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
enigmail-linux/test.py

47 lines
1.3 KiB

#!/usr/bin/python3
import requests
import json
import os
import io
# want these global
token = ''
url = ''
def call(method,*params):
fd = open('%s/.pEp/json-token'%(os.getenv('HOME')))
token = json.load(fd)
url = 'http://%s:%s/ja/0.1/callFunction'%(token['address'],token['port'])
call_d = dict(method=method, params=params, jsonrpc="2.0",)
call_d['security_token'] = token['security_token']
ans = requests.post(url,json=call_d)
if ans.status_code != 200:
print(ans.errorstack)
raise ValueError(ans.status_code)
ans = json.load(io.StringIO(ans.content.decode('utf8')))
if ans['result']['return']['status'] not in (0,):
raise IOError(ans)
ans = ans['result']['outParams']
if len(ans)==1:
return ans[0]
else:
return ans
def idrating(address):
return call('identity_rating',dict(address=address),0)
def decryptMime(msg):
if os.path.exists(msg):
msg = open(msg).read()
return call('MIME_decrypt_message',msg,len(msg),"mime_plaintext",[],0,0, "modified_src")
def encryptMime(msg):
if os.path.exists(msg):
msg = open(msg).read()
return call('MIME_encrypt_message',msg,len(msg),[],"",4,0)
def forcetrust(address):
identity = call('update_identity',{'address': address})
del identity['comm_type']
return call('trust_personal_key',identity)