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
1=== modified file 'checkbox/application.py'
2--- checkbox/application.py 2010-09-23 10:11:27 +0000
3+++ checkbox/application.py 2012-02-07 08:00:00 +0000
4@@ -87,7 +87,10 @@
5 parser.add_option("-w", "--whitelist",
6 help=_("Shorthand for --config=.*/jobs_info/whitelist."))
7 parser.add_option("-W", "--whitelist-file",
8- help=_("Shorthand for --config=.*/jobs_info/whitelist_file."))
9+ help=_("Shorthand for --config=checkbox/plugins/jobs_info/whitelist_file."))
10+ parser.add_option("-S", "--save-submission",
11+ action="store_true",
12+ help=_("Shorthand for --config=checkbox/plugins/submission_prompt/save_submission."))
13 return parser.parse_args(args)
14
15 def create_application(self, args=sys.argv):
16@@ -107,6 +110,8 @@
17 if value:
18 options.config.append("=".join([key, value]))
19
20+ if options.save_submission:
21+ options.config.append("=".join(["checkbox/plugins/launchpad_report/save_submission", str(options.save_submission)]))
22 # Set logging early
23 set_logging(options.log_level, options.log)
24
25
26=== modified file 'debian/changelog'
27--- debian/changelog 2012-02-06 20:04:05 +0000
28+++ debian/changelog 2012-02-07 08:00:00 +0000
29@@ -12,7 +12,10 @@
30 [Daniel Manrique]
31 * Changed way of obtaining preferred browser to ensure we honor the user's
32 preference rather than Chromium's clobbering of
33- /etc/alternatives/gnome-www-browser (LP: #925603)
34+ /etc/alternatives/gnome-www-browser (LP: #925603)
35+
36+ [Brendan Donegan]
37+ * Implement prompt for user to save the old submission if they wish to (LP: #868941)
38
39 -- Daniel Manrique <daniel.manrique@canonical.com> Mon, 06 Feb 2012 14:55:58 -0500
40
41
42=== modified file 'plugins/launchpad_report.py'
43--- plugins/launchpad_report.py 2011-12-07 21:25:59 +0000
44+++ plugins/launchpad_report.py 2012-02-07 08:00:00 +0000
45@@ -17,13 +17,15 @@
46 # along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
47 #
48 import os
49+import time
50+import shutil
51
52 from gettext import gettext as _
53 from string import printable
54
55 from checkbox.lib.safe import safe_make_directory
56
57-from checkbox.properties import Path
58+from checkbox.properties import Path, Bool
59 from checkbox.plugin import Plugin
60 from checkbox.reports.launchpad_report import LaunchpadReportManager
61
62@@ -39,6 +41,9 @@
63 # XSL Stylesheet
64 stylesheet = Path(default="%(checkbox_share)s/report/checkbox.xsl")
65
66+ # Whether to ask to save the submission XML
67+ save_submission = Bool(required=False)
68+
69 def register(self, manager):
70 super(LaunchpadReport, self).register(manager)
71
72@@ -67,6 +72,8 @@
73 self._manager.reactor.call_on(rt, rh)
74
75 # Launchpad report should be generated last.
76+ self._manager.reactor.call_on("check-report", self.check_report, 100)
77+ self._manager.reactor.call_on("save-report", self.save_report, 100)
78 self._manager.reactor.call_on("report", self.report, 100)
79
80 def report_attachments(self, attachments):
81@@ -130,6 +137,26 @@
82 "comment": test.get("data", "")}
83 self._report["questions"].append(question)
84
85+ def check_report(self, interface):
86+ if self.save_submission and os.path.exists(self.filename):
87+ self._manager.reactor.fire("prompt-timestamp", interface)
88+ else:
89+ # Since there is no existing submission we don't want to keep it
90+ self.report()
91+
92+ def save_report(self, response):
93+ if response == 'yes':
94+ # Rename the old submission including a timestamp in the path
95+ timestamp = time.strftime("%Y%m%d-%H%M%S",
96+ time.localtime(os.path.getctime(self.filename)))
97+
98+ basename = os.path.basename(self.filename)
99+ timestamped_file = os.path.splitext(basename)[0] + '_' + timestamp + os.path.splitext(basename)[1]
100+
101+ shutil.move(self.filename, timestamped_file)
102+
103+ self.report()
104+
105 def report(self):
106 # Prepare the payload and attach it to the form
107 stylesheet_path = os.path.join(
108
109=== modified file 'plugins/report_prompt.py'
110--- plugins/report_prompt.py 2011-09-08 14:52:33 +0000
111+++ plugins/report_prompt.py 2012-02-07 08:00:00 +0000
112@@ -37,7 +37,7 @@
113
114 if interface.direction != PREV:
115 interface.show_progress(_("Building report..."),
116- self._manager.reactor.fire, "report")
117+ self._manager.reactor.fire, "check-report", interface)
118
119 self._manager.reactor.cancel_call(event_id)
120
121
122=== added file 'plugins/submission_prompt.py'
123--- plugins/submission_prompt.py 1970-01-01 00:00:00 +0000
124+++ plugins/submission_prompt.py 2012-02-07 08:00:00 +0000
125@@ -0,0 +1,40 @@
126+#
127+# This file is part of Checkbox.
128+#
129+# Copyright 2011 Canonical Ltd.
130+#
131+# Checkbox is free software: you can redistribute it and/or modify
132+# it under the terms of the GNU General Public License as published by
133+# the Free Software Foundation, either version 3 of the License, or
134+# (at your option) any later version.
135+#
136+# Checkbox is distributed in the hope that it will be useful,
137+# but WITHOUT ANY WARRANTY; without even the implied warranty of
138+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139+# GNU General Public License for more details.
140+#
141+# You should have received a copy of the GNU General Public License
142+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
143+#
144+
145+from gettext import gettext as _
146+
147+from checkbox.plugin import Plugin
148+from checkbox.user_interface import NEXT
149+
150+class SubmissionPrompt(Plugin):
151+
152+ def register(self, manager):
153+ super(SubmissionPrompt, self).register(manager)
154+
155+ self._manager.reactor.call_on("prompt-timestamp", self.prompt_timestamp)
156+
157+ def prompt_timestamp(self, interface):
158+ if interface.direction == NEXT:
159+ response = interface.show_info(
160+ _("An existing submission file was detected.\n"
161+ "Do you want to keep it?"),
162+ ["yes", "no"], "yes")
163+ self._manager.reactor.fire("save-report", response)
164+
165+factory = SubmissionPrompt
166
167=== modified file 'scripts/removable_storage_test' (properties changed: +x to -x)

Subscribers

People subscribed via source and target branches