logger.debug("rows(%d)[]='%s'", len(rows), type(rows))
if len(rows) == 0:
- raise Exception("WARNING: Returned no records")
+ raise RuntimeError("WARNING: Returned no records")
elif "data" not in rows:
- raise Exception(f"WARNING: rows()={len(rows)} does not contain key 'data'")
+ raise KeyError(f"WARNING: rows()={len(rows)} does not contain key 'data'")
elif "nodeinfo" not in rows["data"]:
- raise Exception(f"WARNING: rows()={len(rows['data'])} does not contain key 'nodeinfo'")
+ raise KeyError(f"WARNING: rows()={len(rows['data'])} does not contain key 'nodeinfo'")
for entry in rows["data"]["nodeinfo"]:
logger.debug("entry[%s]='%s'", type(entry), entry)
elif not isinstance(sub, str):
raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'")
elif not key_exists(key):
- raise Exception(f"Cache for key='{key}' is not initialized, but function invoked")
+ raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
logger.debug("Setting key='%s',sub='%s',value[%s]='%s' ...", key, sub, type(value), value)
_cache[key][sub] = value
elif not isinstance(sub, str):
raise ValueError(f"Parameter sub[]='{type(sub)}' is not of type 'str'")
elif not key_exists(key):
- raise Exception(f"Cache for key='{key}' is not initialized, but function invoked")
+ raise KeyError(f"Cache for key='{key}' is not initialized, but function invoked")
exists = sub in _cache[key]
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not isinstance(headers, dict):
raise ValueError(f"Parameter headers[]='{type(headers)}' is not of type 'dict'")
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(origin, str) and origin is not None:
raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'")
elif not isinstance(command, str):
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(software, str) and software is not None:
raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
elif isinstance(software, str) and software == "":
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str):
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str) and path is not None:
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
elif path is not None and not path.startswith("/"):
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init block list
blocklist = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
elif not isinstance(path, str) and path is not None:
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
elif path is not None and not path.startswith("/"):
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function was invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
# No CSRF by default, you don't have to add network.api_headers by yourself here
headers = {}
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
raise ValueError(f"block_level='{block_level}' is not wanted.")
elif blacklist.is_blacklisted(blocker):
- raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
- raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked")
elif not is_instance_blocked(blocker, blocked, block_level):
- raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
+ raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
database.cursor.execute(
"SELECT reason FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
raise ValueError(f"block_level='{block_level}' is not wanted.")
elif blacklist.is_blacklisted(blocker):
- raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
- raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked")
elif not is_instance_blocked(blocker, blocked, block_level):
- raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
+ raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
logger.debug("Updating block reason='%s',blocker='%s',blocked='%s',block_level='%s'", reason, blocker, blocked, block_level)
database.cursor.execute(
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
elif blacklist.is_blacklisted(blocker):
- raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
- raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked")
elif not is_instance_blocked(blocker, blocked, block_level):
- raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
+ raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' is not registered but function is invoked")
database.cursor.execute(
"UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
elif blacklist.is_blacklisted(blocker):
- raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
- raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked")
if block_level is None:
database.cursor.execute(
elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
elif blacklist.is_blacklisted(blocker):
- raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocker='{blocker}' is blacklisted but function invoked")
elif blacklist.is_blacklisted(blocked):
- raise Exception(f"blocked='{blocked}' is blacklisted but function invoked")
+ raise RuntimeError(f"blocked='{blocked}' is blacklisted but function invoked")
elif is_instance_blocked(blocker, blocked, block_level):
- raise Exception(f"blocker='{blocker}' is already blocking blocked='{blocked}' with block_level='{block_level}' but function was invoked")
+ raise RuntimeError(f"blocker='{blocker}' is already blocking blocked='{blocked}' with block_level='{block_level}' but function was invoked")
elif reason is not None and reason == "":
- raise Exception(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' has empty (not 'None') block reason set")
+ raise RuntimeError(f"blocker='{blocker}',blocked='{blocked}',block_level='{block_level}' has empty (not 'None') block reason set")
logger.debug("reason='%s' - BEFORE!")
reason = tidyup.reason(reason) if reason is not None and reason != "" else None
if blacklist.is_blacklisted(domain):
raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
elif not _write_error_log:
- raise Exception("Logging of errors is disabled but function was invoked")
+ raise RuntimeError("Logging of errors is disabled but function was invoked")
logger.debug("error[]='%s' - BEFORE!", type(error))
if isinstance(error, (BaseException, json.decoder.JSONDecodeError)):
elif not key in _pending:
raise ValueError(f"key='{key}' not found in _pending")
elif blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function has been invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
elif not utils.is_primitive(value):
raise ValueError(f"value[]='{type(value)}' is not a primitive type")
if not is_registered(domain):
raise ValueError(f"domain='{domain}' is not registered but function was invoked")
elif blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function has been invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
has = False
logger.debug("Checking %d _pending array elements ...", len(_pending))
domain_helper.raise_on(domain)
if not is_registered(domain):
- raise Exception(f"domain='{domain}' cannot be updated while not being registered")
+ raise RuntimeError(f"domain='{domain}' cannot be updated while not being registered")
elif not has_pending(domain):
- raise Exception(f"domain='{domain}' has no pending instance data, but function invoked")
+ raise RuntimeError(f"domain='{domain}' has no pending instance data, but function invoked")
elif blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function has been invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
sql_string = ""
fields = []
logger.debug("rowcount=%d", database.cursor.rowcount)
if database.cursor.rowcount == 0:
- raise Exception(f"Did not update any rows: domain='{domain}',fields()={len(fields)}")
+ raise RuntimeError(f"Did not update any rows: domain='{domain}',fields()={len(fields)}")
logger.debug("Invoking commit() ...")
database.connection.commit()
elif origin is not None and not validators.domain(origin.split("/")[0], rfc_2782=True):
raise ValueError(f"Bad origin name='{origin}'")
elif blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted, but function invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted, but function invoked")
elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (is_registered(domain.split("/")[0]) and domain.find("/c/") > 0):
- raise Exception(f"domain='{domain}' is a single user")
+ raise RuntimeError(f"domain='{domain}' is a single user")
elif domain.find("/tag/") > 0:
- raise Exception(f"domain='{domain}' is a tag")
+ raise RuntimeError(f"domain='{domain}' is a tag")
if software is None:
try:
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function has been invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
elif not isinstance(skip_raise, bool):
raise ValueError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'")
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif has(pattern):
- raise Exception(f"pattern='{pattern}' is already added but function was invoked")
+ raise RuntimeError(f"pattern='{pattern}' is already added but function was invoked")
database.cursor.execute("INSERT INTO obfuscation (pattern, added) VALUES (?, ?)", (
pattern,
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif not has(pattern):
- raise Exception(f"pattern='{pattern}' is not added but function was invoked")
+ raise RuntimeError(f"pattern='{pattern}' is not added but function was invoked")
database.cursor.execute("UPDATE obfuscation SET last_used=? WHERE pattern=? LIMIT 1", (
time.time(),
elif pattern == "":
raise ValueError("Parametern 'pattern' is an empty string")
elif not has(pattern):
- raise Exception(f"pattern='{pattern}' is not added but function was invoked")
+ raise RuntimeError(f"pattern='{pattern}' is not added but function was invoked")
database.cursor.execute("DELETE FROM obfuscation WHERE pattern=? LIMIT 1", [pattern])
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
blocklist = []
block_tag = None
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# No CSRF by default, you don't have to add network.api_headers by yourself here
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
blocklist = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
peers = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init variables
doc = None
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init variables
blocklist = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
logger.debug("domain='%s' is misskey, sending API POST request ...", domain)
peers = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# No CSRF by default, you don't have to add network.api_headers by yourself here
headers = {}
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init variables
peers = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init variables
blockdict = []
domain_helper.raise_on(domain)
if blacklist.is_blacklisted(domain):
- raise Exception(f"domain='{domain}' is blacklisted but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is blacklisted but function is invoked")
elif not instances.is_registered(domain):
- raise Exception(f"domain='{domain}' is not registered but function is invoked")
+ raise RuntimeError(f"domain='{domain}' is not registered but function is invoked")
# Init variables
doc = None