From 407ded8dd0b34aafc055cc7b53c7adb9e968930a Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Wed, 8 Dec 2021 16:52:06 -0700 Subject: [PATCH] fixed a bug in BMMiner parsing where a comma was missing causing json errors --- API/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/API/__init__.py b/API/__init__.py index 5de94f37..4b62a479 100644 --- a/API/__init__.py +++ b/API/__init__.py @@ -141,11 +141,15 @@ class BaseMinerAPI: # some json from the API returns with a null byte (\x00) on the end if data.endswith(b"\x00"): # handle the null byte - data = json.loads(data.decode('utf-8')[:-1]) + str_data = data.decode('utf-8')[:-1] else: # no null byte - data = json.loads(data.decode('utf-8')) + str_data = data.decode('utf-8') + # fix an error with a bmminer return not having a specific comma that breaks json.loads() + str_data.replace("}{", "},{") + # parse the json + parsed_data = json.loads(str_data) # handle bad json except json.decoder.JSONDecodeError: raise APIError(f"Decode Error: {data}") - return data + return parsed_data