/usr/share/checkbox/plugins/launchpad_prompt.py is in checkbox 0.13.7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #
# This file is part of Checkbox.
#
# Copyright 2008 Canonical Ltd.
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
#
import re
import posixpath
from gettext import gettext as _
from checkbox.plugin import Plugin
from checkbox.properties import String
from checkbox.user_interface import PREV
class LaunchpadPrompt(Plugin):
# Email address used to sign in to Launchpad.
email = String(required=False)
# Default email address used for anonymous submissions.
default_email = String(default="ubuntu-friendly-squad@lists.launchpad.net")
def register(self, manager):
super(LaunchpadPrompt, self).register(manager)
self.persist = None
for (rt, rh) in [
("begin-persist", self.begin_persist),
("launchpad-report", self.launchpad_report),
("prompt-exchange", self.prompt_exchange)]:
self._manager.reactor.call_on(rt, rh)
def begin_persist(self, persist):
self.persist = persist.root_at("launchpad_prompt")
def launchpad_report(self, report):
self.report = report
def prompt_exchange(self, interface):
if self.persist and self.persist.has("email"):
email = self.persist.get("email")
else:
email = self.email
# Register temporary handler for exchange-error events
errors = []
def exchange_error(e):
errors.append(e)
event_id = self._manager.reactor.call_on("exchange-error", exchange_error)
while True:
if errors or not self.email:
for error in errors:
self._manager.reactor.fire("prompt-error", interface, error)
url = "file://%s" % posixpath.abspath(self.report)
email = interface.show_entry(_("""\
The following report has been generated for submission to the Launchpad \
hardware database:
[[%s|View Report]]
You can submit this information about your system by providing the email \
address you use to sign in to Launchpad. If you do not have a Launchpad \
account, please register here:
https://launchpad.net/+login""") % url, email)
if interface.direction == PREV:
break
if not email:
email = self.default_email
if not re.match(r"^\S+@\S+\.\S+$", email, re.I):
errors.append(_("Email address must be in a proper format."))
continue
errors = []
self._manager.reactor.fire("launchpad-email", email)
interface.show_progress(
_("Exchanging information with the server..."),
self._manager.reactor.fire, "launchpad-exchange")
if not errors:
break
self._manager.reactor.cancel_call(event_id)
if self.persist:
self.persist.set("email", email)
factory = LaunchpadPrompt
|