Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Aug 8, 2024
1 parent 525c2be commit 5b911ca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions subiquity/models/subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def is_postinstall_only(self, model_name):
)

def is_model_required(self, model_name):
log.debug(
f"is_model_required: {model_name=} {self._cur_install_model_names=} {self._cur_postinstall_model_names}"
)
return (
model_name in self._cur_install_model_names
or model_name in self._cur_postinstall_model_names
Expand Down
23 changes: 21 additions & 2 deletions subiquity/server/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,46 @@ def _active(self):
"""
if self.interactive_for_variants is None:
if self.model_name is None:
log.debug(f"_active {self.name}: True because !model_name")
return True
return self.app.base_model.is_model_required(self.model_name)

result = self.app.base_model.is_model_required(self.model_name)
log.debug(f"_active {self.name}: {result} because is_model_required")
return result
variant = self.app.base_model.source.current.variant
return variant in self.interactive_for_variants
result = variant in self.interactive_for_variants
log.debug(f"_active {self.name}: {result} because interactive_for_variants")
return result

def interactive(self):
if not self.app.autoinstall_config:
log.debug(
f"interactive {self.name}: return {self._active} because autoinstall_config"
)
return self._active
i_sections = self.app.autoinstall_config.get("interactive-sections", [])

if "*" in i_sections:
log.debug(
f'interactive {self.name}: return {self._active} because "*" in i_sections'
)
return self._active

if self.autoinstall_key in i_sections:
log.debug(
f"interactive {self.name}: return {self._active} because key {self.autoinstall_key} in i_sections"
)
return self._active

if (
self.autoinstall_key_alias is not None
and self.autoinstall_key_alias in i_sections
):
log.debug(
f"interactive {self.name}: return {self._active} because alias {self.autoinstall_key_alias} in i_sections"
)
return self._active
log.debug(f"interactive {self.name}: return default False")
return False

async def configured(self):
Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/controllers/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def run_mirror_selection_or_fallback(self, context):

@with_context()
async def apply_autoinstall_config(self, context):
# self.autoinstall_apply_started = True
self.autoinstall_apply_started = True
await self.run_mirror_selection_or_fallback(context)

def on_geoip(self):
Expand Down
7 changes: 5 additions & 2 deletions subiquity/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def tempdirs(*args, **kwargs):

@contextlib.asynccontextmanager
async def start_server_factory(factory, *args, allow_error: bool = False, **kwargs):
with tempfile.TemporaryDirectory() as tempdir:
# with tempfile.TemporaryDirectory() as tempdir:
with tempdirs() as tempdir:
socket_path = f"{tempdir}/socket"
conn = aiohttp.UnixConnector(path=socket_path)
async with aiohttp.ClientSession(connector=conn) as session:
Expand Down Expand Up @@ -1703,7 +1704,9 @@ async def _test_source(self, source_id, expected_driver):
with patch.dict(os.environ, {"SUBIQUITY_DEBUG": "has-drivers"}):
cfg = "examples/machines/simple.json"
extra = ["--source-catalog", "examples/sources/mixed.yaml"]
async with start_server(cfg, extra_args=extra) as inst:
async with start_server(
cfg, set_first_source=False, extra_args=extra
) as inst:
await inst.post("/source", source_id=source_id, search_drivers=True)

names = [
Expand Down

0 comments on commit 5b911ca

Please sign in to comment.