2
# This file is part of Checkbox.
4
# Copyright 2008 Canonical Ltd.
6
# Checkbox is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
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/>.
19
from gettext import gettext as _
21
from checkbox.properties import String
22
from checkbox.plugin import Plugin
25
class CategoryPrompt(Plugin):
27
# Category of the system: desktop, laptop or server
28
category = String(required=False)
30
def register(self, manager):
31
super(CategoryPrompt, self).register(manager)
34
("gather-persist", self.gather_persist),
35
("prompt-category", self.prompt_category)]:
36
self._manager.reactor.call_on(rt, rh)
38
def gather_persist(self, persist):
39
self.persist = persist.root_at("category_prompt")
41
def prompt_category(self, interface):
42
category = self.persist.get("category") or self.category
43
registry = self._manager.registry
45
# Try to determine category from HAL formfactor
47
formfactor = registry.hal.computer.system.formfactor
48
if formfactor is not "unknown":
51
# Try to determine category from dpkg architecture
53
architecture = registry.dpkg.architecture
54
if architecture is "sparc":
57
# Try to determine category from kernel version
59
version = registry.hal.computer.system.kernel.version
60
if str(version).endswith("-server"):
63
# Prompt for the category explicitly
65
category = interface.show_category(_("Category"),
66
_("Please select the category of your system."),
69
self.persist.set("category", category)
70
self._manager.reactor.fire("report-category", category)
73
factory = CategoryPrompt