mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-12 15:27:14 +03:00
[#2077] Ensure Valid Providers on Boot
Ensure we have valid providers set, and throw a warning dialog if we don't.
This commit is contained in:
parent
610d1971f9
commit
e5172e0486
@ -807,6 +807,9 @@ class AppWindow:
|
||||
self.w.bind_all('<<CompanionAuthEvent>>', self.auth) # cAPI auth
|
||||
self.w.bind_all('<<Quit>>', self.onexit) # Updater
|
||||
|
||||
# Check for Valid Providers
|
||||
validate_providers()
|
||||
|
||||
# Start a protocol handler to handle cAPI registration. Requires main loop to be running.
|
||||
self.w.after_idle(lambda: protocol.protocolhandler.start(self.w))
|
||||
|
||||
@ -2115,6 +2118,50 @@ def show_killswitch_poppup(root=None):
|
||||
ok_button.grid(columnspan=2, sticky=tk.EW)
|
||||
|
||||
|
||||
def validate_providers():
|
||||
"""Check if Config has an invalid provider set, and reset to default if we do."""
|
||||
reset_providers = {}
|
||||
station_provider: str = config.get_str("station_provider")
|
||||
if station_provider not in plug.provides('station_url'):
|
||||
logger.error("Station Provider Not Valid. Setting to Default.")
|
||||
config.set('station_provider', 'EDSM')
|
||||
reset_providers["Station"] = (station_provider, "EDSM")
|
||||
|
||||
shipyard_provider: str = config.get_str("shipyard_provider")
|
||||
if shipyard_provider not in plug.provides('shipyard_url'):
|
||||
logger.error("Shipyard Provider Not Valid. Setting to Default.")
|
||||
config.set('shipyard_provider', 'EDSY')
|
||||
reset_providers["Shipyard"] = (shipyard_provider, "EDSY")
|
||||
|
||||
system_provider: str = config.get_str("system_provider")
|
||||
if system_provider not in plug.provides('system_url'):
|
||||
logger.error("System Provider Not Valid. Setting to Default.")
|
||||
config.set('system_provider', 'EDSM')
|
||||
reset_providers["System"] = (system_provider, "EDSM")
|
||||
|
||||
if not reset_providers:
|
||||
return
|
||||
|
||||
# LANG: Popup-text about Reset Providers
|
||||
popup_text = _(r'One or more of your URL Providers were invalid, and have been reset:\r\n\r\n')
|
||||
for provider in reset_providers:
|
||||
# LANG: Text About What Provider Was Reset
|
||||
popup_text += _(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n')
|
||||
popup_text = popup_text.format(
|
||||
PROVIDER=provider,
|
||||
OLDPROV=reset_providers[provider][0],
|
||||
NEWPROV=reset_providers[provider][1]
|
||||
)
|
||||
# And now we do need these to be actual \r\n
|
||||
popup_text = popup_text.replace('\\n', '\n')
|
||||
popup_text = popup_text.replace('\\r', '\r')
|
||||
|
||||
tk.messagebox.showinfo(
|
||||
# LANG: Popup window title for Reset Providers
|
||||
_('EDMC: Default Providers Reset'),
|
||||
popup_text
|
||||
)
|
||||
|
||||
# Run the app
|
||||
if __name__ == "__main__": # noqa: C901
|
||||
logger.info(f'Startup v{appversion()} : Running on Python v{sys.version}')
|
||||
|
@ -231,6 +231,15 @@
|
||||
/* EDMarketConnector.py: Popup-text about 'broken' plugins that failed to load; In files: EDMarketConnector.py:2266; */
|
||||
"One or more of your enabled plugins failed to load. Please see the list on the '{PLUGINS}' tab of '{FILE}' > '{SETTINGS}'. This could be caused by a wrong folder structure. The load.py file should be located under plugins/PLUGIN_NAME/load.py.\r\n\r\nYou can disable a plugin by renaming its folder to have '{DISABLED}' on the end of the name." = "One or more of your enabled plugins failed to load. Please see the list on the '{PLUGINS}' tab of '{FILE}' > '{SETTINGS}'. This could be caused by a wrong folder structure. The load.py file should be located under plugins/PLUGIN_NAME/load.py.\r\n\r\nYou can disable a plugin by renaming its folder to have '{DISABLED}' on the end of the name.";
|
||||
|
||||
/* EDMarketConnector.py: Popup-text about Reset Providers; In files: EDMarketConnector.py:2146; */
|
||||
"One or more of your URL Providers were invalid, and have been reset:\r\n\r\n" = "One or more of your URL Providers were invalid, and have been reset:\r\n\r\n";
|
||||
|
||||
/* EDMarketConnector.py: Text About What Provider Was Reset; In files: EDMarketConnector.py:2148; */
|
||||
"{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n" = "{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n";
|
||||
|
||||
/* EDMarketConnector.py: Popup window title for Reset Providers; In files: EDMarketConnector.py:2161; */
|
||||
"EDMC: Default Providers Reset" = "EDMC: Default Providers Reset";
|
||||
|
||||
/* journal_lock.py: Title text on popup when Journal directory already locked; In files: journal_lock.py:208; */
|
||||
"Journal directory already locked" = "Journal directory already locked";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user