~ubuntu-branches/ubuntu/lucid/checkbox/lucid

« back to all changes in this revision

Viewing changes to plugins/launchpad_report.py

  • Committer: Bazaar Package Importer
  • Author(s): Dave Murphy, Dave Murphy, Andy Whitcroft
  • Date: 2009-03-17 09:46:16 UTC
  • Revision ID: james.westby@ubuntu.com-20090317094616-1p1ifmdy702ilpl9
Tags: 0.7
[ Dave Murphy ]
* Fixed viewing of report files in Firefox 3 (LP: #331481)
* Added additional contextual information
 * /etc/sysctl* (LP: #331055)
 * /etc/modprobe.d (LP: #331056)
 * /etc/modules (LP: #331057)
* Fixed packaging for Jaunty
 * https://lists.ubuntu.com/archives/ubuntu-devel/2009-February/027439.html
 * Uses --install-layout=deb
 * Installs to dist-packages instead of site-packages

[ Andy Whitcroft ]
* suspend_test: update suspend_test to version V6 matching kernel version.
  The version here will become the master copy.
* suspend_test: add a --dry-run mode to simplify developement
* suspend_test: add a automation mode for checkbox integration
* suspend_test: add a new pm-suspend test
* suspend_test: record and restore timer_delay around the variable
  time test.
* suspend_test: release v7.
* suspend_test: initial version of suspend power consumption test
  from a patch by Pete Graner.
* suspend_test: power -- made the sleep time configurable
* suspend_test: detect batteries and disable ac/power tests
* suspend_test: disable dbus tests when we have no primary user
* suspend_test: handle AC transitions better
* suspend_test: enable power test as part of --full
* suspend_test: reduce the noise in the test instructions
* suspend_test: use minutes in output when that is more appropriate
* suspend_test: track actual AC transitions and report them
* suspend_test: only mention AC at all if we have a battery
* suspend_test: report useful data at the bottom for posting
* suspend_test: document the new power test in the usage
* suspend_test: power -- indicate when the result is unreliable
* suspend_test: report -- fix up spacing issues
* suspend_test: release v8

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
18
18
#
19
19
import posixpath
 
20
import shutil
20
21
 
21
22
from checkbox.lib.safe import safe_make_directory
22
23
 
23
 
from checkbox.properties import String
 
24
from checkbox.properties import Path
24
25
from checkbox.plugin import Plugin
25
26
from checkbox.reports.launchpad_report import LaunchpadReportManager
26
27
 
28
29
class LaunchpadReport(Plugin):
29
30
 
30
31
    # Filename where submission information is cached.
31
 
    filename = String(default="%(checkbox_data)s/submission.xml")
 
32
    filename = Path(default="%(checkbox_data)s/submission.xml")
 
33
 
 
34
    # XSL Stylesheet
 
35
    stylesheet = Path(default="%(checkbox_share)s/report/checkbox.xsl")
32
36
 
33
37
    def register(self, manager):
34
38
        super(LaunchpadReport, self).register(manager)
40
44
            "hardware": {},
41
45
            "software": {
42
46
                "packages": []},
43
 
            "questions": []}
 
47
            "questions": [],
 
48
            "context": []}
44
49
 
45
50
        # Launchpad report should be generated last.
46
51
        self._manager.reactor.call_on("report", self.report, 100)
49
54
             ("report-client", self.report_client),
50
55
             ("report-datetime", self.report_datetime),
51
56
             ("report-distribution", self.report_distribution),
52
 
             ("report-dmi", self.report_dmi),
 
57
             ("report-dmi", self.report_context),
53
58
             ("report-hal", self.report_hal),
 
59
             ("report-modprobe", self.report_context),
 
60
             ("report-modules", self.report_context),
54
61
             ("report-packages", self.report_packages),
55
 
             ("report-pci", self.report_pci),
 
62
             ("report-pci", self.report_context),
56
63
             ("report-processors", self.report_processors),
 
64
             ("report-sysctl", self.report_context),
57
65
             ("report-system_id", self.report_system_id),
58
66
             ("report-results", self.report_results)]:
59
67
            self._manager.reactor.call_on(rt, rh)
75
83
        self._report["summary"]["distribution"] = distribution.distributor_id
76
84
        self._report["summary"]["distroseries"] = distribution.release
77
85
 
78
 
    def report_dmi(self, dmi):
79
 
        self._report["hardware"]["dmi"] = dmi
80
 
 
81
86
    def report_packages(self, packages):
82
87
        self._report["software"]["packages"].extend(packages)
83
88
 
84
 
    def report_pci(self, pci):
85
 
        self._report["hardware"]["lspci"] = pci
86
 
 
87
89
    def report_processors(self, processors):
88
90
        self._report["hardware"]["processors"] = processors
89
91
 
100
102
            question["result"] = dict(result.attributes)
101
103
            self._report["questions"].append(question)
102
104
 
 
105
    def report_context(self, sources):
 
106
        # sources should be a list - make it so
 
107
        if not isinstance(sources, list):
 
108
            sources = [sources]
 
109
 
 
110
        for source in sources:
 
111
            if isinstance(source, tuple):
 
112
                source = source[1]
 
113
            info = {}
 
114
            if 'command' in dir(source):
 
115
                info["command"] = source.command
 
116
            if 'filename' in dir(source):
 
117
                info["command"] = source.filename
 
118
            if 'directory' in dir(source):
 
119
                info["command"] = source.directory
 
120
            info["data"] = str(source)
 
121
            self._report["context"].append(info)
 
122
 
103
123
    def report(self):
 
124
        # Copy stylesheet to report directory
 
125
        stylesheet = posixpath.join(
 
126
            posixpath.dirname(self.filename),
 
127
            posixpath.basename(self.stylesheet))
 
128
        shutil.copy(self.stylesheet, stylesheet)
 
129
 
104
130
        # Prepare the payload and attach it to the form
105
 
        report_manager = LaunchpadReportManager("system", "1.0")
 
131
        stylesheet = posixpath.abspath(stylesheet)
 
132
        report_manager = LaunchpadReportManager("system", "1.0", stylesheet)
106
133
        payload = report_manager.dumps(self._report).toprettyxml("")
107
134
 
108
135
        directory = posixpath.dirname(self.filename)
109
136
        safe_make_directory(directory)
110
137
 
111
 
        open(self.filename, "w").write(payload)
 
138
        file = open(self.filename, "w")
 
139
        file.write(payload)
 
140
        file.close()
 
141
 
112
142
        self._manager.reactor.fire("exchange-report", self.filename)
113
143
 
114
144