~kelemeng/checkbox/bug868571

« back to all changes in this revision

Viewing changes to plugins/message_exchange.py

  • Committer: Marc Tardif
  • Date: 2007-10-04 23:12:10 UTC
  • Revision ID: marc.tardif@canonical.com-20071004231210-unxckndkgndxfdp6
Refactored questions to use templates and scripts which fixes bug #149195.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
class MessageExchange(Plugin):
15
15
 
 
16
    persist_name = "message-exchange"
 
17
 
16
18
    transport_factory = HTTPTransport
17
 
    transport_url = "https://launchpad.net/hwdb/+submit"
18
 
 
19
 
    persist_name = "message-exchange"
20
 
 
21
 
    def __init__(self):
22
 
        self._transport = self.transport_factory(self.transport_url)
 
19
 
 
20
    def __init__(self, config):
 
21
        super(MessageExchange, self).__init__(config)
 
22
        self._transport = self.transport_factory(self.config.transport_url)
23
23
 
24
24
    def exchange(self):
25
25
        report = self._manager.report
55
55
        
56
56
        # bzip2 compress the payload and attach it to the form
57
57
        payload = report.toxml()
 
58
        file("/tmp/a.xml", "w").write(payload)
58
59
        cpayload = bz2.compress(payload)
59
60
        f = StringIO.StringIO(cpayload)
60
61
        f.name = filename
81
82
                          pprint.pformat(ret.headers.items()))
82
83
 
83
84
        headers = ret.headers.getheaders("x-launchpad-hwdb-submission")
 
85
        self._manager.set_error()
84
86
        for header in headers:
85
87
            if "Error" in header:
86
88
                # HACK: this should return a useful error message
87
 
                self._manager.set_error("Submission failure")
 
89
                self._manager.set_error(header)
88
90
                logging.error(header)
89
91
                return
90
92