1
# This file is part of Checkbox.
3
# Copyright 2012-2015 Canonical Ltd.
5
# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
7
# Checkbox is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 3,
9
# as published by the Free Software Foundation.
11
# Checkbox is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
20
:mod:`checkbox_ng.tools` -- top-level command line tools
21
========================================================
27
from plainbox.impl.clitools import SingleCommandToolMixIn
28
from plainbox.impl.clitools import ToolBase
29
from plainbox.impl.commands.cmd_selftest import SelfTestCommand
30
from plainbox.public import get_providers
32
from checkbox_ng import __version__ as version
33
from checkbox_ng.config import CheckBoxConfig
34
from checkbox_ng.tests import load_unit_tests
37
logger = logging.getLogger("checkbox.ng.tools")
40
class CheckboxToolBase(ToolBase):
42
Base class for all checkbox-ng tools.
44
This class contains some shared code like configuration, providers, i18n
48
def _load_config(self):
49
return self.get_config_cls().get()
51
def _load_providers(self):
52
return get_providers()
55
def get_exec_version(cls):
57
Get the version of the checkbox-ng package
59
return cls.format_version_tuple(version)
62
def get_config_cls(cls):
64
Get particular sub-class of the Config class to use
68
def get_gettext_domain(self):
70
Get the 'checkbox-ng' gettext domain
74
def get_locale_dir(self):
76
Get an optional development locale directory specific to checkbox-ng
78
return os.getenv("CHECKBOX_NG_LOCALE_DIR", None)
81
class CheckboxTool(CheckboxToolBase):
83
Tool that implements the new checkbox command.
85
This tool has two sub-commands:
87
checkbox sru - to run stable release update testing
88
checkbox check-config - to validate and display system configuration
92
def get_exec_name(cls):
95
def add_subcommands(self, subparsers, early_ns=None):
96
from checkbox_ng.commands.launcher import LauncherCommand
97
from checkbox_ng.commands.sru import SRUCommand
98
from checkbox_ng.commands.submit import SubmitCommand
99
from plainbox.impl.commands.cmd_check_config import CheckConfigCommand
101
self._load_providers, self._load_config
102
).register_parser(subparsers)
105
).register_parser(subparsers)
108
).register_parser(subparsers)
110
self._load_providers, self._load_config
111
).register_parser(subparsers)
112
SelfTestCommand(load_unit_tests).register_parser(subparsers)
115
class CheckboxSubmitTool(SingleCommandToolMixIn, CheckboxToolBase):
117
A tool class that implements checkbox-submit.
119
This tool implements the submit feature to send test results to the
120
Canonical certification website
124
def get_exec_name(cls):
125
return "checkbox-submit"
127
def get_command(self):
128
from checkbox_ng.commands.submit import SubmitCommand
129
return SubmitCommand(self._load_config)
132
class CheckboxLauncherTool(SingleCommandToolMixIn, CheckboxToolBase):
134
A tool class that implements checkbox-launcher.
136
This tool implements configurable text-mode-graphics launchers that perform
137
a pre-defined testing session based on the launcher profile.
141
def get_exec_name(cls):
142
return "checkbox-launcher"
144
def get_command(self):
145
from checkbox_ng.commands.launcher import LauncherCommand
146
return LauncherCommand(self._load_providers, self._load_config)