Merge branch 'SeedSigner:dev' into update-docs

This commit is contained in:
Kshitij
2025-08-09 20:51:01 +05:30
committed by GitHub
4 changed files with 47 additions and 28 deletions
+3 -3
View File
@@ -211,19 +211,19 @@ WorkingDirectory=/home/pi/seedsigner/src/
ExecStart=/usr/bin/python3 main.py
StandardOutput=null
ErrorOutput=null
Restart=always
Restart=no
[Install]
WantedBy=multi-user.target
```
_Note: For local dev you'll want to edit the `Restart=always` line to `Restart=no`. This way when your dev code crashes it won't keep trying to restart itself. Note that the UI "Reset" will no longer work when auto-restarts are disabled._
_Note: The line `Restart=no` ensures that when your dev code crashes it won't keep trying to restart itself._
_Note: Debugging output is completely wiped via routing the stdout and stderr to `/dev/null`. When working in local dev, you'll `kill` the `systemd` SeedSigner service and just directly run the code on demand so you can see all the debugging output live._
Use `CTRL-X` and `y` to exit and save changes.
Configure the service to start running (this will restart the seedsigner code automatically at startup and if it crashes):
Configure the service to start running (this will restart the seedsigner code automatically at startup):
```bash
sudo systemctl enable seedsigner.service
```
+15 -13
View File
@@ -366,23 +366,18 @@ class SeedAddPassphraseView(View):
# The new passphrase will be the return value; it might be empty.
self.seed.set_passphrase(ret_dict["passphrase"])
if "is_back_button" in ret_dict:
if len(self.seed.passphrase) > 0:
return Destination(SeedAddPassphraseExitDialogView)
else:
return Destination(BackStackView)
elif len(self.seed.passphrase) > 0:
return Destination(SeedReviewPassphraseView)
if "is_back_button" in ret_dict or len(self.seed.passphrase) == 0:
return Destination(SeedAddPassphraseExitDialogView)
else:
return Destination(SeedFinalizeView)
return Destination(SeedReviewPassphraseView)
class SeedAddPassphraseExitDialogView(View):
EDIT = ButtonOption("Edit passphrase")
DISCARD = ButtonOption("Discard passphrase", button_label_color="red")
SKIP = ButtonOption("Skip passphrase") # NOT red since we're not throwing anything away
def __init__(self):
super().__init__()
@@ -390,13 +385,20 @@ class SeedAddPassphraseExitDialogView(View):
def run(self):
button_data = [self.EDIT, self.DISCARD]
if self.seed.passphrase:
title = _("Discard passphrase?")
message = _("Your current passphrase entry will be erased.")
button_data = [self.EDIT, self.DISCARD]
else:
title = _("Skip passphrase?")
message = _("You have not entered a passphrase yet.")
button_data = [self.EDIT, self.SKIP]
selected_menu_num = self.run_screen(
WarningScreen,
title=_("Discard passphrase?"),
title=title,
status_headline=None,
text=_("Your current passphrase entry will be erased"),
text=message,
show_back_button=False,
button_data=button_data,
)
@@ -404,7 +406,7 @@ class SeedAddPassphraseExitDialogView(View):
if button_data[selected_menu_num] == self.EDIT:
return Destination(SeedAddPassphraseView)
elif button_data[selected_menu_num] == self.DISCARD:
elif button_data[selected_menu_num] in [self.DISCARD, self.SKIP]:
self.seed.set_passphrase("")
return Destination(SeedFinalizeView)
+27 -10
View File
@@ -1,3 +1,4 @@
import logging
from dataclasses import dataclass
from gettext import gettext as _
from typing import Type
@@ -10,6 +11,9 @@ from seedsigner.models.settings import Settings, SettingsConstants
from seedsigner.models.settings_definition import SettingsDefinition
from seedsigner.models.threads import BaseThread
logger = logging.getLogger(__name__)
class BackStackView:
"""
@@ -242,30 +246,43 @@ class PowerOptionsView(View):
return Destination(PowerOffView)
@dataclass
class RestartView(View):
is_screenshot_renderer: bool = False
def __post_init__(self):
super().__post_init__()
self.thread = self.DoResetThread()
def run(self):
if self.is_screenshot_renderer:
# For the screenshot generator, we don't actually want to restart
return
logger.info("Restarting SeedSigner")
from seedsigner.gui.screens.screen import ResetScreen
thread = RestartView.DoResetThread()
thread.start()
self.thread.start()
self.run_screen(ResetScreen)
class DoResetThread(BaseThread):
def run(self):
import os
import sys
import time
from subprocess import call
# Give the screen just enough time to display the reset message before
# exiting.
time.sleep(0.25)
# Kill the SeedSigner process; Running the process again.
# `.*` is a wildcard to detect either `python`` or `python3`.
if Settings.HOSTNAME == Settings.SEEDSIGNER_OS:
call("kill $(pidof python*) & python /opt/src/main.py", shell=True)
else:
call("kill $(ps aux | grep '[p]ython.*main.py' | awk '{print $2}')", shell=True)
# Flush any buffered data.
sys.stdout.flush()
sys.stderr.flush()
# Replace the current process with a new one.
os.execv(sys.executable, [sys.executable] + sys.argv)
+1 -1
View File
@@ -275,7 +275,7 @@ def generate_screenshots(locale):
ScreenshotConfig(MainMenuView, screenshot_name='MainMenuView_DireWarningToast', toast_thread=DireWarningToast("This is a dire warning toast!", activation_delay=0, duration=0)),
ScreenshotConfig(MainMenuView, screenshot_name='MainMenuView_ErrorToast', toast_thread=ErrorToast("This is an error toast!", activation_delay=0, duration=0)),
ScreenshotConfig(PowerOptionsView),
ScreenshotConfig(RestartView),
ScreenshotConfig(RestartView, dict(is_screenshot_renderer=True)),
ScreenshotConfig(PowerOffView),
],
"Seed Views": [