Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified locale/cs/LC_MESSAGES/timetracker.mo
Binary file not shown.
738 changes: 379 additions & 359 deletions locale/cs/LC_MESSAGES/timetracker.po

Large diffs are not rendered by default.

Binary file modified locale/de/LC_MESSAGES/timetracker.mo
Binary file not shown.
742 changes: 382 additions & 360 deletions locale/de/LC_MESSAGES/timetracker.po

Large diffs are not rendered by default.

Binary file modified locale/en/LC_MESSAGES/timetracker.mo
Binary file not shown.
741 changes: 381 additions & 360 deletions locale/en/LC_MESSAGES/timetracker.po

Large diffs are not rendered by default.

Binary file modified locale/es/LC_MESSAGES/timetracker.mo
Binary file not shown.
742 changes: 382 additions & 360 deletions locale/es/LC_MESSAGES/timetracker.po

Large diffs are not rendered by default.

Binary file modified locale/fr/LC_MESSAGES/timetracker.mo
Binary file not shown.
742 changes: 382 additions & 360 deletions locale/fr/LC_MESSAGES/timetracker.po

Large diffs are not rendered by default.

727 changes: 370 additions & 357 deletions locale/timetracker.pot

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions sl/SL_Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from i18n import _

try:
from update import restore_previous_version
from update import restore_previous_version, check_for_updates, apply_update
UPDATE_MODULE_AVAILABLE = True
except (ImportError, ModuleNotFoundError):
UPDATE_MODULE_AVAILABLE = False
Expand Down Expand Up @@ -303,6 +303,16 @@ def render_icon_button_css():
st.session_state.tracker = TimeTracker()
st.session_state.tracker.initialize_dependencies()
st.session_state.tracker.set_today_flag_for_due_tasks() # Set 'today' flag for tasks due today

# One check per session, not per rerun (Streamlit reruns this whole
# script on every click) - a frozen build has no loose source files for
# the update mechanism to overwrite (see update.py/TimeTrackerSL_GUI.py),
# so there's nothing to offer there.
st.session_state.update_check = {'available': False}
if UPDATE_MODULE_AVAILABLE and not getattr(sys, 'frozen', False):
is_available, new_version, url = check_for_updates(st.session_state.tracker.get_version())
if is_available:
st.session_state.update_check = {'available': True, 'version': new_version, 'url': url}
else:
# Reload from disk on every rerun (i.e. on every click/navigation), so
# changes made by another process sharing the same data file - the SOAP
Expand Down Expand Up @@ -430,11 +440,23 @@ def _auto_refresh_on_external_changes():

def render_header(title, subtitle=None):
"""
Renders the standard header for a view, including title, optional subtitle, and feedback messages.
Renders the standard header for a view: the app version (always, at the
very top, above the title), the view's title, an optional subtitle
below it, and any pending feedback message.

:param title: The main title of the view.
:param subtitle: An optional subtitle.
"""
st.caption(_("Version {version}").format(version=st.session_state.tracker.get_version()))
update_check = st.session_state.get('update_check', {})
if update_check.get('available'):
col_update_msg, col_update_btn = st.columns([10, 1])
with col_update_msg:
st.info(_("A new version ({version}) is available.").format(version=update_check['version']))
with col_update_btn:
if st.button("⟳", help=_("Restart and install the update"), key="update_restart_btn"):
with st.spinner(_("Downloading and installing update...")):
apply_update(update_check['url'])
st.title(title)
if subtitle:
st.caption(subtitle)
Expand Down
14 changes: 14 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ def download_update(url):
os.remove(UPDATE_ZIP_FILE) # Clean up partial download
return False

def apply_update(url):
"""
Downloads (if not already downloaded) and installs the given update,
then restarts the application in-place to run the new version.

:param url: The download URL for the update, as returned by check_for_updates().
"""
if not os.path.exists(UPDATE_ZIP_FILE):
if not download_update(url):
return
install_update()
print(_("Restarting application to apply the update..."))
os.execv(sys.executable, ['python'] + sys.argv)

def install_update():
"""
Installs the downloaded update by extracting the zip file and overwriting old files.
Expand Down
Loading