From ad16f0666dabc95a385942902e229fb034c5ecf8 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 12 May 2024 23:16:45 -0400 Subject: [PATCH 1/2] [2232] Fix Missing Preferences Fixes an issue that could present on clean installs where the EDSM keys weren't generated properly. When the heck did this bug get introduced??? --- plugins/edsm.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/edsm.py b/plugins/edsm.py index 5cd974d5..fd4d3925 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -491,6 +491,20 @@ def credentials(cmdr: str) -> tuple[str, str] | None: edsm_usernames = config.get_list('edsm_usernames') edsm_apikeys = config.get_list('edsm_apikeys') + if not edsm_usernames: # https://github.com/EDCD/EDMarketConnector/issues/2232 + edsm_usernames = ["" for _ in range(len(cmdrs))] + config.set('edsm_usernames', edsm_usernames) + else: # Check for Mismatched Length - fill with null values. + if len(edsm_usernames) < len(cmdrs): + edsm_usernames.extend(["" for _ in range(len(cmdrs) - len(edsm_usernames))]) + + if not edsm_apikeys: + edsm_apikeys = ["" for _ in range(len(cmdrs))] + config.set('edsm_apikeys', edsm_apikeys) + else: # Check for Mismatched Length - fill with null values. + if len(edsm_apikeys) < len(cmdrs): + edsm_apikeys.extend(["" for _ in range(len(cmdrs) - len(edsm_apikeys))]) + if cmdr in cmdrs and len(cmdrs) == len(edsm_usernames) == len(edsm_apikeys): idx = cmdrs.index(cmdr) if idx < len(edsm_usernames) and idx < len(edsm_apikeys): From eece4c2ba75e51c7062905c885ba8fd180b791cd Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 12 May 2024 23:18:24 -0400 Subject: [PATCH 2/2] [2232] Set EDSM Settings --- plugins/edsm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/edsm.py b/plugins/edsm.py index fd4d3925..1d9f8cb8 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -493,17 +493,17 @@ def credentials(cmdr: str) -> tuple[str, str] | None: if not edsm_usernames: # https://github.com/EDCD/EDMarketConnector/issues/2232 edsm_usernames = ["" for _ in range(len(cmdrs))] - config.set('edsm_usernames', edsm_usernames) else: # Check for Mismatched Length - fill with null values. if len(edsm_usernames) < len(cmdrs): edsm_usernames.extend(["" for _ in range(len(cmdrs) - len(edsm_usernames))]) + config.set('edsm_usernames', edsm_usernames) if not edsm_apikeys: edsm_apikeys = ["" for _ in range(len(cmdrs))] - config.set('edsm_apikeys', edsm_apikeys) else: # Check for Mismatched Length - fill with null values. if len(edsm_apikeys) < len(cmdrs): edsm_apikeys.extend(["" for _ in range(len(cmdrs) - len(edsm_apikeys))]) + config.set('edsm_apikeys', edsm_apikeys) if cmdr in cmdrs and len(cmdrs) == len(edsm_usernames) == len(edsm_apikeys): idx = cmdrs.index(cmdr)