04/08 Refactored codes, fixed issues
This commit is contained in:
+11
-1
@@ -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 []
|
||||
Reference in New Issue
Block a user