~ubuntu-branches/debian/sid/checkbox-ng/sid

« back to all changes in this revision

Viewing changes to checkbox_ng/main.py

  • Committer: Package Import Robot
  • Author(s): Sylvain Pineau
  • Date: 2014-01-21 21:18:23 UTC
  • Revision ID: package-import@ubuntu.com-20140121211823-iru2ukliuatzpo5p
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This file is part of Checkbox.
 
2
#
 
3
# Copyright 2012, 2013 Canonical Ltd.
 
4
# Written by:
 
5
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
 
6
#
 
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.
 
10
 
 
11
#
 
12
# Checkbox is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
"""
 
21
:mod:`checkbox_ng.main` -- command line interface
 
22
=================================================
 
23
"""
 
24
 
 
25
import logging
 
26
import sys
 
27
 
 
28
from plainbox.impl.commands import PlainBoxToolBase
 
29
from plainbox.impl.commands.check_config import CheckConfigCommand
 
30
from plainbox.impl.commands.dev import DevCommand
 
31
from plainbox.impl.commands.script import ScriptCommand
 
32
 
 
33
from checkbox_ng import __version__ as version
 
34
from checkbox_ng.commands.certification import CertificationCommand
 
35
from checkbox_ng.commands.cli import CliCommand
 
36
from checkbox_ng.commands.sru import SRUCommand
 
37
try:
 
38
    from checkbox_ng.commands.service import ServiceCommand
 
39
except ImportError:
 
40
    pass
 
41
from checkbox_ng.config import CertificationConfig, CheckBoxConfig, CDTSConfig
 
42
 
 
43
 
 
44
logger = logging.getLogger("checkbox.ng.main")
 
45
 
 
46
checkbox_cli_settings = {
 
47
    'subparser_name': 'checkbox-cli',
 
48
    'subparser_help': 'application for system testing',
 
49
    'default_whitelist': 'default',
 
50
    'default_providers': ['2013.com.canonical:checkbox'],
 
51
    'welcome_text': """\
 
52
Welcome to System Testing!
 
53
Checkbox provides tests to confirm that your system is working properly. \
 
54
Once you are finished running the tests, you can view a summary report for \
 
55
your system.
 
56
Warning: Some tests could cause your system to freeze or become \
 
57
unresponsive. Please save all your work and close all other running \
 
58
applications before beginning the testing process."""
 
59
}
 
60
 
 
61
cdts_cli_settings = {
 
62
    'subparser_name': 'driver-test-suite-cli',
 
63
    'subparser_help': 'driver test suite application',
 
64
    'default_whitelist': 'ihv-firmware',
 
65
    'default_providers': ['2013.com.canonical:canonical-driver-test-suite'],
 
66
    'welcome_text': """\
 
67
Welcome to the Canonical Driver Test Suite.
 
68
This program contains automated and manual tests to help you discover issues \
 
69
that will arise when running your device drivers on Ubuntu.
 
70
This application will step the user through these tests in a predetermined \
 
71
order and automatically collect both system information as well as test \
 
72
results. It will also prompt the user for input when manual testing is \
 
73
required.
 
74
The run time for the tests is determined by which tests you decide to \
 
75
execute. The user will have the opportunity to customize the test run to \
 
76
accommodate the driver and the amount of time available for testing.
 
77
If you have any questions during or after completing your test run, please \
 
78
do not hesitate to contact your Canonical account representative.
 
79
To begin, simply press the Continue button below and follow the onscreen \
 
80
instructions."""
 
81
}
 
82
 
 
83
cert_cli_settings = {
 
84
    'subparser_name': 'certification-server',
 
85
    'subparser_help': 'application for server certification',
 
86
    'default_whitelist': 'server-cert',
 
87
    'default_providers': ['2013.com.canonical:certification-server'],
 
88
    'welcome_text': """\
 
89
Welcome to System Certification!
 
90
This application will gather information from your system. Then you will be \
 
91
asked manual tests to confirm that the system is working properly. Finally, \
 
92
you will be asked for the Secure ID of the computer to submit the \
 
93
information to the certification.canonical.com database.
 
94
To learn how to create or locate the Secure ID, please see here:
 
95
https://certification.canonical.com/"""
 
96
}
 
97
 
 
98
 
 
99
class CheckBoxNGTool(PlainBoxToolBase):
 
100
 
 
101
    @classmethod
 
102
    def get_exec_name(cls):
 
103
        return "checkbox"
 
104
 
 
105
    @classmethod
 
106
    def get_exec_version(cls):
 
107
        return "{}.{}.{}".format(*version[:3])
 
108
 
 
109
    @classmethod
 
110
    def get_config_cls(cls):
 
111
        return CheckBoxConfig
 
112
 
 
113
    def add_subcommands(self, subparsers):
 
114
        SRUCommand(
 
115
            self._provider_list, self._config).register_parser(subparsers)
 
116
        CheckConfigCommand(
 
117
            self._config).register_parser(subparsers)
 
118
        ScriptCommand(
 
119
            self._provider_list, self._config).register_parser(subparsers)
 
120
        DevCommand(
 
121
            self._provider_list, self._config).register_parser(subparsers)
 
122
        CliCommand(
 
123
            self._provider_list, self._config, checkbox_cli_settings
 
124
            ).register_parser(subparsers)
 
125
        CliCommand(
 
126
            self._provider_list, self._config, cdts_cli_settings
 
127
            ).register_parser(subparsers)
 
128
        CertificationCommand(
 
129
            self._provider_list, self._config, cert_cli_settings
 
130
            ).register_parser(subparsers)
 
131
        try:
 
132
            ServiceCommand(self._provider_list, self._config).register_parser(
 
133
                subparsers)
 
134
        except NameError:
 
135
            pass
 
136
 
 
137
 
 
138
class CertificationNGTool(CheckBoxNGTool):
 
139
 
 
140
    @classmethod
 
141
    def get_config_cls(cls):
 
142
        return CertificationConfig
 
143
 
 
144
 
 
145
class CDTSTool(CheckBoxNGTool):
 
146
 
 
147
    @classmethod
 
148
    def get_config_cls(cls):
 
149
        return CDTSConfig
 
150
 
 
151
 
 
152
def main(argv=None):
 
153
    """
 
154
    checkbox command line utility
 
155
    """
 
156
    raise SystemExit(CheckBoxNGTool().main(argv))
 
157
 
 
158
 
 
159
def checkbox_cli(argv=None):
 
160
    """
 
161
    CheckBox command line utility
 
162
    """
 
163
    if argv:
 
164
        args = argv
 
165
    else:
 
166
        args = sys.argv[1:]
 
167
    raise SystemExit(
 
168
        CheckBoxNGTool().main(['checkbox-cli'] + args))
 
169
 
 
170
 
 
171
def cdts_cli(argv=None):
 
172
    """
 
173
    certification-server command line utility
 
174
    """
 
175
    if argv:
 
176
        args = argv
 
177
    else:
 
178
        args = sys.argv[1:]
 
179
    raise SystemExit(
 
180
        CDTSTool().main(['driver-test-suite-cli'] + args))
 
181
 
 
182
 
 
183
def cert_server(argv=None):
 
184
    """
 
185
    certification-server command line utility
 
186
    """
 
187
    if argv:
 
188
        args = argv
 
189
    else:
 
190
        args = sys.argv[1:]
 
191
    raise SystemExit(
 
192
        CertificationNGTool().main(['certification-server'] + args))