import jsondecodeerror seperately since its not in ujson
This commit is contained in:
		
							parent
							
								
									919ab12b76
								
							
						
					
					
						commit
						39d0be32ac
					
				
					 6 changed files with 15 additions and 9 deletions
				
			
		|  | @ -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.') | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ | |||
|     You should have received a copy of the GNU General Public License | ||||
|     along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
| """ | ||||
| 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') | ||||
|  | @ -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 | ||||
| """ | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
|  | @ -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' | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue