Merge lp:~brendan-donegan/checkbox/bug868941_submission_timestamp into lp:checkbox

Proposed by Brendan Donegan
Status: Rejected
Rejected by: Daniel Manrique
Proposed branch: lp:~brendan-donegan/checkbox/bug868941_submission_timestamp
Merge into: lp:checkbox
Diff against target: 167 lines (+79/-4)
5 files modified
checkbox/application.py (+6/-1)
debian/changelog (+4/-1)
plugins/launchpad_report.py (+28/-1)
plugins/report_prompt.py (+1/-1)
plugins/submission_prompt.py (+40/-0)
To merge this branch: bzr merge lp:~brendan-donegan/checkbox/bug868941_submission_timestamp
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Disapprove
Greg Vallande (community) Needs Information
Sylvain Pineau (community) Approve
Review via email: mp+79223@code.launchpad.net

Description of the change

This branch modifies the plugin which generates the submission.xml and adds a new one whose responsibility it is to prompt the user whether they want to keep an existing submission.xml or save it.

The 'check-report' callback in launchpad_report determines whether there is already a submission present - it then fires 'prompt-timestamp' in the submission_prompt plugin which gets a yes/no answer from the user. This is fed back to the 'report' callback of launchpad_report which uses it to determine whether it should copy the old report to a timestamped directory, or do nothing.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

It's a really good addition, thanks for this very useful feature.
For me it's ok to have it in the trunk.

review: Approve
Revision history for this message
Jeff Lane  (bladernr) wrote :

Since we're only saving a single file here (submission.xml) any particular reason for creating timestamp directories rather than just copying the file to something like checkbox-certification-TIMESTAMP.log ??

I could see that being useful if other things were saved (maybe that's worth it just for future expansion ability) but just curious. It's a personal preference thing I guess... mine would be one dir full of logs that have timestamps, rather than one dir full of subdirs each having one log (assuming multiple runs).

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

As you say, personal preference I guess. Thinking about it a bit more though, adding the extra directory might make it more difficult to locate the old submissions - so yeah I think having them all at the same level is better. I'll make that change.

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Made that change - would really like someone to approve this and get it out of the way.

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Going to have to rework this and put the change into checkbox-certification instead.

Revision history for this message
Ara Pulido (ara) wrote :

Instead of putting it in checkbox-certification I would:

 * Put it in checkbox with a parameter
 * In checkbox-certification the parameter is enabled by default
 * In checkbox the parameter is disabled by default

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Time for someone to look at this again. At the moment it works like:

* Need to specify the -S (or --save-submission) flag for it to work in the first place
* If an existing submission is detected then it saves the current submission under a different name

Revision history for this message
Daniel Manrique (roadmr) wrote :

Hi! So I was trying this code and am experiencing a few problems. Here's what I observed:

- Line 76: Global variable filename doesn't exist, so filename needs to be self.filename

- Firing "report" with a "response" parameter (line 143). The extra parameter is correctly handled by the updated report method on launchpad_report.py (line 63-64), but this will fire the report method in *all* registered plugins. So I get this on the log from one of the plugins whose "report" method can't handle the extra parameter:

2011-11-14 16:42:48,991 DEBUG Calling ./plugins/system_info.py SystemInfo.report(yes) for report with priority -10.
2011-11-14 16:42:48,991 ERROR Error running event handler ./plugins/system_info.py SystemInfo.report(yes) for event type 'report'
Traceback (most recent call last):
  File "/home/roadmr/Documents/checkboxes/submission_timestamp/checkbox/reactor.py", line 74, in fire
    results.append(handler(*args, **kwargs))
TypeError: report() takes exactly 1 argument (2 given)

I get this 5 times, for the SystemInfo, ClientInfo, SubmissionInfo, DatetimeInfo and JobsPrompt plugins.

The easy way to handle this is to make all plugins recognize the extra "response" parameter but since it's only used in launchpad_report.py, I think the best solution would be one that kept this concern away from the other plugins.

- Lastly you may want to zorch the pdb-related lines (on lines 19 and 137) when you're sure they are no longer needed.

review: Needs Fixing
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

1. Fixed
2. Created a 'save_report' function to encapsulate the saving of the report without the 'report' function needing to know about the 'response' parameter
3. Zorched

I'm still having trouble getting a submission made on my system. I'll have a quick check to see if it's to do with these changes or if it was something that was already there and then update the review status.

1102. By Brendan Donegan

Little corrections.

1103. By Brendan Donegan

Merged from trunk.

Revision history for this message
Daniel Manrique (roadmr) wrote :

Hi,

Two things may have been giving you trouble when submitting:

- Missing plugin: field for attachment.png job. This is fixed in trunk.

- I kept having trouble when trying to save existing submission.xml files. Here's my test procedure (not a testcase :)

1- Running checkbox with -S and specifying one or two automated tests
2- Rerunning with -S, and specifying one or two *different* tests (unmark the previous selected ones, choose a couple of new ones)

after this I expected the submission.xml file and the submission_xxxxxxx.xml file (from the first run) to be different, but they were the same, and always the same size.

I also looked in submission.xml for the test name I ran (memory/info for instance) and it's not there, even though I'm sure it ran (it's a manual test so I had to answer it). They're basically empty and contain no test results at all, only the data from the gathering phase.

I think this is because
a) calling self.report() in check_report and save_report looks strange and seemed to be giving trouble generating the report even without -S. launchpad_report.py. Can this be changed to self._manager.reactor.fire("report")?
b) the call to report generation is only getting invoked if the user NOT choose to save the report. Method check_report. I think the logic needs to change to generate the report outside the "if" so it gets called regardless of what the user responds.

Could you validate that things behave as I describe?

review: Needs Information
Revision history for this message
Marc Tardif (cr3) wrote :

Gentle nudge, this merge request needs some love...

Revision history for this message
Daniel Manrique (roadmr) wrote :

I tested this again and I'm getting the same results as on my last comment:

1- The submission.xml doesn't contain the test results (I'm using a minimal whitelist with only 3 tests and yet none of them show).

2- Sometimes when the show_info method gets invoked, the dialog that pops up is blank and things just block, I have to forcefully kill checkbox to return things to a working state.

So as mentioned before, the logic could use some looking at and potentially fixing.

It'd be great to include this in Checkbox before Feature Freeze, so I'd appreciate if you could have a second look at this.

review: Needs Fixing
1104. By Brendan Donegan

Merged from trunk

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

This one has been left to the sidelines a bit. I'm revisiting it now and hopefully can iron out the problems.

Revision history for this message
Greg Vallande (gvallande) wrote :

@brendand: Has there been any progress on this since 02-07-12? It appears this one needs some love.

review: Needs Information
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Unfortunately not :( I have to work on this branch in my spare time, which I've not been getting a lot of recently! If it's deemed to be a priority I can look at it, but I haven't seen any suggestion that it is,

Revision history for this message
Daniel Manrique (roadmr) wrote :

Since this feature needs some reworking anyway, I'll reject the merge request, as it's not adequate to keep it as a placeholder if no active work is being done on it. That's what the bug report is for. Thanks anyway!

review: Disapprove

Unmerged revisions

1104. By Brendan Donegan

Merged from trunk

1103. By Brendan Donegan

Merged from trunk.

1102. By Brendan Donegan

Little corrections.

1101. By Brendan Donegan

Made timestamping make more sense.

1100. By Brendan Donegan

Merged from trunk.

1099. By Brendan Donegan

Merged from trunk.

1098. By Brendan Donegan

Added option to enable saving of submission xml file.

1097. By Brendan Donegan

Merged from trunk.

1096. By Brendan Donegan

Instead of timestamped directory just timestamp the file.

1095. By Brendan Donegan

Merge from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'checkbox/application.py'
--- checkbox/application.py 2010-09-23 10:11:27 +0000
+++ checkbox/application.py 2012-02-07 08:00:00 +0000
@@ -87,7 +87,10 @@
87 parser.add_option("-w", "--whitelist",87 parser.add_option("-w", "--whitelist",
88 help=_("Shorthand for --config=.*/jobs_info/whitelist."))88 help=_("Shorthand for --config=.*/jobs_info/whitelist."))
89 parser.add_option("-W", "--whitelist-file",89 parser.add_option("-W", "--whitelist-file",
90 help=_("Shorthand for --config=.*/jobs_info/whitelist_file."))90 help=_("Shorthand for --config=checkbox/plugins/jobs_info/whitelist_file."))
91 parser.add_option("-S", "--save-submission",
92 action="store_true",
93 help=_("Shorthand for --config=checkbox/plugins/submission_prompt/save_submission."))
91 return parser.parse_args(args)94 return parser.parse_args(args)
9295
93 def create_application(self, args=sys.argv):96 def create_application(self, args=sys.argv):
@@ -107,6 +110,8 @@
107 if value:110 if value:
108 options.config.append("=".join([key, value]))111 options.config.append("=".join([key, value]))
109112
113 if options.save_submission:
114 options.config.append("=".join(["checkbox/plugins/launchpad_report/save_submission", str(options.save_submission)]))
110 # Set logging early115 # Set logging early
111 set_logging(options.log_level, options.log)116 set_logging(options.log_level, options.log)
112117
113118
=== modified file 'debian/changelog'
--- debian/changelog 2012-02-06 20:04:05 +0000
+++ debian/changelog 2012-02-07 08:00:00 +0000
@@ -12,7 +12,10 @@
12 [Daniel Manrique]12 [Daniel Manrique]
13 * Changed way of obtaining preferred browser to ensure we honor the user's13 * Changed way of obtaining preferred browser to ensure we honor the user's
14 preference rather than Chromium's clobbering of14 preference rather than Chromium's clobbering of
15 /etc/alternatives/gnome-www-browser (LP: #925603) 15 /etc/alternatives/gnome-www-browser (LP: #925603)
16
17 [Brendan Donegan]
18 * Implement prompt for user to save the old submission if they wish to (LP: #868941)
1619
17 -- Daniel Manrique <daniel.manrique@canonical.com> Mon, 06 Feb 2012 14:55:58 -050020 -- Daniel Manrique <daniel.manrique@canonical.com> Mon, 06 Feb 2012 14:55:58 -0500
1821
1922
=== modified file 'plugins/launchpad_report.py'
--- plugins/launchpad_report.py 2011-12-07 21:25:59 +0000
+++ plugins/launchpad_report.py 2012-02-07 08:00:00 +0000
@@ -17,13 +17,15 @@
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
18#18#
19import os19import os
20import time
21import shutil
2022
21from gettext import gettext as _23from gettext import gettext as _
22from string import printable24from string import printable
2325
24from checkbox.lib.safe import safe_make_directory26from checkbox.lib.safe import safe_make_directory
2527
26from checkbox.properties import Path28from checkbox.properties import Path, Bool
27from checkbox.plugin import Plugin29from checkbox.plugin import Plugin
28from checkbox.reports.launchpad_report import LaunchpadReportManager30from checkbox.reports.launchpad_report import LaunchpadReportManager
2931
@@ -39,6 +41,9 @@
39 # XSL Stylesheet41 # XSL Stylesheet
40 stylesheet = Path(default="%(checkbox_share)s/report/checkbox.xsl")42 stylesheet = Path(default="%(checkbox_share)s/report/checkbox.xsl")
4143
44 # Whether to ask to save the submission XML
45 save_submission = Bool(required=False)
46
42 def register(self, manager):47 def register(self, manager):
43 super(LaunchpadReport, self).register(manager)48 super(LaunchpadReport, self).register(manager)
4449
@@ -67,6 +72,8 @@
67 self._manager.reactor.call_on(rt, rh)72 self._manager.reactor.call_on(rt, rh)
6873
69 # Launchpad report should be generated last.74 # Launchpad report should be generated last.
75 self._manager.reactor.call_on("check-report", self.check_report, 100)
76 self._manager.reactor.call_on("save-report", self.save_report, 100)
70 self._manager.reactor.call_on("report", self.report, 100)77 self._manager.reactor.call_on("report", self.report, 100)
7178
72 def report_attachments(self, attachments):79 def report_attachments(self, attachments):
@@ -130,6 +137,26 @@
130 "comment": test.get("data", "")}137 "comment": test.get("data", "")}
131 self._report["questions"].append(question)138 self._report["questions"].append(question)
132139
140 def check_report(self, interface):
141 if self.save_submission and os.path.exists(self.filename):
142 self._manager.reactor.fire("prompt-timestamp", interface)
143 else:
144 # Since there is no existing submission we don't want to keep it
145 self.report()
146
147 def save_report(self, response):
148 if response == 'yes':
149 # Rename the old submission including a timestamp in the path
150 timestamp = time.strftime("%Y%m%d-%H%M%S",
151 time.localtime(os.path.getctime(self.filename)))
152
153 basename = os.path.basename(self.filename)
154 timestamped_file = os.path.splitext(basename)[0] + '_' + timestamp + os.path.splitext(basename)[1]
155
156 shutil.move(self.filename, timestamped_file)
157
158 self.report()
159
133 def report(self):160 def report(self):
134 # Prepare the payload and attach it to the form161 # Prepare the payload and attach it to the form
135 stylesheet_path = os.path.join(162 stylesheet_path = os.path.join(
136163
=== modified file 'plugins/report_prompt.py'
--- plugins/report_prompt.py 2011-09-08 14:52:33 +0000
+++ plugins/report_prompt.py 2012-02-07 08:00:00 +0000
@@ -37,7 +37,7 @@
3737
38 if interface.direction != PREV:38 if interface.direction != PREV:
39 interface.show_progress(_("Building report..."),39 interface.show_progress(_("Building report..."),
40 self._manager.reactor.fire, "report")40 self._manager.reactor.fire, "check-report", interface)
4141
42 self._manager.reactor.cancel_call(event_id)42 self._manager.reactor.cancel_call(event_id)
4343
4444
=== added file 'plugins/submission_prompt.py'
--- plugins/submission_prompt.py 1970-01-01 00:00:00 +0000
+++ plugins/submission_prompt.py 2012-02-07 08:00:00 +0000
@@ -0,0 +1,40 @@
1#
2# This file is part of Checkbox.
3#
4# Copyright 2011 Canonical Ltd.
5#
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.
10#
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.
15#
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/>.
18#
19
20from gettext import gettext as _
21
22from checkbox.plugin import Plugin
23from checkbox.user_interface import NEXT
24
25class SubmissionPrompt(Plugin):
26
27 def register(self, manager):
28 super(SubmissionPrompt, self).register(manager)
29
30 self._manager.reactor.call_on("prompt-timestamp", self.prompt_timestamp)
31
32 def prompt_timestamp(self, interface):
33 if interface.direction == NEXT:
34 response = interface.show_info(
35 _("An existing submission file was detected.\n"
36 "Do you want to keep it?"),
37 ["yes", "no"], "yes")
38 self._manager.reactor.fire("save-report", response)
39
40factory = SubmissionPrompt
041
=== modified file 'scripts/removable_storage_test' (properties changed: +x to -x)

Subscribers

People subscribed via source and target branches