]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 12:48:23 +0000 (14:48 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 2 Jun 2023 12:48:23 +0000 (14:48 +0200)
- timestamps are not handled over anymore
- more checks on parameter

fba.py

diff --git a/fba.py b/fba.py
index 95774e71eaf02083ec9b9be5bd38c2e6bb833e4c..37e7384ae8c9220d1a19a0204d57f0c52c3adf34 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -192,7 +192,7 @@ def is_cache_key_set(key: str, sub: str) -> bool:
 
 def is_primitive(var: any) -> bool:
     #print(f"DEBUG: var[]='{type(var)}' - CALLED!")
-    return type(var) in {int, str, float, bool, NoneType}
+    return type(var) in {int, str, float, bool} or var == None
 
 def set_instance_data(key: str, domain: str, value: any):
     #print(f"DEBUG: key='{key}',domain='{domain}',value[]='{type(value)}' - CALLED!")
@@ -1086,12 +1086,18 @@ def update_last_seen(blocker: str, blocked: str, block_level: str):
 
 def block_instance(blocker: str, blocked: str, reason: str, block_level: str):
     # DEBUG: print("DEBUG: blocker,blocked,reason,block_level:", blocker, blocked, reason, block_level)
-    if not validators.domain(blocker.split("/")[0]):
-        print("WARNING: Bad blocker:", blocker)
-        raise
+    if type(blocker) != str:
+        raise ValueError(f"Parameter blocker[]={type(blocker)} is not 'str'")
+    elif blocker == "":
+        raise ValueError(f"Parameter 'blocker' cannot be empty")
+    elif not validators.domain(blocker.split("/")[0]):
+        raise ValueError(f"Bad blocker='{blocker}'")
+    elif type(blocked) != str:
+        raise ValueError(f"Parameter blocked[]={type(blocked)} is not 'str'")
+    elif blocked == "":
+        raise ValueError(f"Parameter 'blocked' cannot be empty")
     elif not validators.domain(blocked.split("/")[0]):
-        print("WARNING: Bad blocked:", blocked)
-        raise
+        raise ValueError(f"Bad blocked='{blocked}'")
 
     print("INFO: New block:", blocker, blocked, reason, block_level, first_seen, last_seen)
     try:
@@ -1108,7 +1114,7 @@ def block_instance(blocker: str, blocked: str, reason: str, block_level: str):
         )
 
     except BaseException as e:
-        print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',first_seen='{first_seen}',last_seen='{last_seen}',exception[{type(e)}]:'{str(e)}'")
+        print(f"ERROR: failed SQL query: blocker='{blocker}',blocked='{blocked}',reason='{reason}',block_level='{block_level}',exception[{type(e)}]:'{str(e)}'")
         sys.exit(255)
 
     # DEBUG: print("DEBUG: EXIT!")