Merge lp:~cr3/ubuntu/lucid/checkbox/0.9.2 into lp:ubuntu/lucid/checkbox

Proposed by Marc Tardif on 2010-06-23
Status: Needs review
Proposed branch: lp:~cr3/ubuntu/lucid/checkbox/0.9.2
Merge into: lp:ubuntu/lucid/checkbox
Diff against target: 822 lines (+253/-247)
20 files modified
backend (+12/-3)
checkbox/job.py (+1/-1)
checkbox/resource.py (+3/-2)
checkbox/user_interface.py (+7/-2)
debian/changelog (+17/-0)
debian/control (+1/-0)
jobs/disk.txt.in (+1/-2)
jobs/local.txt.in (+1/-1)
jobs/resource.txt.in (+1/-0)
plugins/backend_info.py (+15/-17)
plugins/begin_prompt.py (+33/-0)
plugins/launchpad_exchange.py (+2/-1)
plugins/persist_info.py (+2/-2)
po/checkbox.pot (+10/-10)
scripts/ansi_parser (+2/-1)
scripts/device_list (+0/-168)
scripts/disk_test (+0/-33)
scripts/run_templates (+142/-0)
scripts/suspend_test (+2/-3)
scripts/udev_resource (+1/-1)
To merge this branch: bzr merge lp:~cr3/ubuntu/lucid/checkbox/0.9.2
Reviewer Review Type Date Requested Status
Mathias Gug 2010-06-23 Needs Fixing on 2010-07-08
Review via email: mp+28341@code.launchpad.net
To post a comment you must log in.
Mathias Gug (mathiaz) wrote :

In order to get this branch uploaded to lucid a proper SRU is required:

 1. debian/changelog: the target should be lucid-proposed instead of lucid.

 2. Every bug attached to the SRU proposal should be turned into a proper SRU report as outlined in https://wiki.ubuntu.com/StableReleaseUpdates#Procedure.

review: Needs Fixing
Mathias Gug (mathiaz) wrote :

The bug list may be trimmed to fix only high-impact bugs and get the SRU published earlier.

hawthornso23 (hawthorn) wrote :

What is happening with this. Bug 553328 is serious and potentially shortens the life of hardware. It leaves a CPU perpetually running at 100% until the next reboot (even logout/login wont stop it). Users of an LTS in particular often go months between reboots. I've just discovered that I have apparently been running a CPU at 100% for several weeks. No wonder it was running hot!

There seems to have been no activity here for six months. Is there a way of injecting more urgency into this process?

Unmerged revisions

16. By Marc Tardif on 2010-04-20

New upstream release (LP: #567568):
* Added referer when sending submissions to Launchpad (LP: #550973)
* Added suggests to checkbox package in debian/control file (LP: #352740)
* Fixed udev_resource script to be more resilient (LP: #556824)
* Fixed cdimage_resource script to read casper.log (LP: #558728)
* Fixed reporting all resources found for a job (LP: #560948)
* Fixed stalling when using kdesudo to start backend (LP: #557443)
* Fixed starting the appropriate default browser on UNR (LP: #563050)
* Fixed ansi_parser script when outputting to stdout (LP: #560952)
* Fixed opening the report with the gconf preferred browser (LP: #562580)
* Fixed suspend_test to use relative time for wakealarm (LP: #349768)
* Fixed backend not getting terminated upon closing (LP: #553328)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'backend'
2--- backend 2010-03-07 15:05:44 +0000
3+++ backend 2010-06-23 19:15:40 +0000
4@@ -1,32 +1,41 @@
5 #!/usr/bin/python
6
7+import os
8 import sys
9
10 from optparse import OptionParser
11 from checkbox.lib.fifo import FifoReader, FifoWriter
12
13-from checkbox.job import Job
14+from checkbox.job import Job, FAIL
15
16
17 def main(args):
18 usage = "Usage: %prog INPUT OUTPUT"
19 parser = OptionParser(usage=usage)
20+ parser.add_option("-p", "--path",
21+ help="PATH variable to replace in the environment")
22 (options, args) = parser.parse_args(args)
23
24 if len(args) < 2:
25 parser.error("Missing INPUT and OUTPUT")
26
27+ if options.path:
28+ os.environ["PATH"] = options.path
29+
30 reader = FifoReader(args[0])
31 writer = FifoWriter(args[1])
32
33 while True:
34 try:
35 message = reader.read_object()
36- if message:
37+ if isinstance(message, dict) and "command" in message:
38 job = Job(message["command"], message.get("environ"),
39 message.get("timeout"))
40 result = job.execute()
41- writer.write_object(result)
42+ else:
43+ result = (FAIL, "", 0,)
44+
45+ writer.write_object(result)
46 except IOError, e:
47 break
48
49
50=== modified file 'checkbox/job.py'
51--- checkbox/job.py 2010-03-09 16:58:36 +0000
52+++ checkbox/job.py 2010-06-23 19:15:40 +0000
53@@ -89,7 +89,7 @@
54
55 duration = process.endtime - process.starttime
56
57- return (status, data, duration)
58+ return (status, data, duration,)
59
60
61 class JobStore(MessageStore):
62
63=== modified file 'checkbox/resource.py'
64--- checkbox/resource.py 2010-03-07 15:05:44 +0000
65+++ checkbox/resource.py 2010-06-23 19:15:40 +0000
66@@ -52,15 +52,16 @@
67 return self._try(other, lambda a, b: a != b)
68
69 def _try(self, other, function, until=True, default=False):
70+ found = False
71 for item in self._list:
72 if self._name in item:
73 value = self._convert(item[self._name])
74 if function(value, other) == until:
75 # Append item to list of results
76 self._list._map._results.append(item)
77- return until
78+ found = True
79
80- return default
81+ return until if found else default
82
83
84 class ResourceList(list):
85
86=== modified file 'checkbox/user_interface.py'
87--- checkbox/user_interface.py 2010-03-07 15:05:44 +0000
88+++ checkbox/user_interface.py 2010-06-23 19:15:40 +0000
89@@ -175,21 +175,26 @@
90 # with respectively -new-window and --new-window
91 try:
92 if os.getenv("DISPLAY") and \
93- subprocess.call(["pgrep", "-x", "-u", str(uid), "gnome-panel"],
94+ subprocess.call(["pgrep", "-x", "-u", str(uid), "gnome-panel|gconfd-2"],
95 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
96 gct = subprocess.Popen(sudo_prefix + ["gconftool", "--get",
97 "/desktop/gnome/url-handlers/http/command"],
98 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
99- if gct.returncode == 0:
100+ if gct.wait() == 0:
101 preferred_browser = gct.communicate()[0]
102 browser = re.match("((firefox|seamonkey|flock)[^\s]*)", preferred_browser)
103 if browser:
104 subprocess.call(sudo_prefix + [browser.group(0), "-new-window", url])
105 sys.exit(0)
106+
107 browser = re.match("(epiphany[^\s]*)", preferred_browser)
108 if browser:
109 subprocess.call(sudo_prefix + [browser.group(0), "--new-window", url])
110 sys.exit(0)
111+
112+ subprocess.call(sudo_prefix + [preferred_browser % url], shell=True)
113+ sys.exit(0)
114+
115 if subprocess.call(sudo_prefix + ["gnome-open", url]) == 0:
116 sys.exit(0)
117 except OSError:
118
119=== modified file 'debian/changelog'
120--- debian/changelog 2010-03-07 15:05:44 +0000
121+++ debian/changelog 2010-06-23 19:15:40 +0000
122@@ -1,3 +1,20 @@
123+checkbox (0.9.2) lucid; urgency=low
124+
125+ New upstream release (LP: #567568):
126+ * Added referer when sending submissions to Launchpad (LP: #550973)
127+ * Added suggests to checkbox package in debian/control file (LP: #352740)
128+ * Fixed udev_resource script to be more resilient (LP: #556824)
129+ * Fixed cdimage_resource script to read casper.log (LP: #558728)
130+ * Fixed reporting all resources found for a job (LP: #560948)
131+ * Fixed stalling when using kdesudo to start backend (LP: #557443)
132+ * Fixed starting the appropriate default browser on UNR (LP: #563050)
133+ * Fixed ansi_parser script when outputting to stdout (LP: #560952)
134+ * Fixed opening the report with the gconf preferred browser (LP: #562580)
135+ * Fixed suspend_test to use relative time for wakealarm (LP: #349768)
136+ * Fixed backend not getting terminated upon closing (LP: #553328)
137+
138+ -- Marc Tardif <marc@ubuntu.com> Tue, 06 Apr 2010 14:17:46 -0400
139+
140 checkbox (0.9.1) lucid; urgency=low
141
142 New upstream release (LP: #548800):
143
144=== modified file 'debian/control'
145--- debian/control 2010-03-09 16:58:36 +0000
146+++ debian/control 2010-06-23 19:15:40 +0000
147@@ -15,6 +15,7 @@
148 Provides: hwtest
149 Depends: ${misc:Depends}, ${python:Depends}, debconf, udev
150 Recommends: dpkg, lsb-release, python-apport, python-apt, python-gst0.10
151+Suggests: checkbox-cli | checkbox-gtk
152 Conflicts: hwtest (<< 0.1-0ubuntu12)
153 XB-Python-Version: ${python:Versions}
154 Description: Checkbox System Testing
155
156=== modified file 'jobs/disk.txt.in'
157--- jobs/disk.txt.in 2010-03-07 15:05:44 +0000
158+++ jobs/disk.txt.in 2010-06-23 19:15:40 +0000
159@@ -1,7 +1,6 @@
160 plugin: manual
161 name: disk_test
162-user: root
163-command: disk_test
164+command: udev_resource | filter_templates -w "category=DISK" | awk -F': ' '$1 == "product" { print $2 }'
165 _description:
166 The following hard drives were detected:
167 .
168
169=== modified file 'jobs/local.txt.in'
170--- jobs/local.txt.in 2010-03-07 15:05:44 +0000
171+++ jobs/local.txt.in 2010-06-23 19:15:40 +0000
172@@ -59,7 +59,7 @@
173
174 name: dmesg
175 plugin: attachment
176-command: cat /var/log/dmesg
177+command: cat /var/log/dmesg | ansi_parser
178
179 name: dmi
180 plugin: attachment
181
182=== modified file 'jobs/resource.txt.in'
183--- jobs/resource.txt.in 2010-03-09 16:58:36 +0000
184+++ jobs/resource.txt.in 2010-06-23 19:15:40 +0000
185@@ -4,6 +4,7 @@
186
187 name: cdimage
188 plugin: resource
189+user: root
190 command: cdimage_resource
191
192 name: dpkg
193
194=== modified file 'plugins/backend_info.py'
195--- plugins/backend_info.py 2010-03-07 15:05:44 +0000
196+++ plugins/backend_info.py 2010-06-23 19:15:40 +0000
197@@ -18,7 +18,6 @@
198 #
199 import os
200 import shutil
201-import signal
202
203 from subprocess import call, PIPE
204 from tempfile import mkdtemp
205@@ -44,7 +43,12 @@
206 # Backend should run as early as possible
207 self._manager.reactor.call_on("gather", self.gather, -100)
208
209- def get_root_command(self, command):
210+ def get_command(self, *args):
211+ command = [self.command, "--path=%s" % os.environ["PATH"]]
212+
213+ return command + list(args)
214+
215+ def get_root_command(self, *args):
216 uid = os.getuid()
217 if uid == 0:
218 prefix = []
219@@ -59,17 +63,11 @@
220 stdout=PIPE, stderr=PIPE) == 0 and \
221 call(["pgrep", "-x", "-u", str(uid), "gnome-panel|gconfd-2"],
222 stdout=PIPE, stderr=PIPE) == 0:
223- prefix = ["gksu", "-k", "--"]
224+ prefix = ["gksu", "--"]
225 else:
226- prefix = ["sudo", "-E"]
227-
228- # Append PATH
229- prefix.append("PATH=%s" % os.environ["PATH"])
230-
231- # Extend command
232- prefix.extend(command)
233-
234- return prefix
235+ prefix = ["sudo"]
236+
237+ return prefix + self.get_command(*args)
238
239 def gather(self):
240 self.directory = mkdtemp(prefix="checkbox")
241@@ -82,8 +80,7 @@
242 self.parent_reader = FifoReader(child_output)
243
244 else:
245- command = [self.command, child_input, child_output]
246- root_command = self.get_root_command(command)
247+ root_command = self.get_root_command(child_input, child_output)
248 os.execvp(root_command[0], root_command)
249 # Should never get here
250
251@@ -95,10 +92,11 @@
252 self._manager.reactor.fire("message-result", *result)
253
254 def stop(self):
255- os.kill(self.pid, signal.SIGHUP)
256+ self.parent_writer.close()
257+ self.parent_reader.close()
258+ shutil.rmtree(self.directory)
259+
260 os.waitpid(self.pid, 0)
261
262- shutil.rmtree(self.directory)
263-
264
265 factory = BackendInfo
266
267=== added file 'plugins/begin_prompt.py'
268--- plugins/begin_prompt.py 1970-01-01 00:00:00 +0000
269+++ plugins/begin_prompt.py 2010-06-23 19:15:40 +0000
270@@ -0,0 +1,33 @@
271+#
272+# This file is part of Checkbox.
273+#
274+# Copyright 2010 Canonical Ltd.
275+#
276+# Checkbox is free software: you can redistribute it and/or modify
277+# it under the terms of the GNU General Public License as published by
278+# the Free Software Foundation, either version 3 of the License, or
279+# (at your option) any later version.
280+#
281+# Checkbox is distributed in the hope that it will be useful,
282+# but WITHOUT ANY WARRANTY; without even the implied warranty of
283+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
284+# GNU General Public License for more details.
285+#
286+# You should have received a copy of the GNU General Public License
287+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
288+#
289+from checkbox.plugin import Plugin
290+
291+
292+class BeginPrompt(Plugin):
293+
294+ def register(self, manager):
295+ super(BeginPrompt, self).register(manager)
296+
297+ self._manager.reactor.call_on("prompt-begin", self.prompt_begin)
298+
299+ def prompt_begin(self, interface):
300+ self._manager.reactor.fire("begin")
301+
302+
303+factory = BeginPrompt
304
305=== modified file 'plugins/launchpad_exchange.py'
306--- plugins/launchpad_exchange.py 2010-03-07 15:05:44 +0000
307+++ plugins/launchpad_exchange.py 2010-06-23 19:15:40 +0000
308@@ -60,7 +60,8 @@
309 def register(self, manager):
310 super(LaunchpadExchange, self).register(manager)
311
312- self._headers = {}
313+ self._headers = {
314+ "Referer": self.transport_url}
315 self._form = {
316 "field.private": "False",
317 "field.contactable": "False",
318
319=== modified file 'plugins/persist_info.py'
320--- plugins/persist_info.py 2010-03-09 16:58:36 +0000
321+++ plugins/persist_info.py 2010-06-23 19:15:40 +0000
322@@ -33,14 +33,14 @@
323 self.persist = None
324
325 for (rt, rh) in [
326- ("prompt-begin", self.prompt_begin),
327+ ("begin", self.begin),
328 ("prompt-job", self.save)]:
329 self._manager.reactor.call_on(rt, rh, -100)
330
331 # Save persist data last
332 self._manager.reactor.call_on("stop", self.save, 1000)
333
334- def prompt_begin(self, interface):
335+ def begin(self):
336 self.persist = Persist(self.filename)
337 self._manager.reactor.fire("begin-persist", self.persist)
338
339
340=== modified file 'po/checkbox.pot'
341--- po/checkbox.pot 2010-03-07 15:05:44 +0000
342+++ po/checkbox.pot 2010-06-23 19:15:40 +0000
343@@ -8,7 +8,7 @@
344 msgstr ""
345 "Project-Id-Version: PACKAGE VERSION\n"
346 "Report-Msgid-Bugs-To: \n"
347-"POT-Creation-Date: 2010-04-01 17:14-0400\n"
348+"POT-Creation-Date: 2010-04-14 18:05-0400\n"
349 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
350 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
351 "Language-Team: LANGUAGE <LL@li.org>\n"
352@@ -68,13 +68,13 @@
353 msgstr ""
354
355 #. description
356-#: ../jobs/audio.txt.in:7 ../jobs/disk.txt.in:17 ../jobs/network.txt.in:16
357+#: ../jobs/audio.txt.in:7 ../jobs/disk.txt.in:16 ../jobs/network.txt.in:16
358 #: ../jobs/video.txt.in:26
359 msgid "$output"
360 msgstr ""
361
362 #. description
363-#: ../jobs/audio.txt.in:7 ../jobs/disk.txt.in:5 ../jobs/network.txt.in:16
364+#: ../jobs/audio.txt.in:7 ../jobs/disk.txt.in:4 ../jobs/network.txt.in:16
365 #: ../jobs/video.txt.in:26
366 msgid "Is this correct?"
367 msgstr ""
368@@ -128,17 +128,17 @@
369 msgstr ""
370
371 #. description
372-#: ../jobs/disk.txt.in:5
373+#: ../jobs/disk.txt.in:4
374 msgid "The following hard drives were detected:"
375 msgstr ""
376
377 #. description
378-#: ../jobs/disk.txt.in:17
379+#: ../jobs/disk.txt.in:16
380 msgid "Disk benchmark:"
381 msgstr ""
382
383 #. description
384-#: ../jobs/disk.txt.in:17
385+#: ../jobs/disk.txt.in:16
386 msgid "Is this ok?"
387 msgstr ""
388
389@@ -693,12 +693,12 @@
390 "your system."
391 msgstr ""
392
393-#: ../plugins/launchpad_exchange.py:116
394+#: ../plugins/launchpad_exchange.py:117
395 #, python-format
396 msgid "Failed to process form: %s"
397 msgstr ""
398
399-#: ../plugins/launchpad_exchange.py:139
400+#: ../plugins/launchpad_exchange.py:140
401 #, python-format
402 msgid ""
403 "Failed to contact server. Please try\n"
404@@ -709,13 +709,13 @@
405 "https://launchpad.net/+hwdb/+submit"
406 msgstr ""
407
408-#: ../plugins/launchpad_exchange.py:148
409+#: ../plugins/launchpad_exchange.py:149
410 msgid ""
411 "Failed to upload to server,\n"
412 "please try again later."
413 msgstr ""
414
415-#: ../plugins/launchpad_exchange.py:160
416+#: ../plugins/launchpad_exchange.py:161
417 msgid "Information not posted to Launchpad."
418 msgstr ""
419
420
421=== modified file 'scripts/ansi_parser'
422--- scripts/ansi_parser 2010-03-07 15:05:44 +0000
423+++ scripts/ansi_parser 2010-06-23 19:15:40 +0000
424@@ -150,7 +150,8 @@
425 for arg in args:
426 output.write(parse_filename(arg))
427
428- output.close()
429+ if options.output and options.output != "-":
430+ output.close()
431
432 return 0
433
434
435=== removed file 'scripts/device_list'
436--- scripts/device_list 2010-03-07 15:05:44 +0000
437+++ scripts/device_list 1970-01-01 00:00:00 +0000
438@@ -1,168 +0,0 @@
439-#! /bin/sh -e
440-TYPE="$1"
441-
442-case $TYPE in
443- maybe-floppy)
444- logger -t list-devices "deprecated parameter maybe-floppy"
445- TYPE=floppy
446- ;;
447- cd|disk|partition|floppy|maybe-usb-floppy|usb-partition) ;;
448- *)
449- echo "Usage: $0 cd|disk|partition|floppy|maybe-usb-floppy|usb-partition" >&2
450- exit 2
451- ;;
452-esac
453-
454-if [ ! -d /sys/block ]; then
455- exit 0
456-fi
457-if type udevadm >/dev/null 2>&1; then
458- device_info () {
459- udevadm info -q "$1" -p "$2" 2>/dev/null
460- }
461-elif type udevinfo >/dev/null 2>&1; then
462- device_info () {
463- udevinfo -q "$1" -p "$2" 2>/dev/null
464- }
465-else
466- exit 0
467-fi
468-
469-device_name () {
470- local name
471- if ! name="$(device_info name "$1")"; then
472- name="$(printf %s "${1##*/}" | \
473- sed 's,!,/,g')"
474- fi
475- echo "/dev/$name"
476-}
477-
478-is_sataraid () {
479- grep -qs ^DMRAID- "$1/dm/uuid"
480-}
481-
482-is_sataraid_partition () {
483- # dmraid partitions are always slaved to another dm device
484- for slave in "$1"/slaves/dm-*; do
485- if [ -e "$slave" ]; then
486- return 0
487- fi
488- done
489- return 1
490-}
491-
492-if type dmraid >/dev/null 2>&1; then
493- raiddevs="$(dmraid -r -c || true)"
494-else
495- raiddevs=
496-fi
497-
498-# cloned-and-hacked from partman-base/init.d/parted
499-part_of_sataraid () {
500- local raiddev
501- for raiddev in $raiddevs; do
502- if [ "$(readlink -f "$raiddev")" = "$1" ]; then
503- return 0
504- fi
505- done
506- return 1
507-}
508-
509-syspaths=
510-scan_partition=false
511-case $TYPE in
512- partition)
513- for x in /sys/block/*/*[0-9]; do
514- [ -d "$x" ] || continue
515- syspaths="${syspaths:+$syspaths }$x"
516- done
517- for x in /sys/block/dm-*; do
518- [ -d "$x" ] || continue
519- (is_sataraid "$x" && is_sataraid_partition "$x") || continue
520- syspaths="${syspaths:+$syspaths }$x"
521- done
522- TYPE=disk
523- # Also allow misdetected USB devices
524- scan_partition=:
525- ;;
526- usb-partition)
527- for x in /sys/block/*/*; do
528- [ -d "$x" ] || continue
529- syspaths="${syspaths:+$syspaths }$x"
530- done
531- ;;
532- *)
533- for x in /sys/block/*; do
534- [ -d "$x" ] || continue
535- case $x in
536- /sys/block/dm-*)
537- if is_sataraid "$x" && is_sataraid_partition "$x"; then
538- continue
539- fi
540- ;;
541- *)
542- name="$(device_name "$x")"
543- if part_of_sataraid "$name"; then
544- continue
545- fi
546- ;;
547- esac
548- syspaths="${syspaths:+$syspaths }$x"
549- done
550- ;;
551-esac
552-for x in $syspaths; do
553- devpath="${x#/sys}"
554- match=false
555- case $TYPE in
556- floppy)
557- # TODO ugly special case for non-IDE floppies
558- case $devpath in
559- /block/fd[0-9]*)
560- match=:
561- ;;
562- esac
563- ;;
564- esac
565- if ! $match && [ "$TYPE" = cd ]; then
566- if device_info env "$devpath" | grep -q '^ID_CDROM='; then
567- match=:
568- fi
569- fi
570- if ! $match; then
571- if device_info env "$devpath" | grep -q "^ID_TYPE=$TYPE"; then
572- match=:
573- fi
574- fi
575- if ! $match && [ "$TYPE" = disk ]; then
576- case $devpath in
577- /block/cciss\!*|/block/ida\!*|/block/rd\!*|/block/mmcblk*)
578- match=:
579- ;;
580- /block/dm-*)
581- # for now, we only understand dmraid
582- if is_sataraid "/sys$devpath"; then
583- match=:
584- fi
585- ;;
586- esac
587- fi
588- # Some USB sticks and CD drives are misdetected as floppy
589- # This allows to scan for those
590- if ! $match && ( $scan_partition || [ "$TYPE" = maybe-usb-floppy ] ); then
591- if device_info env "$devpath" | grep -q '^ID_BUS=usb' && \
592- device_info env "$devpath" | grep -q '^ID_TYPE=floppy'; then
593- match=:
594- fi
595- fi
596- # Disk partitions, but only on USB drives
597- if ! $match && [ "$TYPE" = usb-partition ]; then
598- if device_info env "$devpath" | grep -q '^ID_BUS=usb' && \
599- device_info env "$devpath" | grep -q '^ID_TYPE=disk'; then
600- match=:
601- fi
602- fi
603- if $match; then
604- device_name "/sys$devpath"
605- fi
606-done
607
608=== removed file 'scripts/disk_test'
609--- scripts/disk_test 2010-03-07 15:05:44 +0000
610+++ scripts/disk_test 1970-01-01 00:00:00 +0000
611@@ -1,33 +0,0 @@
612-#!/usr/bin/python
613-
614-import os
615-import sys
616-
617-from subprocess import Popen, PIPE
618-
619-
620-def main(args):
621- directory = os.path.dirname(__file__)
622- script = os.path.join(directory, "device_list")
623- disk_devices_string = Popen([script, "disk"], stdout=PIPE).communicate()[0]
624- disk_devices_string = disk_devices_string.strip()
625-
626- if not disk_devices_string:
627- print "None"
628- else:
629- disk_devices = disk_devices_string.split("\n")
630- for disk_device in disk_devices:
631- disk = os.path.basename(disk_device)
632- model_path = "/sys/block/%s/device/model" % disk
633- model_file = open(model_path)
634- try:
635- model_name = model_file.read().strip()
636- print model_name
637- finally:
638- model_file.close()
639-
640- return 0
641-
642-
643-if __name__ == "__main__":
644- sys.exit(main(sys.argv[1:]))
645
646=== added file 'scripts/run_templates'
647--- scripts/run_templates 1970-01-01 00:00:00 +0000
648+++ scripts/run_templates 2010-06-23 19:15:40 +0000
649@@ -0,0 +1,142 @@
650+#!/usr/bin/env python
651+
652+import os
653+import re
654+import sys
655+import uuid
656+
657+from optparse import OptionParser
658+from subprocess import Popen, PIPE
659+
660+from checkbox.lib.template import Template
661+
662+
663+DEFAULT_INPUT = "-"
664+DEFAULT_OUTPUT = "-"
665+
666+COMMAND_TEMPLATE = """cat <<%(separator)s
667+%(input)s
668+%(separator)s"""
669+
670+
671+class Runner(object):
672+
673+ def __init__(self, input, output):
674+ self.input = input
675+ self.output = output
676+
677+ def get_args(self, record):
678+ return []
679+
680+ def get_env(self, record):
681+ env = dict(os.environ)
682+ env["NF"] = str(len(record))
683+
684+ return env
685+
686+ def process(self, args, shell=False):
687+ process = Popen(args, shell=shell, stdout=PIPE)
688+ records = self.process_output(process.stdout)
689+
690+ for nr, record in enumerate(records):
691+ args = self.get_args(record)
692+ env = self.get_env(record)
693+ env["NR"] = str(nr)
694+
695+ command_string = COMMAND_TEMPLATE % {
696+ "input": self.input,
697+ "separator": uuid.uuid4()}
698+ command = ["sh", "-c", command_string] + args
699+
700+ process = Popen(command,
701+ env=env,
702+ stdout=self.output)
703+ process.communicate()
704+
705+ def process_output(self, output):
706+ raise NotImplementedError
707+
708+
709+class LineRunner(Runner):
710+
711+ field_separator = r"\s+"
712+ record_separator = r"(?:\r?\n)"
713+
714+ def get_args(self, record):
715+ args = [record]
716+ args.extend(re.split(self.field_separator, record))
717+
718+ return args
719+
720+ def process_output(self, file):
721+ # Strip trailing separator
722+ data = re.sub(r"%s$" % self.record_separator, "", file.read())
723+
724+ return re.split(self.record_separator, data)
725+
726+
727+class TemplateRunner(Runner):
728+
729+ def get_env(self, record):
730+ env = super(TemplateRunner, self).get_env(record)
731+ env.update(record)
732+
733+ return env
734+
735+ def process_output(self, output):
736+ template = Template()
737+ return template.load_file(output)
738+
739+
740+def main(args):
741+ usage = "Usage: %prog [OPTIONS] [COMMAND]"
742+ parser = OptionParser(usage=usage)
743+ parser.add_option("-i", "--input",
744+ metavar="FILE",
745+ default=DEFAULT_INPUT,
746+ help="Input from the given file name, - for stdin")
747+ parser.add_option("-o", "--output",
748+ metavar="FILE",
749+ default=DEFAULT_OUTPUT,
750+ help="Output to the given file name, - for stdout")
751+ parser.add_option("-s", "--shell",
752+ action="store_true",
753+ help="Run the command as a shell script")
754+ parser.add_option("-t", "--template",
755+ action="store_true",
756+ help="Interpret the command output as a template")
757+ (options, args) = parser.parse_args(args)
758+
759+ # Default args to echo command
760+ if not args:
761+ args = ["echo"]
762+
763+ # Read input
764+ if options.input == "-":
765+ input = sys.stdin.read()
766+ else:
767+ input_file = open(options.input, "r")
768+ try:
769+ input = input_file.read()
770+ finally:
771+ input_file.close()
772+
773+ # Open output
774+ if options.output == "-":
775+ output_file = sys.stdout
776+ else:
777+ output_file = open(options.output, "w")
778+
779+ # Determine runner class
780+ if options.template:
781+ runner_class = TemplateRunner
782+ else:
783+ runner_class = LineRunner
784+
785+ runner = runner_class(input, output_file)
786+ runner.process(args, options.shell)
787+
788+ return 0
789+
790+if __name__ == "__main__":
791+ sys.exit(main(sys.argv[1:]))
792
793=== modified file 'scripts/suspend_test'
794--- scripts/suspend_test 2009-03-17 09:46:16 +0000
795+++ scripts/suspend_test 2010-06-23 19:15:40 +0000
796@@ -109,11 +109,10 @@
797 #
798 ctl='/sys/class/rtc/rtc0/wakealarm'
799 if [ -f "$ctl" ]; then
800- time=`date '+%s' -d "+ $timeout seconds"`
801 # Cancel any outstanding timers.
802 echo "0" >"$ctl"
803- # rtcN/wakealarm uses absolute time in seconds
804- echo "$time" >"$ctl"
805+ # rtcN/wakealarm can use relative time in seconds
806+ echo "+$timeout" >"$ctl"
807 return 0
808 fi
809 ctl='/proc/acpi/alarm'
810
811=== modified file 'scripts/udev_resource'
812--- scripts/udev_resource 2010-03-07 15:05:44 +0000
813+++ scripts/udev_resource 2010-06-23 19:15:40 +0000
814@@ -476,7 +476,7 @@
815 def devices(self):
816 devices = []
817 line_pattern = re.compile(r"(?P<key>\w):\s*(?P<value>.*)")
818- multi_pattern = re.compile(r"(?P<key>\w+)=(?P<value>.*)")
819+ multi_pattern = re.compile(r"(?P<key>[^=]+)=(?P<value>.*)")
820
821 output = Popen(COMMAND, stdout=PIPE, shell=True).communicate()[0]
822 for record in output.split("\n\n"):

Subscribers

People subscribed via source and target branches

to all changes: