Exemple #1
0
def collect_categories(mask_paths, displaymode):
    """Return a list of all category subclasses. Look for them in modules
       imported as module_mask % basename(f) where f is name of all files in path.
    """
    categories = []
    if displaymode == DISPLAY_MODE_TEXT:
        for mask, path in mask_paths:
            categories.extend(collect(mask, path, lambda obj: getattr(obj, "displayOnHubTUI", None) is not None))
    else:
        for mask, path in mask_paths:
            categories.extend(collect(mask, path, lambda obj: getattr(obj, "displayOnHubGUI", None) is not None))

    return categories
Exemple #2
0
def collect_categories(mask_paths, displaymode):
    """Return a list of all category subclasses. Look for them in modules
       imported as module_mask % basename(f) where f is name of all files in path.
    """
    categories = []
    if displaymode == DISPLAY_MODE_TEXT:
        for mask, path in mask_paths:
            categories.extend(collect(mask, path, lambda obj: getattr(obj, "displayOnHubTUI", None) is not None))
    else:
        for mask, path in mask_paths:
            categories.extend(collect(mask, path, lambda obj: getattr(obj, "displayOnHubGUI", None) is not None))

    return categories
Exemple #3
0
def collect_spokes(mask_paths, category):
    """Return a list of all spoke subclasses that should appear for a given
       category. Look for them in files imported as module_path % basename(f)

       :param mask_paths: list of mask, path tuples to search for classes
       :type mask_paths: list of (mask, path)

       :return: list of Spoke classes belonging to category
       :rtype: list of Spoke classes

    """
    spokes = []
    for mask, path in mask_paths:
        candidate_spokes = (collect(
            mask, path, lambda obj: hasattr(obj, "category") and obj.category
            is not None and obj.category.__name__ == category))
        # filter out any spokes from the candidates that have already been visited by the user before
        # (eq. before Anaconda or Initial Setup started) and should not be visible again
        visible_spokes = []
        for candidate in candidate_spokes:
            if screen_access.sam.get_screen_visited(candidate.__name__):
                log.info(
                    "Spoke %s will not be displayed because it has already been visited before.",
                    candidate.__name__)
            else:
                visible_spokes.append(candidate)
        spokes.extend(visible_spokes)

    return spokes
Exemple #4
0
def collect_spokes(mask_paths, category):
    """Return a list of all spoke subclasses that should appear for a given
       category. Look for them in files imported as module_path % basename(f)

       :param mask_paths: list of mask, path tuples to search for classes
       :type mask_paths: list of (mask, path)

       :return: list of Spoke classes belonging to category
       :rtype: list of Spoke classes

    """
    spokes = []
    for mask, path in mask_paths:
        candidate_spokes = (collect(mask, path,
                            lambda obj: hasattr(obj, "category") and obj.category is not None and obj.category.__name__ == category))
        # filter out any spokes from the candidates that have already been visited by the user before
        # (eq. before Anaconda or Initial Setup started) and should not be visible again
        visible_spokes = []
        for candidate in candidate_spokes:
            if screen_access.sam.get_screen_visited(candidate.__name__):
                log.info("Spoke %s will not be displayed because it has already been visited before.",
                         candidate.__name__)
            else:
                visible_spokes.append(candidate)
        spokes.extend(visible_spokes)

    return spokes
Exemple #5
0
    def _get_available_classes(self, paths):
        """Return a list of available install classes."""
        # Append the location of install classes to the python path
        # so install classes can import and inherit correct classes.
        sys.path = paths + sys.path

        classes = set()
        for path in paths:
            log.debug("Searching %s.", path)

            for install_class in collect("%s", path, self._is_install_class):
                log.debug("Found %s.", self._get_class_description(install_class))
                classes.add(install_class)

        # Classes are sorted by their priority and name in the reversed order,
        # so classes with the highest priority and longer name are preferred.
        # For example, Fedora Workstation doesn't have higher priority.
        return sorted(classes, key=self._get_install_class_key, reverse=True)
Exemple #6
0
    def _get_available_classes(self, paths):
        """Return a list of available install classes."""
        # Append the location of install classes to the python path
        # so install classes can import and inherit correct classes.
        sys.path = paths + sys.path

        classes = set()
        for path in paths:
            log.debug("Searching %s.", path)

            for install_class in collect("%s", path, self._is_install_class):
                log.debug("Found %s.",
                          self._get_class_description(install_class))
                classes.add(install_class)

        # Classes are sorted by their priority and name in the reversed order,
        # so classes with the highest priority and longer name are preferred.
        # For example, Fedora Workstation doesn't have higher priority.
        return sorted(classes, key=self._get_install_class_key, reverse=True)
Exemple #7
0
    def _collectActionClasses(self, module_pattern_w_path, standalone_class):
        """Collect all the Hub and Spoke classes which should be enqueued for processing.

        :param module_pattern_w_path: the full name patterns (pyanaconda.ui.gui.spokes.%s)
                                      and directory paths to modules we are about to import
        :type module_pattern_w_path: list of (string, string)

        :param standalone_class: the parent type of Spokes we want to pick up
        :type standalone_class: common.StandaloneSpoke based types

        :return: list of Spoke classes with standalone_class as a parent
        :rtype: list of Spoke classes
        """
        standalones = []

        for module_pattern, path in module_pattern_w_path:
            standalones.extend(collect(module_pattern, path, lambda obj: issubclass(obj, standalone_class) and \
                                       getattr(obj, "preForHub", False) or getattr(obj, "postForHub", False)))

        return standalones
import os, sys

from pyanaconda.iutil import collect

# FIXME: Storage tests don't want to work right now, so they are disabled while
# I debug them so we can get useful data from other tests.
os._exit(77)

if os.geteuid() != 0:
    sys.stderr.write("You must be root to run the storage tests; skipping.\n")
    # This return code tells the automake test driver that this test was skipped.
    os._exit(77)

if "top_srcdir" not in os.environ:
    sys.stderr.write("$top_srcdir must be defined in the test environment\n")
    # This return code tells the automake test driver that the test setup failed
    sys.exit(99)

failures = 0

classes = collect("cases.%s",
                  os.path.abspath(os.path.join(os.environ["top_srcdir"], "tests/storage/cases/")),
                  lambda obj: getattr(obj, "desc", None) is not None)

for tc in classes:
    obj = tc()
    failures += obj.run()

os._exit(failures)
from pyanaconda.iutil import collect

# FIXME: Storage tests don't want to work right now, so they are disabled while
# I debug them so we can get useful data from other tests.
os._exit(77)

if os.geteuid() != 0:
    sys.stderr.write("You must be root to run the storage tests; skipping.\n")
    # This return code tells the automake test driver that this test was skipped.
    os._exit(77)

if "top_srcdir" not in os.environ:
    sys.stderr.write("$top_srcdir must be defined in the test environment\n")
    # This return code tells the automake test driver that the test setup failed
    sys.exit(99)

failures = 0

classes = collect(
    "cases.%s",
    os.path.abspath(
        os.path.join(os.environ["top_srcdir"], "tests/storage/cases/")),
    lambda obj: getattr(obj, "desc", None) is not None)

for tc in classes:
    obj = tc()
    failures += obj.run()

os._exit(failures)