]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 13:06:26 +0000 (15:06 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 13:06:26 +0000 (15:06 +0200)
- introduced cookies.clear() to clear cookies for given domain

fba/commands.py
fba/fba.py
fba/helpers/cookies.py

index fb83824a235f40789c947b185c28d0b983b9cd82..f10fb56482de673673d876d06badafdfd78a5f37 100644 (file)
@@ -121,6 +121,9 @@ def fetch_bkali(args: argparse.Namespace) -> int:
             try:
                 print(f"INFO: Fetching instances from domain='{domain}' ...")
                 federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name)
+
+                # DEBUG: print(f"DEBUG: Invoking cookies.clear({domain}) ...")
+                cookies.clear(domain)
             except network.exceptions as exception:
                 print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_bkali) from domain='{domain}'")
                 instances.set_last_error(domain, exception)
@@ -271,6 +274,9 @@ def fetch_blocks(args: argparse.Namespace):
                         blocks.update_last_seen(blocker, blocked, block_level)
                         blocks.update_reason(reason, blocker, blocked, block_level)
 
+                    # DEBUG: print(f"DEBUG: Invoking cookies.clear({blocked}) ...")
+                    cookies.clear(blocked)
+
             # DEBUG: print("DEBUG: Committing changes ...")
             fba.connection.commit()
         else:
@@ -283,6 +289,9 @@ def fetch_blocks(args: argparse.Namespace):
         if config.get("bot_enabled") and len(blockdict) > 0:
             network.send_bot_post(blocker, blockdict)
 
+        # DEBUG: print(f"DEBUG: Invoking cookies.clear({blocker}) ...")
+        cookies.clear(blocker)
+
     # DEBUG: print("DEBUG: EXIT!")
 
 def fetch_observer(args: argparse.Namespace):
@@ -357,6 +366,9 @@ def fetch_observer(args: argparse.Namespace):
             print(f"INFO: Fetching instances for domain='{domain}',software='{software}'")
             federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name)
 
+            # DEBUG: print(f"DEBUG: Invoking cookies.clear({domain}) ...")
+            cookies.clear(domain)
+
     # DEBUG: print("DEBUG: EXIT!")
 
 def fetch_cs(args: argparse.Namespace):
@@ -418,6 +430,9 @@ def fetch_cs(args: argparse.Namespace):
                     try:
                         print(f"INFO: Fetching instances from domain='{row['domain']}' ...")
                         federation.fetch_instances(row["domain"], 'chaos.social', None, inspect.currentframe().f_code.co_name)
+
+                        # DEBUG: print(f"DEBUG: Invoking cookies.clear({row['domain']}) ...")
+                        cookies.clear(row["domain"])
                     except network.exceptions as exception:
                         print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_cs) from domain='{row['domain']}'")
                         instances.set_last_error(row["domain"], exception)
@@ -466,6 +481,9 @@ def fetch_fba_rss(args: argparse.Namespace):
             try:
                 print(f"INFO: Fetching instances from domain='{domain}' ...")
                 federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name)
+
+                # DEBUG: print(f"DEBUG: Invoking cookies.clear({domain}) ...")
+                cookies.clear(domain)
             except network.exceptions as exception:
                 print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_fba_rss) from domain='{domain}'")
                 instances.set_last_error(domain, exception)
@@ -519,6 +537,9 @@ def fetch_fbabot_atom(args: argparse.Namespace):
             try:
                 print(f"INFO: Fetching instances from domain='{domain}' ...")
                 federation.fetch_instances(domain, None, None, inspect.currentframe().f_code.co_name)
+
+                # DEBUG: print(f"DEBUG: Invoking cookies.clear({domain}) ...")
+                cookies.clear(domain)
             except network.exceptions as exception:
                 print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_fbabot_atom) from domain='{domain}'")
                 instances.set_last_error(domain, exception)
@@ -533,6 +554,9 @@ def fetch_instances(args: argparse.Namespace) -> int:
     try:
         print(f"INFO: Fetching instances from args.domain='{args.domain}' ...")
         federation.fetch_instances(args.domain, None, None, inspect.currentframe().f_code.co_name)
+
+        # DEBUG: print(f"DEBUG: Invoking cookies.clear({args.domain}) ...")
+        cookies.clear(args.domain)
     except network.exceptions as exception:
         print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_instances) from args.domain='{args.domain}'")
         instances.set_last_error(args.domain, exception)
@@ -559,6 +583,9 @@ def fetch_instances(args: argparse.Namespace) -> int:
         try:
             print(f"INFO: Fetching instances for instance '{row[0]}' ('{row[2]}') of origin='{row[1]}',nodeinfo_url='{row[3]}'")
             federation.fetch_instances(row[0], row[1], row[2], inspect.currentframe().f_code.co_name, row[3])
+
+            # DEBUG: print(f"DEBUG: Invoking cookies.clear({row[0]}) ...")
+            cookies.clear(row[0])
         except network.exceptions as exception:
             print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_instances) from domain='{row[0]}'")
             instances.set_last_error(row[0], exception)
index 8e3c0c06cd4c4dbd478f5126c0a7469fb50788db..335028c8cf824c16bb6d25ae5b0740edba32ae1b 100644 (file)
@@ -126,6 +126,9 @@ def process_domain(domain: str, blocker: str, command: str) -> bool:
         print(f"INFO: Fetching instances for instane='{domain}',blocker='{blocker}',command='{command}' ...")
         federation.fetch_instances(domain, blocker, None, command)
         processed = True
+
+        # DEBUG: print(f"DEBUG: Invoking cookies.clear({domain}) ...")
+        cookies.clear(domain)
     except network.exceptions as exception:
         print(f"WARNING: Exception '{type(exception)}' during fetching instances (fetch_oliphant) from domain='{domain}'")
         instances.set_last_error(domain, exception)
index 5a35602bda672028f32f56088832742f35643926..2ed3f1d7a79763a07496ebb4280c9a4f894af77e 100644 (file)
@@ -53,3 +53,16 @@ def has (domain: str) -> bool:
 
     # DEBUG: print(f"DEBUG: has_cookies='{has_cookies}' - EXIT!")
     return has_cookies
+
+def clear (domain: str):
+    # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+    if not isinstance(domain, str):
+        raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
+    elif domain == "":
+        raise ValueError("Parameter 'domain' is empty")
+
+    if has(domain):
+        # DEBUG: print(f"DEBUG: Removing cookies for domain='{domain}' ...")
+        del _cookies[domain]
+
+    # DEBUG: print(f"DEBUG: EXIT!")