2
# Copyright (c) 2008 Canonical
4
# Written by Marc Tardif <marc@interunion.ca>
6
# This file is part of Checkbox.
8
# Checkbox is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# Checkbox is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23
from checkbox.lib.safe import safe_make_directory
25
from checkbox.plugin import Plugin
26
from checkbox.reports.launchpad_report import LaunchpadReportManager
29
class LaunchpadReport(Plugin):
31
required_attributes = ["filename"]
33
def register(self, manager):
34
super(LaunchpadReport, self).register(manager)
45
# Launchpad report should be generated last.
46
self._manager.reactor.call_on("report", self.report, 100)
48
("report-architecture", self.report_architecture),
49
("report-client", self.report_client),
50
("report-datetime", self.report_datetime),
51
("report-distribution", self.report_distribution),
52
("report-hal", self.report_hal),
53
("report-packages", self.report_packages),
54
("report-processors", self.report_processors),
55
("report-system_id", self.report_system_id),
56
("report-results", self.report_results)]:
57
self._manager.reactor.call_on(rt, rh)
59
def report_architecture(self, architecture):
60
self._report["summary"]["architecture"] = architecture
62
def report_hal(self, hal):
63
self._report["hardware"]["hal"] = hal
65
def report_client(self, client):
66
self._report["summary"]["client"] = client
68
def report_datetime(self, datetime):
69
self._report["summary"]["date_created"] = datetime
71
def report_distribution(self, distribution):
72
self._report["software"]["lsbrelease"] = dict(distribution)
73
self._report["summary"]["distribution"] = distribution.distributor_id
74
self._report["summary"]["distroseries"] = distribution.release
76
def report_packages(self, packages):
77
self._report["software"]["packages"].extend(packages)
79
def report_processors(self, processors):
80
self._report["hardware"]["processors"] = processors
82
def report_system_id(self, system_id):
83
self._report["summary"]["system_id"] = system_id
85
def report_results(self, results):
86
for result in results:
88
question = dict(test.attributes)
89
question["command"] = str(test.command)
90
question["description"] = str(test.description)
91
question["requires"] = str(test.requires)
92
question["result"] = dict(result.attributes)
93
self._report["questions"].append(question)
96
# Prepare the payload and attach it to the form
97
report_manager = LaunchpadReportManager("system", "1.0")
98
payload = report_manager.dumps(self._report).toprettyxml("")
100
filename = self._config.filename
101
directory = posixpath.dirname(filename)
102
safe_make_directory(directory)
104
open(filename, "w").write(payload)
105
self._manager.reactor.fire("exchange-report", filename)
108
factory = LaunchpadReport