Commit Graph

35 Commits

Author SHA1 Message Date
Olivier Gayot 76815d6fa1 views: redraw screen after receiving event
Views that are dynamically updated using asynchronous events that are
handled by urwid need to be redrawn.

Ensure that such events trigger a redraw.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-05-02 14:07:35 +02:00
Olivier Gayot 020dcc0b88 ui: redraw screens after moving from one screen to another
Wieh urwid > 2.1.2, the screen is only redrawn after urwid handles an
event (e.g., keypress, resize, ...) or an urwid alarm (it is like a
timer).

All other changes made to the UI do not trigger a screen redraw. We now
redraw the screen properly after moving from one screen to another.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-03-28 10:04:11 +01:00
Olivier Gayot c95261e0de ui: have a distinct state file for rich mode over serial
We recently made sure that after doing a snap refresh, the rich mode
(i.e., either rich or basic) is preserved. This was implemented by
storing the rich mode in a state file. When the client starts, it loads
the rich mode from said state file if it exists.

Unfortunately, on s390x, it causes installs to default to basic mode.
This happens because on this architecture, a subiquity install consists
of:

 * a first client (over serial) showing the SSH password
 * a second client (logging over SSH) actually going through the
   installation UI.

Since the first client uses a serial connection, the state file is
created with rich-mode set to basic. Upon connecting using SSH, the
state file is read and the rich-mode is set to basic as well.

Fixed by storing the rich-mode in two separate files, one for clients
over serial and one for other clients.

LP: #2036096

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-22 09:27:13 +02:00
Michael Hudson-Doyle a4c924f1f9 persist rich mode across updates 2023-08-08 14:16:36 +12:00
Michael Hudson-Doyle ce9a130f37 make initial setup of rich mode less confusing 2023-08-08 14:07:10 +12:00
Dan Bungert 34d40643ad format with black + isort 2023-07-25 15:27:42 -06:00
Dan Bungert 9d12871f15 many: s/create_task/run_bg_task/
create_task has the following note:
  Important: Save a reference to the result of this function, to avoid a
  task disappearing mid-execution.

Convert existing usage of create_task to run_bg_task, if that
create_task is not actually storing the result.
2023-02-13 14:56:07 -07:00
Michael Hudson-Doyle 50ac03eacb Remove Application.aio_loop attribute 2022-12-08 12:52:14 +13:00
Michael Hudson-Doyle 06d7f04032 remove --script/--click command line arguments
I implemented these a long time ago to help working on parts of the ui
by allowing a way to script moving past some screens. I haven't used
them in ages, it's pretty bad code and probably a fragmentary answers
file is a better solution to the same problem. What do you think?
2022-12-07 14:56:00 +13:00
Michael Hudson-Doyle 7aab0b5de4 rewrite Spinner to not require a loop parameter 2022-12-07 14:19:27 +13:00
Michael Hudson-Doyle 85b3cd0724 switch from loop.create_task to asyncio.create_task
mostly done with sed
2022-11-08 10:08:46 +13:00
Olivier Gayot a62a0b6002 loop: start running the event loop before doing anything else
This allows us to use asyncio.run() and to avoid many pitfalls.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-10-28 17:05:54 +02:00
Olivier Gayot 2fdeb55218 snaplist: improve hack to display double stars instead of ✓
We used to rely on the narrow non-breakable space to be displayed as a
star in basic mode. This is not great and could impact other screens.

We now make use of two check-marks (each replaced by a star in basic
mode) and mask one of them in rich mode using display attributes.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-05-10 09:45:25 +02:00
Olivier Gayot e5017256a2 snaplist: add visual indication for starred publishers
In addition to verified publishers being indicated by a check-mark, we
now have starred publishers indicated with a circled star.

If unicode support is not available, for instance with serial
connections, we use a different number of stars to represent:

 * verified publishers: 2 stars
 * starred publishers: 1 star
 * others: no star

Because our mechanism to substitute unicode characters with ascii
equivalents expect a 1:1 mapping, we cannot simply replace the circled
start by two stars. To workaround the issue, we added a narrow
non-breakable space.

When support of unicode is available, this character shows up as a
normal space.
When support of unicode is not available, it gets replaced by a star.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-05-04 10:32:32 +02:00
Olivier Gayot cb132611c2 ui: get rid of unreachable else block
The following commit added an unconditional return statement in the try
block of _move_screen, effectively making the associated else block
unreachable.

  a7bcc7fa add a way to wait for something with notification after 0.1s

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-13 18:34:46 +02:00
Olivier Gayot 014d9d0d01 ui: introduce an optional level of indirection in make_ui
The make_ui() function / coroutine returns a BaseView (i.e., a
screen to display to the user).

That being said, when the application calls, make_ui(), it does not come
with a guarantee that the view returned will be displayed to the user
immediately.

One of the reason is that there are multiple await statements before the
we call the ui.set_body function. Therefore, tasks running concurrently
cannot reliably expect that they execute after the display is refreshed.

Perhaps more importantly, when the make_ui() function takes more than .1
second to execute, we display a "Progress" screen that stays visible for
at least one second. This can effectively delay a lot the moment when
the view returned by make_ui() is shown to the user. A lot can happen in
the meantime.

As the result, the view returned by make_ui can be outdated by the time
we show it on the screen.

One way to work around this problem is to store in the controller a
reference to the view that it returns in make_ui(). This way, the
controller can modify the view and keep it up-to-date until it gets
shown to the user.

Unfortunately, some controllers (e.g., the storage controller) do not
modify / mutate the existing view object when a modification is needed ;
but instead instantiate a new view object.

This patch introduces a level of indirection that can be used by these
controllers. Instead of returning a view object from make_ui(), the
controllers are now allowed to return a callback ; which in turn will
return a view object.

https://bugs.launchpad.net/subiquity/+bug/1968161

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-13 18:34:46 +02:00
Dan Bungert 2719c57c1b
locale - let it check interactive-sections again (#937)
* locale - let it check interactive-sections again

* Turn Serial into a whole new screen

When in serial, first offer the rich/basic choice (or SSH button),
and only show the current welcome screen if we choose rich mode.
Add a back button on Welcome if we are on serial.

LP: #1919251
2021-04-21 10:11:27 -06:00
Michael Hudson-Doyle b0af11ad02 kill any foreground subprocess before restarting
This fixes a problem where you drop to a shell and refresh subiquity
from that shell -- the client tries to restart but it is running in the
background and so crashes trying to modify the terminal settings. So
this kills the subprocess before restarting. This required the extremely
angry PR I sent before: forcefully killing the subprocess also crashes
the client before restart in a similar way.
2021-04-01 17:24:49 +13:00
Michael Hudson-Doyle 939c81920c do not crash when subshell exits via signal
Here is something you can try with a live server installer today: drop
into a subshell and type "kill -9 $$". The installer will crash with an
'Input/output error' from tcsetattr.

What's going on is some deep unix arcana: when the subshell exits via
signal somehow the shell's process group is still in the foreground
(even though there are no processes in it?) and calling tcsetattr() from
a background process is not allowed. So the fix for this is reasonably
simple (or at least: short): call tcsetpgrp() to put our process group
back into the foreground. A background process doing this gets sent
SIGTTOU, but if we ignore that, all is well.

Frankly this is all very strange and I would like a lie down now.
2021-04-01 16:27:05 +13:00
Michael Hudson-Doyle 64ac97aafe make subiquity client use new API for guided disk usage 2021-03-30 14:22:28 +13:00
Michael Hudson-Doyle fac0eeed43 fix crash when trying to view nic info
fixes half of https://bugs.launchpad.net/subiquity/+bug/1912955
2021-01-27 09:35:09 +13:00
Michael Hudson-Doyle 673ade7f2a make core interface a little simpler 2020-10-09 13:12:09 +13:00
Michael Hudson-Doyle c03f6580fd move more code that should never have been so generic 2020-10-09 13:08:15 +13:00
Michael Hudson-Doyle 2bf981ebb8 move "last-screen" handling out of generic code 2020-10-09 13:07:04 +13:00
Michael Hudson-Doyle 7d02ee17f6 make zdev view/controller interface more client/server friendly 2020-09-21 21:04:14 +12:00
Michael Hudson-Doyle 56441c6f97 small tidies 2020-09-18 22:01:36 +12:00
Michael Hudson-Doyle 9b414df0eb add a helper to wait and show a dialog if needed
use this in snaplist view. cancellation with asyncio is mindbending!
2020-09-18 21:51:14 +12:00
Michael Hudson-Doyle a7bcc7faf0 add a way to wait for something with notification after 0.1s
use this for moving between screens, removing some crummy code from subquity/core.py
2020-09-18 21:18:27 +12:00
Michael Hudson-Doyle 6c258d6da4 allow make_ui to be a coroutine 2020-09-18 11:52:19 +12:00
Michael Hudson-Doyle f0082c2068 change controller api to return a view, rather than setting it 2020-09-18 11:44:00 +12:00
Michael Hudson-Doyle aa3bce4414 do not run the urwid loop at all when not interactive 2020-09-18 09:54:50 +12:00
Michael Hudson-Doyle 45009e3a12 refactor startup a little
the point of this is to have the event loop running while loading
autoinstall commands, which means we do not have to start and stop the
event loop inside load_autoinstall_config if there are early-commands to
run.
2020-09-18 09:54:50 +12:00
Michael Hudson-Doyle edc65dbbfb make the base controller have no ui, add subclass for one that has ui 2020-08-23 23:18:28 +12:00
Michael Hudson-Doyle f6757af8d1 fix restarting after refresh 2020-08-23 23:18:28 +12:00
Michael Hudson-Doyle ccd8c2382e split urwid-using bits out of subiquitycore.core.Application 2020-08-23 23:18:26 +12:00