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!")
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:
)
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!")