Skip to content

Commit

Permalink
Candidate manual system upgrade menu action
Browse files Browse the repository at this point in the history
  • Loading branch information
woodcoder committed Apr 26, 2024
1 parent 8e2763f commit 3eb8021
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 40 deletions.
34 changes: 21 additions & 13 deletions ui/locale/canute.pot
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Translations template for PROJECT.
# Copyright (C) 2023 ORGANIZATION
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-12-20 14:35+0000\n"
"POT-Creation-Date: 2024-04-26 15:25+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -209,15 +209,15 @@ msgstr ""
msgid "go to book list"
msgstr ""

#: ui/library/view.py:73
#: ui/library/view.py:74
msgid "LIBRARY menu"
msgstr ""

#: ui/library/view.py:83
#: ui/library/view.py:84
msgid "back to directory list"
msgstr ""

#: ui/library/view.py:89
#: ui/library/view.py:90
msgid "more directories"
msgstr ""

Expand All @@ -232,31 +232,39 @@ msgid ""
"files in the library."
msgstr ""

#: ui/system_menu/system_menu.py:52
#: ui/system_menu/view.py:15
msgid "run in standalone mode"
msgstr ""

#: ui/system_menu/view.py:19
msgid "emulated"
msgstr ""

#: ui/system_menu/system_menu.py:62
#: ui/system_menu/view.py:34
msgid "shutdown"
msgstr ""

#: ui/system_menu/system_menu.py:63
#: ui/system_menu/view.py:35
msgid "backup log to USB stick"
msgstr ""

#: ui/system_menu/system_menu.py:64
#: ui/system_menu/view.py:36
msgid "select language and code"
msgstr ""

#: ui/system_menu/system_menu.py:68
#: ui/system_menu/view.py:37
msgid "install upgrade from "
msgstr ""

#: ui/system_menu/view.py:40
msgid "release:"
msgstr ""

#: ui/system_menu/system_menu.py:69
#: ui/system_menu/view.py:41
msgid "serial:"
msgstr ""

#: ui/system_menu/view.py:23
#: ui/system_menu/view.py:49
msgid "system menu"
msgstr ""

Binary file modified ui/locale/en_GB.UTF-8@ueb1/LC_MESSAGES/canute.mo
Binary file not shown.
33 changes: 21 additions & 12 deletions ui/locale/en_GB.UTF-8@ueb1/LC_MESSAGES/canute.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-11-08 10:00+0000\n"
"PO-Revision-Date: 2023-11-08 11:18+0000\n"
"POT-Creation-Date: 2024-04-26 15:25+0100\n"
"PO-Revision-Date: 2024-04-26 14:27+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -117,7 +117,7 @@ msgstr ""
"⠃⠥⠞⠞⠕⠝ ⠞⠕ ⠞⠓⠑ ⠇⠑⠋⠞ ⠕⠋ ⠦⠧⠊⠑⠺ ⠎⠽⠎⠞⠑⠍ ⠍⠑⠝⠥⠴\n"
"⠕⠝ ⠞⠓⠑ ⠙⠊⠎⠏⠇⠁⠽⠲"

#: ui/book/view.py:11
#: ui/book/view.py:10
msgid "go to page"
msgstr "⠛⠕ ⠞⠕ ⠏⠁⠛⠑"

Expand Down Expand Up @@ -291,15 +291,15 @@ msgstr ""
msgid "go to book list"
msgstr "⠛⠕⠀⠞⠕⠀⠃⠕⠕⠅⠀⠇⠊⠎⠞"

#: ui/library/view.py:73
#: ui/library/view.py:74
msgid "LIBRARY menu"
msgstr "⠠⠠⠇⠊⠃⠗⠁⠗⠽⠀⠍⠑⠝⠥"

#: ui/library/view.py:83
#: ui/library/view.py:84
msgid "back to directory list"
msgstr "⠃⠁⠉⠅⠀⠞⠕⠀⠙⠊⠗⠑⠉⠞⠕⠗⠽⠀⠇⠊⠎⠞"

#: ui/library/view.py:89
#: ui/library/view.py:90
msgid "more directories"
msgstr "⠍⠕⠗⠑⠀⠙⠊⠗⠑⠉⠞⠕⠗⠊⠑⠎"

Expand All @@ -322,29 +322,38 @@ msgstr ""
"⠇⠊⠃⠗⠁⠗⠽⠲"

#: ui/system_menu/system_menu.py:52
#: ui/system_menu/view.py:15
msgid "run in standalone mode"
msgstr "⠗⠥⠝⠀⠊⠝⠀⠎⠞⠁⠝⠙⠁⠇⠕⠝⠑⠀⠍⠕⠙⠑"

#: ui/system_menu/view.py:19
msgid "emulated"
msgstr "⠑⠍⠥⠇⠁⠞⠑⠙"

#: ui/system_menu/system_menu.py:62
#: ui/system_menu/view.py:34
msgid "shutdown"
msgstr "⠎⠓⠥⠞⠙⠕⠺⠝"

#: ui/system_menu/system_menu.py:63
#: ui/system_menu/view.py:35
msgid "backup log to USB stick"
msgstr "⠃⠁⠉⠅⠥⠏ ⠇⠕⠛ ⠞⠕ ⠠⠠⠥⠎⠃ ⠎⠞⠊⠉⠅"

#: ui/system_menu/system_menu.py:64
#: ui/system_menu/view.py:36
msgid "select language and code"
msgstr "⠎⠑⠇⠑⠉⠞ ⠇⠁⠝⠛⠥⠁⠛⠑ ⠁⠝⠙ ⠉⠕⠙⠑"

#: ui/system_menu/system_menu.py:68
#: ui/system_menu/view.py:37
msgid "install upgrade from "
msgstr "⠊⠝⠎⠞⠁⠇⠇⠀⠥⠏⠛⠗⠁⠙⠑⠀⠋⠗⠕⠍⠀"

#: ui/system_menu/view.py:40
msgid "release:"
msgstr "⠗⠑⠇⠑⠁⠎⠑⠒"

#: ui/system_menu/system_menu.py:69
#: ui/system_menu/view.py:41
msgid "serial:"
msgstr "⠎⠑⠗⠊⠁⠇⠒"

#: ui/system_menu/view.py:23
#: ui/system_menu/view.py:49
msgid "system menu"
msgstr "⠎⠽⠎⠞⠑⠍ ⠍⠑⠝⠥"
Binary file modified ui/locale/en_GB.UTF-8@ueb2/LC_MESSAGES/canute.mo
Binary file not shown.
34 changes: 21 additions & 13 deletions ui/locale/en_GB.UTF-8@ueb2/LC_MESSAGES/canute.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-11-08 10:00+0000\n"
"PO-Revision-Date: 2023-11-08 11:18+0000\n"
"POT-Creation-Date: 2024-04-26 15:25+0100\n"
"PO-Revision-Date: 2024-04-26 14:27+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -110,7 +110,7 @@ msgstr ""
"⠏⠗⠑⠎⠎ ⠮ ⠇⠔⠑ ⠎⠑⠇⠑⠉⠞ ⠃⠥⠞⠞⠕⠝ ⠞⠕ ⠮ ⠇⠑⠋⠞ ⠷\n"
"⠦⠧⠊⠑⠺ ⠎⠽⠌⠑⠍ ⠍⠢⠥⠴ ⠕⠝ ⠮ ⠲⠏⠇⠁⠽⠲"

#: ui/book/view.py:11
#: ui/book/view.py:10
msgid "go to page"
msgstr "⠛ ⠞⠕ ⠏⠁⠛⠑"

Expand Down Expand Up @@ -268,15 +268,15 @@ msgstr ""
msgid "go to book list"
msgstr "⠛⠀⠞⠕⠀⠃⠕⠕⠅⠀⠇⠊⠌"

#: ui/library/view.py:73
#: ui/library/view.py:74
msgid "LIBRARY menu"
msgstr "⠠⠠⠇⠊⠃⠗⠜⠽⠀⠍⠢⠥"

#: ui/library/view.py:83
#: ui/library/view.py:84
msgid "back to directory list"
msgstr "⠃⠁⠉⠅⠀⠞⠕⠀⠙⠊⠗⠑⠉⠞⠕⠗⠽⠀⠇⠊⠌"

#: ui/library/view.py:89
#: ui/library/view.py:90
msgid "more directories"
msgstr "⠍⠀⠙⠊⠗⠑⠉⠞⠕⠗⠊⠑⠎"

Expand All @@ -295,30 +295,38 @@ msgstr ""
"⠡⠁⠝⠛⠑ ⠮ ⠎⠽⠌⠑⠍ ⠇⠁⠝⠛⠥⠁⠛⠑ ⠕⠗ ⠠⠃⠗⠇ ⠉⠕⠙⠑⠂ ⠝ ⠮\n"
"⠇⠁⠝⠛⠥⠁⠛⠑ ⠕⠗ ⠉⠕⠙⠑ ⠷ ⠁⠝⠽ ⠋⠊⠇⠑⠎ ⠔ ⠮ ⠇⠊⠃⠗⠜⠽⠲"

#: ui/system_menu/system_menu.py:52
#: ui/system_menu/view.py:15
msgid "run in standalone mode"
msgstr "⠗⠥⠝⠀⠔⠀⠌⠯⠁⠇⠐⠕⠀⠍⠕⠙⠑"

#: ui/system_menu/view.py:19
msgid "emulated"
msgstr "⠑⠍⠥⠇⠁⠞⠫"

#: ui/system_menu/system_menu.py:62
#: ui/system_menu/view.py:34
msgid "shutdown"
msgstr "⠩⠥⠞⠙⠪⠝"

#: ui/system_menu/system_menu.py:63
#: ui/system_menu/view.py:35
msgid "backup log to USB stick"
msgstr "⠃⠁⠉⠅⠥⠏ ⠇⠕⠛ ⠞⠕ ⠠⠠⠥⠎⠃ ⠌⠊⠉⠅"

#: ui/system_menu/system_menu.py:64
#: ui/system_menu/view.py:36
msgid "select language and code"
msgstr "⠎⠑⠇⠑⠉⠞ ⠇⠁⠝⠛⠥⠁⠛⠑ ⠯ ⠉⠕⠙⠑"

#: ui/system_menu/system_menu.py:68
#: ui/system_menu/view.py:37
msgid "install upgrade from "
msgstr "⠔⠌⠁⠇⠇⠀⠥⠏⠛⠗⠁⠙⠑⠀⠋⠀"

#: ui/system_menu/view.py:40
msgid "release:"
msgstr "⠗⠑⠇⠂⠎⠑⠒"

#: ui/system_menu/system_menu.py:69
#: ui/system_menu/view.py:41
msgid "serial:"
msgstr "⠎⠻⠊⠁⠇⠒"

#: ui/system_menu/view.py:23
#: ui/system_menu/view.py:49
msgid "system menu"
msgstr "⠎⠽⠌⠑⠍ ⠍⠢⠥"
7 changes: 7 additions & 0 deletions ui/system_menu/buttons.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from ..state import state
from . import upgrade

def install_upgrade():
if upgrade.available:
upgrade.upgrade()

buttons = {
'single': {
'2': state.app.shutdown,
'3': state.app.go_to_language_menu,
'4': install_upgrade,
'R': state.app.help_menu.toggle,
'>': state.app.next_page,
'<': state.app.previous_page,
Expand All @@ -12,6 +18,7 @@
'long': {
'2': state.app.shutdown,
'3': state.app.go_to_language_menu,
'4': install_upgrade,
'R': state.app.help_menu.toggle,
'>': state.app.next_page,
'<': state.app.previous_page,
Expand Down
26 changes: 26 additions & 0 deletions ui/system_menu/upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from ..config_loader import load

def mounted_paths():
config = load()
media_dir = config.get('files', {}).get('media_dir')
source_dirs = config.get('files', {}).get('library', [])

for source_dir in source_dirs:
source_path = os.path.join(media_dir, source_dir.get('path'))
if source_dir.get('mountpoint', False) and os.path.ismount(source_path):
yield source_path, source_dir.get('name')

available = False
source_paths = mounted_paths()
for source_path, source_name in source_paths:
for upgrade in ['sysupgrade', 'sysupgrade.sh']:
upgrade_file = os.path.join(source_path, upgrade)
if os.path.exists(upgrade_file):
available = True
break

def upgrade():
go_file = os.path.join(source_path, 'sysupgrade-now.txt')
open(go_file, 'a').close()
os.system('shutdown -r now')
4 changes: 2 additions & 2 deletions ui/system_menu/view.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from ..braille import format_title, brailleify, from_unicode
from . import upgrade
from .help import render_help


# This exists on a Pi and reading it yields a useful board identifier.
# But existence will do for right now.
if os.path.exists('/sys/firmware/devicetree/base/model'):
Expand Down Expand Up @@ -34,7 +34,7 @@ async def render(width, height, state):
_('shutdown'),
_('backup log to USB stick'),
_('select language and code'),
'',
_('install upgrade from ') + upgrade.source_name if upgrade.available else '',
'',
'',
_('release:') + ' ' + release,
Expand Down

0 comments on commit 3eb8021

Please sign in to comment.