]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 4 Jun 2023 13:37:05 +0000 (15:37 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 4 Jun 2023 13:38:51 +0000 (15:38 +0200)
- package/module of JSONDecodeError is json.decoder.JSONDecodeError

fba/fba.py

index 1bab14f0bb4e10db185627846b3d996fbf2392ef..623e5e0664557407d0ffb4f6b0097cc6d582ddc5 100644 (file)
@@ -380,7 +380,7 @@ def log_error(domain: str, res: any):
 
     try:
         # DEBUG: print("DEBUG: BEFORE res[]:", type(res))
-        if isinstance(res, BaseException) or isinstance(res, json.JSONDecodeError):
+        if isinstance(res, BaseException) or isinstance(res, json.decoder.JSONDecodeError):
             res = str(res)
 
         # DEBUG: print("DEBUG: AFTER res[]:", type(res))
@@ -415,7 +415,7 @@ def update_last_error(domain: str, res: any):
         raise ValueError(f"Parameter 'domain' cannot be empty")
 
     # DEBUG: print("DEBUG: BEFORE res[]:", type(res))
-    if isinstance(res, BaseException) or isinstance(res, json.JSONDecodeError):
+    if isinstance(res, BaseException) or isinstance(res, json.decoder.JSONDecodeError):
         res = f"{type}:str(res)"
 
     # DEBUG: print("DEBUG: AFTER res[]:", type(res))
@@ -495,14 +495,18 @@ def get_peers(domain: str, software: str) -> list:
                     "sort" : "+pubAt",
                     "host" : None,
                     "limit": step
-                }), {"Origin": domain})
+                }), {
+                    "Origin": domain
+                })
             else:
                 fetched = post_json_api(domain, "/api/federation/instances", json.dumps({
                     "sort"  : "+pubAt",
                     "host"  : None,
                     "limit" : step,
                     "offset": offset - 1
-                }), {"Origin": domain})
+                }), {
+                    "Origin": domain
+                })
 
             # DEBUG: print(f"DEBUG: fetched()={len(fetched))}")
             if len(fetched) == 0:
@@ -1327,7 +1331,9 @@ def get_misskey_blocks(domain: str) -> dict:
                     "host"     : None,
                     "suspended": True,
                     "limit"    : step
-                }), {"Origin": domain})
+                }), {
+                    "Origin": domain
+                })
             else:
                 # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
                 fetched = post_json_api(domain, "/api/federation/instances", json.dumps({
@@ -1336,7 +1342,9 @@ def get_misskey_blocks(domain: str) -> dict:
                     "suspended": True,
                     "limit"    : step,
                     "offset"   : offset - 1
-                }), {"Origin": domain})
+                }), {
+                    "Origin": domain
+                })
 
             # DEBUG: print("DEBUG: fetched():", len(fetched))
             if len(fetched) == 0:
@@ -1376,7 +1384,9 @@ def get_misskey_blocks(domain: str) -> dict:
                     "host"   : None,
                     "blocked": True,
                     "limit"  : step
-                }), {"Origin": domain})
+                }), {
+                    "Origin": domain
+                })
             else:
                 # DEBUG: print("DEBUG: Sending JSON API request to domain,step,offset:", domain, step, offset)
                 fetched = post_json_api(domain,"/api/federation/instances", json.dumps({
@@ -1384,8 +1394,10 @@ def get_misskey_blocks(domain: str) -> dict:
                     "host"   : None,
                     "blocked": True,
                     "limit"  : step,
-                    "offset" : offset-1
-                }), {"Origin": domain})
+                    "offset" : offset - 1
+                }), {
+                    "Origin": domain
+                })
 
             # DEBUG: print("DEBUG: fetched():", len(fetched))
             if len(fetched) == 0:
@@ -1456,7 +1468,7 @@ def json_from_response(response: requests.models.Response) -> list:
         # DEBUG: print(f"DEBUG: response.text()={len(response.text)} is not empty, invoking response.json() ...")
         try:
             data = response.json()
-        except json.JSONDecodeError:
+        except json.decoder.JSONDecodeError:
             pass
 
     # DEBUG: print(f"DEBUG: data[]={type(data)} - EXIT!")