add a dry-run hot key for pretending to run an install
This commit is contained in:
parent
5dc2895481
commit
2a53fce963
|
@ -431,17 +431,34 @@ class Subiquity(Application):
|
||||||
if key == 'f1':
|
if key == 'f1':
|
||||||
if not self.ui.right_icon.showing_something:
|
if not self.ui.right_icon.showing_something:
|
||||||
self.ui.right_icon.open_pop_up()
|
self.ui.right_icon.open_pop_up()
|
||||||
elif self.opts.dry_run and key in ['ctrl e', 'ctrl r']:
|
elif key in ['ctrl z', 'f2']:
|
||||||
|
self.debug_shell()
|
||||||
|
elif self.opts.dry_run:
|
||||||
|
self.unhandled_input_dry_run(key)
|
||||||
|
else:
|
||||||
|
super().unhandled_input(key)
|
||||||
|
|
||||||
|
def unhandled_input_dry_run(self, key):
|
||||||
|
if key == 'ctrl g':
|
||||||
|
import asyncio
|
||||||
|
from systemd import journal
|
||||||
|
|
||||||
|
async def mock_install():
|
||||||
|
async with self.install_lock_file.exclusive():
|
||||||
|
self.install_lock_file.write_content("nowhere")
|
||||||
|
journal.send(
|
||||||
|
"starting install", SYSLOG_IDENTIFIER="subiquity")
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
schedule_task(mock_install())
|
||||||
|
elif key in ['ctrl e', 'ctrl r']:
|
||||||
interrupt = key == 'ctrl e'
|
interrupt = key == 'ctrl e'
|
||||||
try:
|
try:
|
||||||
1/0
|
1/0
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
self.make_apport_report(
|
self.make_apport_report(
|
||||||
ErrorReportKind.UNKNOWN, "example", interrupt=interrupt)
|
ErrorReportKind.UNKNOWN, "example", interrupt=interrupt)
|
||||||
elif self.opts.dry_run and key == 'ctrl u':
|
elif key == 'ctrl u':
|
||||||
1/0
|
1/0
|
||||||
elif key in ['ctrl z', 'f2']:
|
|
||||||
self.debug_shell()
|
|
||||||
else:
|
else:
|
||||||
super().unhandled_input(key)
|
super().unhandled_input(key)
|
||||||
|
|
||||||
|
|
|
@ -181,10 +181,11 @@ GLOBAL_KEYS = (
|
||||||
)
|
)
|
||||||
|
|
||||||
DRY_RUN_KEYS = (
|
DRY_RUN_KEYS = (
|
||||||
(_('Control-X'), _('quit (dry-run only)')),
|
(_('Control-X'), _('quit')),
|
||||||
(_('Control-E'), _('generate noisy error report (dry-run only)')),
|
(_('Control-E'), _('generate noisy error report')),
|
||||||
(_('Control-R'), _('generate quiet error report (dry-run only)')),
|
(_('Control-R'), _('generate quiet error report')),
|
||||||
(_('Control-U'), _('crash the ui (dry-run only)')),
|
(_('Control-G'), _('pretend to run an install')),
|
||||||
|
(_('Control-U'), _('crash the ui')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,8 +196,11 @@ class GlobalKeyStretchy(Stretchy):
|
||||||
for key, text in GLOBAL_KEYS:
|
for key, text in GLOBAL_KEYS:
|
||||||
rows.append(TableRow([Text(_(key)), Text(_(text))]))
|
rows.append(TableRow([Text(_(key)), Text(_(text))]))
|
||||||
if app.opts.dry_run:
|
if app.opts.dry_run:
|
||||||
|
dro = _('(dry-run only)')
|
||||||
for key, text in DRY_RUN_KEYS:
|
for key, text in DRY_RUN_KEYS:
|
||||||
rows.append(TableRow([Text(_(key)), Text(_(text))]))
|
rows.append(TableRow([
|
||||||
|
Text(_(key)),
|
||||||
|
Text(_(text) + ' ' + dro)]))
|
||||||
table = TablePile(
|
table = TablePile(
|
||||||
rows, spacing=2, colspecs={1: ColSpec(can_shrink=True)})
|
rows, spacing=2, colspecs={1: ColSpec(can_shrink=True)})
|
||||||
widgets = [
|
widgets = [
|
||||||
|
|
Loading…
Reference in New Issue