1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

[#519] Framework Beta Update Track

This commit is contained in:
David Sangrey 2024-05-03 21:34:03 -04:00
parent 4a1a107e03
commit b6e373decd
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
4 changed files with 54 additions and 10 deletions

View File

@ -829,7 +829,7 @@ class AppWindow:
self.suit.grid_forget()
self.suit_shown = False
def postprefs(self, dologin: bool = True):
def postprefs(self, dologin: bool = True, **postargs):
"""Perform necessary actions after the Preferences dialog is applied."""
self.prefsdialog = None
self.set_labels() # in case language has changed
@ -853,6 +853,11 @@ class AppWindow:
if dologin and monitor.cmdr:
self.login() # Login if not already logged in with this Cmdr
if postargs.get('Update') and postargs.get('Track'):
# LANG: Inform the user the Update Track has changed
self.status['text'] = tr.tl('Update Track Changed to {TRACK}').format(TRACK=postargs.get('Track'))
self.updater.check_for_updates()
def set_labels(self):
"""Set main window labels, e.g. after language change."""
self.cmdr_label['text'] = tr.tl('Cmdr') + ':' # LANG: Label for commander name in main window

View File

@ -17,7 +17,6 @@ __all__ = [
'applongname',
'appcmdname',
'copyright',
'update_feed',
'update_interval',
'debug_senders',
'trace_on',
@ -29,7 +28,9 @@ __all__ = [
'user_agent',
'appversion_nobuild',
'AbstractConfig',
'config'
'config',
'get_update_feed',
'update_feed'
]
import abc
@ -58,7 +59,7 @@ _static_appversion = '5.10.4'
_cached_version: semantic_version.Version | None = None
copyright = '© 2015-2019 Jonathan Harris, 2020-2024 EDCD'
update_feed = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
update_interval = 8*60*60 # 8 Hours
# Providers marked to be in debug mode. Generally this is expected to switch to sending data to a log file
debug_senders: list[str] = []
@ -479,3 +480,17 @@ def get_config(*args, **kwargs) -> AbstractConfig:
config = get_config()
# TODO: Set Proper Beta XML, Bring XML from Releases to Live, Translations, wiki on Updates (WILL NOT DOWNGRADE), link in label
def get_update_feed() -> str:
"""Select the proper update feed for the current update track."""
if config.get_bool('beta_optin'):
print("Checking Using Beta")
return 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
print("Checking Live")
return 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
# TODO: Add Dep Warning
update_feed = get_update_feed()

View File

@ -494,10 +494,29 @@ class PreferencesDialog(tk.Toplevel):
self.hotkey_play_btn.grid(columnspan=4, padx=self.BUTTONX, pady=self.PADY, sticky=tk.W, row=row.get())
# Option to disabled Automatic Check For Updates whilst in-game
# Options to select the Update Path and Disable Automatic Checks For Updates whilst in-game
ttk.Separator(config_frame, orient=tk.HORIZONTAL).grid(
columnspan=4, padx=self.PADX, pady=self.SEPY, sticky=tk.EW, row=row.get()
)
with row as curr_row:
nb.Label(config_frame, text=tr.tl('Update Track')).grid( # LANG: Select the Update Track (Beta, Stable)
padx=self.PADX, pady=self.PADY, sticky=tk.W, row=curr_row
)
self.curr_update_track = "Beta" if config.get_bool('beta_optin') else "Stable"
self.update_paths = tk.StringVar(value=self.curr_update_track)
# TODO: LANG
update_paths = [
tr.tl("Stable"), # LANG: Stable Version of EDMC
tr.tl("Beta") # LANG: Beta Version of EDMC
]
self.update_track = nb.OptionMenu(
config_frame, self.update_paths, self.update_paths.get(), *update_paths
)
self.update_track.configure(width=15)
self.update_track.grid(column=1, pady=self.BOXY, sticky=tk.W, row=curr_row)
self.disable_autoappupdatecheckingame = tk.IntVar(value=config.get_int('disable_autoappupdatecheckingame'))
self.disable_autoappupdatecheckingame_btn = nb.Checkbutton(
config_frame,
@ -1196,7 +1215,7 @@ class PreferencesDialog(tk.Toplevel):
config.set('hotkey_mods', self.hotkey_mods)
config.set('hotkey_always', int(not self.hotkey_only.get()))
config.set('hotkey_mute', int(not self.hotkey_play.get()))
config.set('beta_optin', 0 if self.update_paths.get() == "Stable" else 1)
config.set('shipyard_provider', self.shipyard_provider.get())
config.set('system_provider', self.system_provider.get())
config.set('station_provider', self.station_provider.get())
@ -1220,9 +1239,14 @@ class PreferencesDialog(tk.Toplevel):
config.set('dark_highlight', self.theme_colors[1])
theme.apply(self.parent)
# Send to the Post Config if we updated the update branch
post_flags = {
'Update': True if self.curr_update_track != self.update_paths.get() else False,
'Track': self.update_paths.get()
}
# Notify
if self.callback:
self.callback()
self.callback(**post_flags)
plug.notify_prefs_changed(monitor.cmdr, monitor.is_beta)

View File

@ -14,7 +14,7 @@ from typing import TYPE_CHECKING
from xml.etree import ElementTree
import requests
import semantic_version
from config import appname, appversion_nobuild, config, update_feed
from config import appname, appversion_nobuild, config, get_update_feed
from EDMCLogging import get_main_logger
from l10n import translations as tr
@ -90,7 +90,7 @@ class Updater:
self.updater: ctypes.CDLL | None = ctypes.cdll.WinSparkle
# Set the appcast URL
self.updater.win_sparkle_set_appcast_url(update_feed.encode())
self.updater.win_sparkle_set_appcast_url(get_update_feed().encode())
# Set the appversion *without* build metadata, as WinSparkle
# doesn't do proper Semantic Version checks.
@ -146,7 +146,7 @@ class Updater:
newversion = None
items = {}
try:
request = requests.get(update_feed, timeout=10)
request = requests.get(get_update_feed(), timeout=10)
except requests.RequestException as ex:
logger.exception(f'Error retrieving update_feed file: {ex}')