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/>.
22
from gettext import gettext as _
24
from checkbox.plugin import Plugin
25
from checkbox.properties import String
26
from checkbox.user_interface import PREV
29
class LaunchpadPrompt(Plugin):
31
# Email address used to sign in to Launchpad.
32
email = String(required=False)
34
# Default email address used for anonymous submissions.
35
default_email = String(default="ubuntu-friendly-squad@lists.launchpad.net")
37
def register(self, manager):
38
super(LaunchpadPrompt, self).register(manager)
43
("begin-persist", self.begin_persist),
44
("launchpad-report", self.launchpad_report),
45
("prompt-exchange", self.prompt_exchange)]:
46
self._manager.reactor.call_on(rt, rh)
48
def begin_persist(self, persist):
49
self.persist = persist.root_at("launchpad_prompt")
51
def launchpad_report(self, report):
54
def prompt_exchange(self, interface):
55
if self.persist and self.persist.has("email"):
56
email = self.persist.get("email")
60
# Register temporary handler for exchange-error events
63
def exchange_error(e):
66
event_id = self._manager.reactor.call_on("exchange-error",
70
if errors or not self.email:
72
self._manager.reactor.fire("prompt-error",
75
url = "file://%s" % posixpath.abspath(self.report)
77
# Ignore whether to submit to HEXR
78
email = interface.show_entry(_("""\
79
The following report has been generated for submission to the Launchpad \
84
You can submit this information about your system by providing the email \
85
address you use to sign in to Launchpad. If you do not have a Launchpad \
86
account, please register here:
88
https://launchpad.net/+login""") % url, email, label=_("Email") + ":")[0]
90
if interface.direction == PREV:
94
email = self.default_email
96
if not re.match(r"^\S+@\S+\.\S+$", email, re.I):
97
errors.append(_("Email address must be in a proper format."))
101
self._manager.reactor.fire("launchpad-email", email)
102
interface.show_progress(
103
_("Exchanging information with the server..."),
104
self._manager.reactor.fire, "launchpad-exchange", interface)
108
self._manager.reactor.cancel_call(event_id)
110
self.persist.set("email", email)
113
factory = LaunchpadPrompt