From 8929197010dc4df4dc1563ba0c8e5c50613b3183 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 26 Apr 2022 10:55:19 +0200 Subject: [PATCH] drivers: include source.search_drivers in GET /drivers The search_drivers attribute is set at the source model level, not at the the drivers model level. Having said that, by adding its value in the response to GET /drivers, we can avoid doing multiple HTTP calls in the make_ui function. Signed-off-by: Olivier Gayot --- subiquity/client/controllers/drivers.py | 6 ++---- subiquity/common/types.py | 2 ++ subiquity/server/controllers/drivers.py | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/subiquity/client/controllers/drivers.py b/subiquity/client/controllers/drivers.py index 82442338..e5efe49a 100644 --- a/subiquity/client/controllers/drivers.py +++ b/subiquity/client/controllers/drivers.py @@ -31,13 +31,11 @@ class DriversController(SubiquityTuiController): endpoint_name = 'drivers' async def make_ui(self) -> DriversView: - source_endpoint = self.app.client.source - source_response = await source_endpoint.GET() + response: DriversResponse = await self.endpoint.GET() - if not source_response.search_drivers: + if not response.search_drivers: raise Skip - response: DriversResponse = await self.endpoint.GET() return DriversView(self, response.drivers, response.install, response.local_only) diff --git a/subiquity/common/types.py b/subiquity/common/types.py index cf39d081..1dfa5c4a 100644 --- a/subiquity/common/types.py +++ b/subiquity/common/types.py @@ -399,10 +399,12 @@ class DriversResponse: to do it. It will bet set to None until we figure out what drivers are available. :local_only: tells if we are looking for drivers only from the ISO. + :search_drivers: enables or disables drivers listing. """ install: bool drivers: Optional[List[str]] local_only: bool + search_drivers: bool @attr.s(auto_attribs=True) diff --git a/subiquity/server/controllers/drivers.py b/subiquity/server/controllers/drivers.py index 325b4f26..ade96456 100644 --- a/subiquity/server/controllers/drivers.py +++ b/subiquity/server/controllers/drivers.py @@ -102,9 +102,12 @@ class DriversController(SubiquityController): if wait: await asyncio.shield(self._drivers_task) + search_drivers = self.app.controllers.Source.model.search_drivers + return DriversResponse(install=self.model.do_install, drivers=self.drivers, - local_only=local_only) + local_only=local_only, + search_drivers=search_drivers) async def POST(self, data: DriversPayload) -> None: self.model.do_install = data.install