From 919ab12b76167b220acd9c9b9f0325589e35c0dc Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 3 Apr 2020 04:27:37 -0500 Subject: [PATCH] plugins now use ujson --- .../default-plugins/chat/controlapi.py | 21 +++++------ static-data/default-plugins/chat/main.py | 2 +- .../default-plugins/chat/peerserver.py | 26 ++++++++------ .../default-plugins/circles/flowapi.py | 3 +- static-data/default-plugins/encrypt/main.py | 5 ++- static-data/default-plugins/pms/mailapi.py | 35 ++++++++++--------- static-data/default-plugins/pms/main.py | 3 +- 7 files changed, 54 insertions(+), 41 deletions(-) diff --git a/static-data/default-plugins/chat/controlapi.py b/static-data/default-plugins/chat/controlapi.py index 7718c36a..0cbac652 100755 --- a/static-data/default-plugins/chat/controlapi.py +++ b/static-data/default-plugins/chat/controlapi.py @@ -1,9 +1,14 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - HTTP endpoints for controlling IMs -''' -''' +HTTP endpoints for controlling IMs +""" +import ujson as json + +from flask import Response, request, redirect, Blueprint, send_from_directory +import deadsimplekv as simplekv + +import filepaths +""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -16,11 +21,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' -import json -from flask import Response, request, redirect, Blueprint, send_from_directory -import deadsimplekv as simplekv -import filepaths +""" flask_blueprint = Blueprint('chat_control', __name__) key_store = simplekv.DeadSimpleKV(filepaths.cached_storage, refresh_seconds=5) @flask_blueprint.route('/chatapi/ping') diff --git a/static-data/default-plugins/chat/main.py b/static-data/default-plugins/chat/main.py index 2b8f7eb6..a7d730d4 100755 --- a/static-data/default-plugins/chat/main.py +++ b/static-data/default-plugins/chat/main.py @@ -19,7 +19,7 @@ ''' # Imports some useful libraries -import locale, sys, os, threading, json +import locale, sys, os, threading, ujson as json locale.setlocale(locale.LC_ALL, '') import onionrservices, logger, config from onionrservices import bootstrapservice diff --git a/static-data/default-plugins/chat/peerserver.py b/static-data/default-plugins/chat/peerserver.py index 58dc3d7f..2d8e0905 100755 --- a/static-data/default-plugins/chat/peerserver.py +++ b/static-data/default-plugins/chat/peerserver.py @@ -1,9 +1,18 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - HTTP endpoints for communicating with peers -''' -''' +HTTP endpoints for communicating with peers +""" +import sys +import os + +import deadsimplekv as simplekv +import ujson as json +from flask import Response, request, redirect, Blueprint, abort, g + +from utils import identifyhome +from onionrutils import localcommand +import filepaths +""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -16,12 +25,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' -import sys, os, json -from utils import identifyhome -from onionrutils import localcommand -import deadsimplekv as simplekv, filepaths -from flask import Response, request, redirect, Blueprint, abort, g +""" sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) direct_blueprint = Blueprint('chat', __name__) diff --git a/static-data/default-plugins/circles/flowapi.py b/static-data/default-plugins/circles/flowapi.py index 6c946d47..01f70a04 100755 --- a/static-data/default-plugins/circles/flowapi.py +++ b/static-data/default-plugins/circles/flowapi.py @@ -3,9 +3,10 @@ This file primarily serves to allow specific fetching of circles board messages """ import operator -import json import os +import ujson as json + from flask import Response, Blueprint from deadsimplekv import DeadSimpleKV diff --git a/static-data/default-plugins/encrypt/main.py b/static-data/default-plugins/encrypt/main.py index 239be339..8fd53fe2 100755 --- a/static-data/default-plugins/encrypt/main.py +++ b/static-data/default-plugins/encrypt/main.py @@ -19,7 +19,10 @@ ''' # Imports some useful libraries -import logger, config, threading, time, datetime, sys, json +import logger, config, threading, time, datetime, sys + +import ujson as json + from onionrutils import stringvalidators, bytesconverter from onionrcrypto import encryption, keypair, signing, getourkeypair import onionrexceptions, onionrusers diff --git a/static-data/default-plugins/pms/mailapi.py b/static-data/default-plugins/pms/mailapi.py index efa827f4..81c5a127 100755 --- a/static-data/default-plugins/pms/mailapi.py +++ b/static-data/default-plugins/pms/mailapi.py @@ -1,9 +1,22 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - HTTP endpoints for mail plugin. -''' -''' +HTTP endpoints for mail plugin +""" +import sys +import os + +import ujson as json +from flask import Response, request, redirect, Blueprint, abort +import deadsimplekv as simplekv + +from onionrusers import contactmanager +from onionrutils import stringvalidators +from utils import reconstructhash, identifyhome + +sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) +import loadinbox +import sentboxdb +""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -16,17 +29,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' -import sys, os, json -from flask import Response, request, redirect, Blueprint, abort -from onionrusers import contactmanager -from onionrutils import stringvalidators -from utils import reconstructhash, identifyhome -import filepaths -import deadsimplekv as simplekv -sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) -import loadinbox, sentboxdb - +""" flask_blueprint = Blueprint('mail', __name__) kv = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat') diff --git a/static-data/default-plugins/pms/main.py b/static-data/default-plugins/pms/main.py index bda3f1fd..cf03c1b7 100755 --- a/static-data/default-plugins/pms/main.py +++ b/static-data/default-plugins/pms/main.py @@ -5,7 +5,8 @@ Private messages in an email like fashion import locale import sys import os -import json + +import ujson as json from onionrusers import contactmanager from utils import reconstructhash