This file is indexed.

/usr/lib/python3/dist-packages/checkbox_ng/tools.py is in python3-checkbox-ng 0.23-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# This file is part of Checkbox.
#
# Copyright 2012-2015 Canonical Ltd.
# Written by:
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.

"""
:mod:`checkbox_ng.tools` -- top-level command line tools
========================================================
"""

import logging
import os

from plainbox.impl.clitools import SingleCommandToolMixIn
from plainbox.impl.clitools import ToolBase
from plainbox.impl.commands.cmd_selftest import SelfTestCommand
from plainbox.public import get_providers

from checkbox_ng import __version__ as version
from checkbox_ng.config import CheckBoxConfig
from checkbox_ng.tests import load_unit_tests


logger = logging.getLogger("checkbox.ng.tools")


class CheckboxToolBase(ToolBase):
    """
    Base class for all checkbox-ng tools.

    This class contains some shared code like configuration, providers, i18n
    and version handling.
    """

    def _load_config(self):
        return self.get_config_cls().get()

    def _load_providers(self):
        return get_providers()

    @classmethod
    def get_exec_version(cls):
        """
        Get the version of the checkbox-ng package
        """
        return cls.format_version_tuple(version)

    @classmethod
    def get_config_cls(cls):
        """
        Get particular sub-class of the Config class to use
        """
        return CheckBoxConfig

    def get_gettext_domain(self):
        """
        Get the 'checkbox-ng' gettext domain
        """
        return "checkbox-ng"

    def get_locale_dir(self):
        """
        Get an optional development locale directory specific to checkbox-ng
        """
        return os.getenv("CHECKBOX_NG_LOCALE_DIR", None)


class CheckboxTool(CheckboxToolBase):
    """
    Tool that implements the new checkbox command.

    This tool has two sub-commands:

        checkbox sru - to run stable release update testing
        checkbox check-config - to validate and display system configuration
    """

    @classmethod
    def get_exec_name(cls):
        return "checkbox"

    def add_subcommands(self, subparsers, early_ns=None):
        from checkbox_ng.commands.launcher import LauncherCommand
        from checkbox_ng.commands.sru import SRUCommand
        from checkbox_ng.commands.submit import SubmitCommand
        from plainbox.impl.commands.cmd_check_config import CheckConfigCommand
        SRUCommand(
            self._load_providers, self._load_config
        ).register_parser(subparsers)
        CheckConfigCommand(
            self._load_config
        ).register_parser(subparsers)
        SubmitCommand(
            self._load_config
        ).register_parser(subparsers)
        LauncherCommand(
            self._load_providers, self._load_config
        ).register_parser(subparsers)
        SelfTestCommand(load_unit_tests).register_parser(subparsers)


class CheckboxSubmitTool(SingleCommandToolMixIn, CheckboxToolBase):
    """
    A tool class that implements checkbox-submit.

    This tool implements the submit feature to send test results to the
    Canonical certification website
    """

    @classmethod
    def get_exec_name(cls):
        return "checkbox-submit"

    def get_command(self):
        from checkbox_ng.commands.submit import SubmitCommand
        return SubmitCommand(self._load_config)


class CheckboxLauncherTool(SingleCommandToolMixIn, CheckboxToolBase):
    """
    A tool class that implements checkbox-launcher.

    This tool implements configurable text-mode-graphics launchers that perform
    a pre-defined testing session based on the launcher profile.
    """

    @classmethod
    def get_exec_name(cls):
        return "checkbox-launcher"

    def get_command(self):
        from checkbox_ng.commands.launcher import LauncherCommand
        return LauncherCommand(self._load_providers, self._load_config)