diff --git a/src/config/__init__.py b/src/config/__init__.py index 2762a522..b292c4be 100755 --- a/src/config/__init__.py +++ b/src/config/__init__.py @@ -3,6 +3,7 @@ This file deals with configuration management. """ import os +from json import JSONDecodeError import ujson as json import logger @@ -105,7 +106,7 @@ def save(): try: with open(get_config_file(), 'w', encoding="utf8") as configfile: json.dump(get_config(), configfile, indent=2) - except json.JSONDecodeError: + except JSONDecodeError: logger.warn('Failed to write to configuration file.') @@ -115,7 +116,7 @@ def reload(): try: with open(get_config_file(), 'r', encoding="utf8") as configfile: set_config(json.loads(configfile.read())) - except (FileNotFoundError, json.JSONDecodeError) as e: + except (FileNotFoundError, JSONDecodeError) as e: pass #logger.debug('Failed to parse configuration file.') diff --git a/src/httpapi/configapi/__init__.py b/src/httpapi/configapi/__init__.py index ea8fbc85..a0aefab7 100755 --- a/src/httpapi/configapi/__init__.py +++ b/src/httpapi/configapi/__init__.py @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +from json import JSONDecodeError import ujson as json from flask import Blueprint, request, Response, abort @@ -42,7 +43,7 @@ def set_all_config(): """Overwrite existing JSON config with new JSON string""" try: new_config = request.get_json(force=True) - except json.JSONDecodeError: + except JSONDecodeError: abort(400) else: config.set_config(new_config) @@ -59,7 +60,7 @@ def set_by_key(key): """ try: data = json.loads(bytes_to_str(request.data)) - except (json.JSONDecodeError, KeyError): + except (JSONDecodeError, KeyError): abort(400) config.set(key, data, True) return Response('success') \ No newline at end of file diff --git a/src/onionrutils/localcommand.py b/src/onionrutils/localcommand.py index b1330cf8..b7e7aab2 100644 --- a/src/onionrutils/localcommand.py +++ b/src/onionrutils/localcommand.py @@ -4,12 +4,14 @@ send a command to the local API server """ import urllib import time -import functools from typing import TYPE_CHECKING, Callable import requests +import deadsimplekv + +import logger +import config -import logger, config, deadsimplekv from . import getclientapiserver import filepaths """ diff --git a/src/onionrutils/validatemetadata.py b/src/onionrutils/validatemetadata.py index 8cb7a1cf..a4e1ccea 100644 --- a/src/onionrutils/validatemetadata.py +++ b/src/onionrutils/validatemetadata.py @@ -2,6 +2,7 @@ validate new block's metadata """ +from json import JSONDecodeError import ujson as json import logger, onionrexceptions @@ -34,7 +35,7 @@ def validate_metadata(metadata, block_data) -> bool: if type(metadata) is str: try: metadata = json.loads(metadata) - except json.JSONDecodeError: + except JSONDecodeError: pass # Validate metadata dict for invalid keys to sizes that are too large diff --git a/static-data/default-plugins/chat/peerserver.py b/static-data/default-plugins/chat/peerserver.py index 2d8e0905..7bf0dda2 100755 --- a/static-data/default-plugins/chat/peerserver.py +++ b/static-data/default-plugins/chat/peerserver.py @@ -4,6 +4,7 @@ HTTP endpoints for communicating with peers """ import sys import os +from json import JSONDecodeError import deadsimplekv as simplekv import ujson as json @@ -50,7 +51,7 @@ def sendto(): """Endpoint peers send chat messages to""" try: msg = request.get_json(force=True) - except json.JSONDecodeError: + except JSONDecodeError: msg = '' else: msg = json.dumps(msg) diff --git a/static-data/default-plugins/circles/flowapi.py b/static-data/default-plugins/circles/flowapi.py index 01f70a04..e1cd5ad8 100755 --- a/static-data/default-plugins/circles/flowapi.py +++ b/static-data/default-plugins/circles/flowapi.py @@ -32,7 +32,7 @@ with open( os.path.dirname( os.path.realpath(__file__)) + '/info.json', 'r') as info_file: data = info_file.read().strip() - version = json.loads(data, strict=False)['version'] + version = json.loads(data)['version'] BOARD_CACHE_FILE = identifyhome.identify_home() + '/board-index.cache.json'