04/08 Refactored codes, fixed issues

This commit is contained in:
2026-04-08 16:12:33 -04:00
parent c5e6566b6d
commit 6e1c9bbc7d
11 changed files with 84 additions and 124 deletions
+11 -1
View File
@@ -34,6 +34,16 @@ except Exception as e:
gmaps_client = None
print(f"❌ Error initializing Google Maps client: {e}")
def is_gmaps_available():
"""Return True if the Google Maps client is initialized and usable.
Always call this (or check ``if gmaps_client:``) before calling any
method on ``gmaps_client`` to prevent AttributeError when the API key
is absent.
"""
return gmaps_client is not None
# ---------------------------------------------------------------------------
# Geocoding cache
# ---------------------------------------------------------------------------
@@ -811,4 +821,4 @@ def get_all_locations_from_qr_codes():
return [row[0] for row in result.fetchall()]
except Exception as e:
logger_handler.logger.error(f"Error loading locations: {e}")
return []
return []