]> git.mxchange.org Git - fba.git/blobdiff - fba.py
Continued:
[fba.git] / fba.py
diff --git a/fba.py b/fba.py
index 2638800a408322721c604c025c1a583776a5f5bf..91efa62271111cb10163cc99713f7f336f491dd1 100644 (file)
--- a/fba.py
+++ b/fba.py
@@ -73,7 +73,7 @@ api_headers = {
 
 # Found info from node, such as nodeinfo URL, detection mode that needs to be
 # written to database. Both arrays must be filled at the same time or else
-# update_nodeinfos() will fail
+# update_instance_data() will fail
 nodeinfos = {
     # Detection mode: 'AUTO_DISCOVERY', 'STATIC_CHECKS' or 'GENERATOR'
     # NULL means all detection methods have failed (maybe still reachable instance)
@@ -352,8 +352,8 @@ def update_last_blocked(domain: str):
     nodeinfos["last_blocked"] = time.time()
 
     # Running pending updated
-    # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
-    update_nodeinfos(domain)
+    # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+    update_instance_data(domain)
 
     # DEBUG: print("DEBUG: EXIT!")
 
@@ -372,7 +372,7 @@ def has_pending_nodeinfos(domain: str) -> bool:
     # DEBUG: print(f"DEBUG: has_pending='{has_pending}' - EXIT!")
     return has_pending
 
-def update_nodeinfos(domain: str):
+def update_instance_data(domain: str):
     if type(domain) != str:
         raise ValueError(f"WARNING: domain[]={type(domain)} is not 'str'")
 
@@ -401,22 +401,23 @@ def update_nodeinfos(domain: str):
         # DEBUG: print(f"DEBUG: Success! (rowcount={cursor.rowcount })")
 
         if cursor.rowcount == 0:
-            print("WARNING: Did not update any rows:", domain)
-        else:
-            connection.commit()
+            print(f"WARNING: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!")
+            return
+
+        connection.commit()
+
+        # DEBUG: print("DEBUG: Deleting nodeinfos for domain:", domain)
+        for key in nodeinfos:
+            try:
+                # DEBUG: print("DEBUG: Deleting key:", key)
+                del nodeinfos[key][domain]
+            except:
+                pass
 
     except BaseException as e:
         print(f"ERROR: failed SQL query: domain='{domain}',sql='{sql}',exception[{type(e)}]:'{str(e)}'")
         sys.exit(255)
 
-    # DEBUG: print("DEBUG: Deleting nodeinfos for domain:", domain)
-    for key in nodeinfos:
-        try:
-            # DEBUG: print("DEBUG: Deleting key:", key)
-            del nodeinfos[key][domain]
-        except:
-            pass
-
     # DEBUG: print("DEBUG: EXIT!")
 
 def log_error(domain: str, res: any):
@@ -473,8 +474,8 @@ def update_last_error(domain: str, res: any):
         nodeinfos["last_error_details"][domain] = res.reason
 
     # Running pending updated
-    # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
-    update_nodeinfos(domain)
+    # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+    update_instance_data(domain)
 
     log_error(domain, res)
 
@@ -488,8 +489,8 @@ def update_last_instance_fetch(domain: str):
     nodeinfos["last_instance_fetch"][domain] = time.time()
 
     # Running pending updated
-    # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
-    update_nodeinfos(domain)
+    # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+    update_instance_data(domain)
 
     # DEBUG: print("DEBUG: EXIT!")
 
@@ -502,8 +503,8 @@ def update_last_nodeinfo(domain: str):
     nodeinfos["last_updated"][domain] = time.time()
 
     # Running pending updated
-    # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
-    update_nodeinfos(domain)
+    # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+    update_instance_data(domain)
 
     # DEBUG: print("DEBUG: EXIT!")
 
@@ -1101,7 +1102,7 @@ def add_instance(domain: str, origin: str, originator: str, path: str = None):
 
         if has_pending_nodeinfos(domain):
             # DEBUG: print(f"DEBUG: domain='{domain}' has pending nodeinfo being updated ...")
-            update_nodeinfos(domain)
+            update_instance_data(domain)
             remove_pending_error(domain)
 
         if domain in pending_errors: