From 9085f5eae83562d981361edaaf2ade7c6d4d110f Mon Sep 17 00:00:00 2001 From: Mirko Brombin Date: Sat, 24 Sep 2022 19:35:48 +0200 Subject: [PATCH] support showing pages conditionaly --- vanilla_first_setup/utils/builder.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vanilla_first_setup/utils/builder.py b/vanilla_first_setup/utils/builder.py index 1e8d7f7..1adc551 100644 --- a/vanilla_first_setup/utils/builder.py +++ b/vanilla_first_setup/utils/builder.py @@ -17,6 +17,7 @@ import os import sys import logging +import subprocess import json from gi.repository import Gio @@ -67,6 +68,24 @@ class Builder: logging.warning("No log will be stored.") for key, step in self.__recipe.raw["steps"].items(): + if step.get("display-conditions"): + _condition_met = False + for command in step["display-conditions"]: + try: + logger.info("Performing display-condition: %s" % command) + output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT) + if output.decode("utf-8") == "" or output.decode("utf-8") == "1": + logger.info("Step %s skipped due to display-conditions" % key) + break + except subprocess.CalledProcessError as e: + logger.info("Step %s skipped due to display-conditions" % key) + break + else: + _condition_met = True + + if not _condition_met: + continue + if step["template"] in templates: _widget = templates[step["template"]](self.__window, self.distro_info, key, step) self.__register_widgets.append(_widget)