console_conf: fix showing error messages, when snap create-user fails
This commit is contained in:
parent
2ea7f6cd5a
commit
6de8970560
|
@ -156,8 +156,9 @@ class IdentityController(BaseController):
|
||||||
cp = run_command(
|
cp = run_command(
|
||||||
["snap", "create-user", "--sudoer", "--json", email])
|
["snap", "create-user", "--sudoer", "--json", email])
|
||||||
if cp.returncode != 0:
|
if cp.returncode != 0:
|
||||||
self.ui.body.error.set_text(
|
if isinstance(self.ui.body, IdentityView):
|
||||||
"Creating user failed:\n" + cp.stderr)
|
self.ui.body.snap_create_user_failed(
|
||||||
|
"Creating user failed:", cp.stderr)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
data = json.loads(cp.stdout)
|
data = json.loads(cp.stdout)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import logging
|
||||||
from urwid import connect_signal
|
from urwid import connect_signal
|
||||||
|
|
||||||
from subiquitycore.view import BaseView
|
from subiquitycore.view import BaseView
|
||||||
|
from subiquitycore.ui.utils import SomethingFailed
|
||||||
from subiquitycore.ui.form import (
|
from subiquitycore.ui.form import (
|
||||||
Form,
|
Form,
|
||||||
EmailField,
|
EmailField,
|
||||||
|
@ -55,3 +56,6 @@ class IdentityView(BaseView):
|
||||||
|
|
||||||
def done(self, result):
|
def done(self, result):
|
||||||
self.controller.identity_done(result.email.value)
|
self.controller.identity_done(result.email.value)
|
||||||
|
|
||||||
|
def snap_create_user_failed(self, msg, stderr):
|
||||||
|
self.show_stretchy_overlay(SomethingFailed(self, msg, stderr))
|
||||||
|
|
|
@ -28,7 +28,6 @@ from subiquitycore.view import (
|
||||||
from subiquitycore.ui.buttons import (
|
from subiquitycore.ui.buttons import (
|
||||||
cancel_btn,
|
cancel_btn,
|
||||||
ok_btn,
|
ok_btn,
|
||||||
other_btn,
|
|
||||||
)
|
)
|
||||||
from subiquitycore.ui.container import (
|
from subiquitycore.ui.container import (
|
||||||
ListBox,
|
ListBox,
|
||||||
|
@ -49,6 +48,7 @@ from subiquitycore.ui.stretchy import (
|
||||||
from subiquitycore.ui.utils import (
|
from subiquitycore.ui.utils import (
|
||||||
button_pile,
|
button_pile,
|
||||||
screen,
|
screen,
|
||||||
|
SomethingFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
from subiquity.ui.views.identity import (
|
from subiquity.ui.views.identity import (
|
||||||
|
@ -217,26 +217,6 @@ class ConfirmSSHKeys(Stretchy):
|
||||||
self.parent.controller.done(self.result)
|
self.parent.controller.done(self.result)
|
||||||
|
|
||||||
|
|
||||||
class FetchingSSHKeysFailed(Stretchy):
|
|
||||||
def __init__(self, parent, msg, stderr):
|
|
||||||
self.parent = parent
|
|
||||||
ok = other_btn(label=_("Close"), on_press=self.close)
|
|
||||||
widgets = [
|
|
||||||
Text(msg),
|
|
||||||
Text(""),
|
|
||||||
Text(stderr.strip('\n')),
|
|
||||||
Text(""),
|
|
||||||
button_pile([ok]),
|
|
||||||
]
|
|
||||||
super().__init__(
|
|
||||||
"",
|
|
||||||
widgets,
|
|
||||||
2, 4)
|
|
||||||
|
|
||||||
def close(self, sender):
|
|
||||||
self.parent.remove_overlay()
|
|
||||||
|
|
||||||
|
|
||||||
class SSHView(BaseView):
|
class SSHView(BaseView):
|
||||||
|
|
||||||
title = _("SSH Setup")
|
title = _("SSH Setup")
|
||||||
|
@ -318,4 +298,4 @@ class SSHView(BaseView):
|
||||||
|
|
||||||
def fetching_ssh_keys_failed(self, msg, stderr):
|
def fetching_ssh_keys_failed(self, msg, stderr):
|
||||||
self.remove_overlay()
|
self.remove_overlay()
|
||||||
self.show_stretchy_overlay(FetchingSSHKeysFailed(self, msg, stderr))
|
self.show_stretchy_overlay(SomethingFailed(self, msg, stderr))
|
||||||
|
|
|
@ -30,7 +30,9 @@ from urwid import (
|
||||||
WidgetDisable,
|
WidgetDisable,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.ui.buttons import other_btn
|
||||||
from subiquitycore.ui.container import ListBox, Pile
|
from subiquitycore.ui.container import ListBox, Pile
|
||||||
|
from subiquitycore.ui.stretchy import Stretchy
|
||||||
from subiquitycore.ui.table import TableRow
|
from subiquitycore.ui.table import TableRow
|
||||||
from subiquitycore.ui.width import widget_width
|
from subiquitycore.ui.width import widget_width
|
||||||
|
|
||||||
|
@ -330,3 +332,23 @@ def make_action_menu_row(
|
||||||
def rewrap(text):
|
def rewrap(text):
|
||||||
paras = text.split("\n\n")
|
paras = text.split("\n\n")
|
||||||
return "\n\n".join([p.replace('\n', ' ') for p in paras]).strip()
|
return "\n\n".join([p.replace('\n', ' ') for p in paras]).strip()
|
||||||
|
|
||||||
|
|
||||||
|
class SomethingFailed(Stretchy):
|
||||||
|
def __init__(self, parent, msg, stderr):
|
||||||
|
self.parent = parent
|
||||||
|
ok = other_btn(label=_("Close"), on_press=self.close)
|
||||||
|
widgets = [
|
||||||
|
Text(msg),
|
||||||
|
Text(""),
|
||||||
|
Text(stderr.strip('\n')),
|
||||||
|
Text(""),
|
||||||
|
button_pile([ok]),
|
||||||
|
]
|
||||||
|
super().__init__(
|
||||||
|
"",
|
||||||
|
widgets,
|
||||||
|
2, 4)
|
||||||
|
|
||||||
|
def close(self, sender):
|
||||||
|
self.parent.remove_overlay()
|
||||||
|
|
Loading…
Reference in New Issue