From 2d268ae5c49764129b4b5ab3787248533f94727e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 4 Jun 2023 13:32:55 +0200 Subject: [PATCH] Continued: - trim off last dot in host/domain name - only release lock when acquired, e.g. check_instance.py doesn't need a lock --- fba/boot.py | 9 +++++---- fba/fba.py | 4 ++-- fba/instances.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fba/boot.py b/fba/boot.py index 605d2ea..dfe7ae4 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -38,8 +38,9 @@ def acquire_lock(): def shutdown(): print("DEBUG: Closing database connection ...") fba.connection.close() - print("DEBUG: Releasing lock ...") - LOCK.close() - print(f"DEBUG: Deleting lockfile='{lockfile}' ...") - os.remove(lockfile) + if LOCK != None: + print("DEBUG: Releasing lock ...") + LOCK.close() + print(f"DEBUG: Deleting lockfile='{lockfile}' ...") + os.remove(lockfile) print("DEBUG: Shutdown completed.") diff --git a/fba/fba.py b/fba/fba.py index 2025397..4d2d21d 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -1425,8 +1425,8 @@ def tidyup_domain(domain: str) -> str: if type(domain) != str: raise ValueError(f"Parameter domain[]={type(domain)} is not expected") - # All lower-case and strip spaces out - domain = domain.lower().strip() + # All lower-case and strip spaces out + last dot + domain = domain.lower().strip().rstrip(".") # No port number domain = re.sub("\:\d+$", "", domain) diff --git a/fba/instances.py b/fba/instances.py index 3312fa8..8be7a38 100644 --- a/fba/instances.py +++ b/fba/instances.py @@ -116,7 +116,7 @@ def update_instance_data(domain: str): # DEBUG: print(f"DEBUG: Success! (rowcount={fba.cursor.rowcount })") if fba.cursor.rowcount == 0: - print(f"WARNING: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!") + # DEBUG: print(f"DEBUG: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!") return # DEBUG: print("DEBUG: Committing changes ...") -- 2.39.5