From 3be1632627fd6f1fd41ecbabd1f99767081bcd8c Mon Sep 17 00:00:00 2001 From: Dustin Decker Date: Mon, 27 Jan 2025 15:12:37 -0800 Subject: [PATCH] Fix variable loading when they are unset --- selfdrive/frogpilot/fleetmanager/helpers.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/selfdrive/frogpilot/fleetmanager/helpers.py b/selfdrive/frogpilot/fleetmanager/helpers.py index 1abcab84723b42..3c6e0361bddad6 100644 --- a/selfdrive/frogpilot/fleetmanager/helpers.py +++ b/selfdrive/frogpilot/fleetmanager/helpers.py @@ -227,19 +227,30 @@ def get_nav_active(): return False def get_amap_key(): + token = params.get("AMapKey1", encoding='utf8') + token2 = params.get("AMapKey2", encoding='utf8') return ( - token.strip() if (token := params.get("AMapKey1", encoding='utf8')) != "0" else None, - token2.strip() if (token2 := params.get("AMapKey2", encoding='utf8')) != "0" else None + token.strip() if token and token != "0" else None, + token2.strip() if token2 and token2 != "0" else None ) def get_gmap_key(): - return token.strip() if (token := params.get("GMapKey", encoding='utf8')) != "0" else None + token = params.get("GMapKey", encoding='utf8') + if token is None: + return None + return token.strip() if token != "0" else None def get_public_token(): - return token.strip() if (token := params.get("MapboxPublicKey", encoding='utf8')).startswith("pk") else None + token = params.get("MapboxPublicKey", encoding='utf8') + if token is None: + return None + return token.strip() if token.startswith("pk") else None def get_app_token(): - return token.strip() if (token := params.get("MapboxSecretKey", encoding='utf8')).startswith("sk") else None + token = params.get("MapboxSecretKey", encoding='utf8') + if token is None: + return None + return token.strip() if token.startswith("sk") else None def get_SearchInput(): SearchInput = params.get_int("SearchInput")