Merge lp:~matsubara/checkbox/maas-tests into lp:~nskaggs/checkbox/checkbox-app-testing

Proposed by Diogo Matsubara
Status: Superseded
Proposed branch: lp:~matsubara/checkbox/maas-tests
Merge into: lp:~nskaggs/checkbox/checkbox-app-testing
Diff against target: 379979 lines (+378475/-0) (has conflicts)
283 files modified
.bzr-builddeb/default.conf (+2/-0)
.bzrignore (+38/-0)
.checkbox-editor.cfg (+18/-0)
COPYING (+674/-0)
README (+5/-0)
apport/checkbox.py (+24/-0)
apport/source_checkbox.py (+20/-0)
backend (+51/-0)
bin/checkbox-app-testing (+35/-0)
checkbox/application.py (+136/-0)
checkbox/arguments.py (+95/-0)
checkbox/attribute.py (+41/-0)
checkbox/component.py (+184/-0)
checkbox/contrib/REThread.py (+139/-0)
checkbox/contrib/bpickle.py (+167/-0)
checkbox/contrib/glock.py (+316/-0)
checkbox/contrib/persist.py (+552/-0)
checkbox/dispatcher.py (+201/-0)
checkbox/job.py (+140/-0)
checkbox/lib/bit.py (+46/-0)
checkbox/lib/cache.py (+37/-0)
checkbox/lib/config.py (+173/-0)
checkbox/lib/conversion.py (+169/-0)
checkbox/lib/decorator.py (+28/-0)
checkbox/lib/dmi.py (+225/-0)
checkbox/lib/enum.py (+72/-0)
checkbox/lib/environ.py (+113/-0)
checkbox/lib/fifo.py (+105/-0)
checkbox/lib/input.py (+585/-0)
checkbox/lib/log.py (+77/-0)
checkbox/lib/path.py (+66/-0)
checkbox/lib/pci.py (+86/-0)
checkbox/lib/process.py (+139/-0)
checkbox/lib/redirect.py (+158/-0)
checkbox/lib/resolver.py (+126/-0)
checkbox/lib/safe.py (+102/-0)
checkbox/lib/script.py (+33/-0)
checkbox/lib/selector.py (+207/-0)
checkbox/lib/signal.py (+89/-0)
checkbox/lib/template.py (+144/-0)
checkbox/lib/template_i18n.py (+134/-0)
checkbox/lib/tests/resolver.py (+100/-0)
checkbox/lib/text.py (+100/-0)
checkbox/lib/transport.py (+336/-0)
checkbox/lib/update.py (+42/-0)
checkbox/lib/url.py (+41/-0)
checkbox/lib/usb.py (+59/-0)
checkbox/message.py (+332/-0)
checkbox/parsers/cpuinfo.py (+180/-0)
checkbox/parsers/cputable (+40/-0)
checkbox/parsers/cputable.py (+42/-0)
checkbox/parsers/deferred.py (+27/-0)
checkbox/parsers/description.py (+74/-0)
checkbox/parsers/device.py (+24/-0)
checkbox/parsers/dmidecode.py (+123/-0)
checkbox/parsers/meminfo.py (+46/-0)
checkbox/parsers/submission.py (+540/-0)
checkbox/parsers/tests/cputable.py (+74/-0)
checkbox/parsers/tests/description.py (+146/-0)
checkbox/parsers/tests/dmi.py (+80/-0)
checkbox/parsers/tests/dmidecode.py (+60/-0)
checkbox/parsers/tests/udevadm.py (+68/-0)
checkbox/parsers/udevadm.py (+472/-0)
checkbox/parsers/utils.py (+36/-0)
checkbox/plugin.py (+50/-0)
checkbox/properties.py (+209/-0)
checkbox/reactor.py (+118/-0)
checkbox/report.py (+177/-0)
checkbox/reports/launchpad_report.py (+287/-0)
checkbox/reports/xml_report.py (+191/-0)
checkbox/resource.py (+140/-0)
checkbox/tests/report.py (+109/-0)
checkbox/user_interface.py (+216/-0)
checkbox/variables.py (+302/-0)
checkbox_qt/qt_interface.py (+248/-0)
debian/changelog (+174/-0)
debian/checkbox-app-testing.postinst (+6/-0)
debian/checkbox-app-testing.postrm (+29/-0)
debian/compat (+1/-0)
debian/control (+18/-0)
debian/copyright (+36/-0)
debian/rules (+16/-0)
debian/source/format (+1/-0)
examples/checkbox-app-testing.ini (+33/-0)
icons/scalable/apps/checkbox.svg (+336/-0)
install/config (+162/-0)
install/postinst (+79/-0)
jobs/dejadup.txt.in (+37/-0)
jobs/empathy.txt.in (+89/-0)
jobs/eog.txt.in (+98/-0)
jobs/evince.txt.in (+89/-0)
jobs/fileroller.txt.in (+34/-0)
jobs/firefox.txt.in (+45/-0)
jobs/gedit.txt.in (+105/-0)
jobs/gnomecontrolcenter.txt.in (+10/-0)
jobs/gnomescreenshot.txt.in (+48/-0)
jobs/gnometerminal.txt.in (+76/-0)
jobs/gwibber.txt.in (+16/-0)
jobs/juju.txt.in (+24/-0)
jobs/libreoffice.txt.in (+486/-0)
jobs/local.txt.in (+168/-0)
jobs/maasserver.txt.in (+29/-0)
jobs/mandatory.txt.in (+5/-0)
jobs/nautilus.txt.in (+157/-0)
jobs/networkmanager.txt.in (+243/-0)
jobs/orca.txt.in (+130/-0)
jobs/resource.txt.in (+69/-0)
jobs/rhythmbox.txt.in (+88/-0)
jobs/seahorse.txt.in (+10/-0)
jobs/shotwell.txt.in (+113/-0)
jobs/softwarecenter.txt.in (+10/-0)
jobs/thunderbird.txt.in (+10/-0)
jobs/totem.txt.in (+33/-0)
jobs/ubuntumaasinstaller.txt.in (+36/-0)
jobs/ubuntuone.txt.in (+50/-0)
jobs/updatemanager.txt.in (+14/-0)
man/checkbox.1 (+106/-0)
plugins/apport_prompt.py (+281/-0)
plugins/attachment_info.py (+39/-0)
plugins/backend_info.py (+153/-0)
plugins/begin_prompt.py (+33/-0)
plugins/client_info.py (+43/-0)
plugins/datetime_info.py (+36/-0)
plugins/delay_prompt.py (+37/-0)
plugins/error_prompt.py (+34/-0)
plugins/final_prompt.py (+37/-0)
plugins/gather_prompt.py (+39/-0)
plugins/intro_prompt.py (+54/-0)
plugins/jobs_info.py (+149/-0)
plugins/jobs_prompt.py (+162/-0)
plugins/launchpad_exchange.py (+184/-0)
plugins/launchpad_prompt.py (+109/-0)
plugins/launchpad_report.py (+223/-0)
plugins/local_suite.py (+47/-0)
plugins/lock_prompt.py (+78/-0)
plugins/manual_test.py (+48/-0)
plugins/message_info.py (+126/-0)
plugins/metric_test.py (+41/-0)
plugins/persist_info.py (+70/-0)
plugins/proxy_info.py (+84/-0)
plugins/recover_prompt.py (+68/-0)
plugins/remote_suite.py (+48/-0)
plugins/report_prompt.py (+46/-0)
plugins/resource_info.py (+78/-0)
plugins/scripts_info.py (+41/-0)
plugins/server_info.py (+42/-0)
plugins/shell_test.py (+63/-0)
plugins/sleep_info.py (+42/-0)
plugins/submission_info.py (+64/-0)
plugins/subunit_report.py (+79/-0)
plugins/suites_prompt.py (+130/-0)
plugins/system_info.py (+89/-0)
plugins/tests_prompt.py (+33/-0)
plugins/user_interface.py (+116/-0)
po/POTFILES.in (+21/-0)
po/ace.po (+3015/-0)
po/af.po (+3009/-0)
po/am.po (+3036/-0)
po/ar.po (+3312/-0)
po/ast.po (+6023/-0)
po/az.po (+2994/-0)
po/be.po (+4628/-0)
po/bg.po (+3564/-0)
po/bn.po (+3810/-0)
po/bo.po (+3134/-0)
po/br.po (+3220/-0)
po/bs.po (+4653/-0)
po/ca.po (+4148/-0)
po/ca@valencia.po (+3866/-0)
po/checkbox.pot (+423/-0)
po/ckb.po (+3069/-0)
po/cs.po (+5706/-0)
po/cy.po (+3003/-0)
po/da.po (+4660/-0)
po/de.po (+6415/-0)
po/dv.po (+2994/-0)
po/el.po (+5331/-0)
po/en_AU.po (+5724/-0)
po/en_CA.po (+3414/-0)
po/en_GB.po (+5962/-0)
po/eo.po (+4102/-0)
po/es.po (+6091/-0)
po/et.po (+3099/-0)
po/eu.po (+3234/-0)
po/fa.po (+2994/-0)
po/fi.po (+5149/-0)
po/fr.po (+5129/-0)
po/ga.po (+2994/-0)
po/gd.po (+3024/-0)
po/gl.po (+4943/-0)
po/he.po (+3762/-0)
po/hi.po (+3526/-0)
po/hr.po (+3290/-0)
po/hu.po (+4889/-0)
po/hy.po (+2994/-0)
po/id.po (+3326/-0)
po/is.po (+3109/-0)
po/it.po (+5914/-0)
po/ja.po (+4168/-0)
po/jbo.po (+2994/-0)
po/ka.po (+2997/-0)
po/kk.po (+3104/-0)
po/km.po (+2994/-0)
po/kn.po (+3021/-0)
po/ko.po (+3736/-0)
po/ku.po (+3021/-0)
po/ky.po (+2994/-0)
po/lt.po (+3287/-0)
po/lv.po (+4144/-0)
po/mk.po (+3034/-0)
po/ml.po (+3006/-0)
po/mr.po (+3012/-0)
po/ms.po (+5919/-0)
po/my.po (+3089/-0)
po/nb.po (+3306/-0)
po/nds.po (+2994/-0)
po/ne.po (+3075/-0)
po/nl.po (+5461/-0)
po/nn.po (+3022/-0)
po/oc.po (+3961/-0)
po/pl.po (+4369/-0)
po/ps.po (+2994/-0)
po/pt.po (+4404/-0)
po/pt_BR.po (+6099/-0)
po/ro.po (+4781/-0)
po/ru.po (+6132/-0)
po/sd.po (+2994/-0)
po/shn.po (+2994/-0)
po/si.po (+3009/-0)
po/sk.po (+3794/-0)
po/sl.po (+5635/-0)
po/sq.po (+4419/-0)
po/sr.po (+4599/-0)
po/sv.po (+4650/-0)
po/ta.po (+3014/-0)
po/te.po (+3003/-0)
po/th.po (+3273/-0)
po/tr.po (+5330/-0)
po/ug.po (+5734/-0)
po/uk.po (+3918/-0)
po/ur.po (+2994/-0)
po/uz.po (+2994/-0)
po/vi.po (+3519/-0)
po/zh_CN.po (+3892/-0)
po/zh_HK.po (+3470/-0)
po/zh_TW.po (+3711/-0)
pulseaudio_settings (+6/-0)
qt/checkbox-app-testing.desktop.in (+11/-0)
qt/checkbox-qt.ui (+935/-0)
qt/checkbox.svg (+2478/-0)
qt/com.canonical.QtCheckbox.service (+3/-0)
qt/frontend/frontend.pro (+25/-0)
qt/frontend/main.cpp (+14/-0)
qt/frontend/qtfront.cpp (+594/-0)
qt/frontend/qtfront.h (+110/-0)
qt/frontend/qtfront.ui (+1142/-0)
qt/frontend/resources.qrc (+5/-0)
qt/frontend/step.cpp (+52/-0)
qt/frontend/step.h (+13/-0)
qt/frontend/treemodel.cpp (+90/-0)
qt/frontend/treemodel.h (+20/-0)
report/checkbox.js (+16/-0)
report/checkbox.xsl (+188/-0)
report/hardware-1_0.rng (+533/-0)
report/styles.css (+258/-0)
run (+40/-0)
scripts/cdimage_resource (+96/-0)
scripts/cpuinfo_resource (+56/-0)
scripts/dmi_resource (+55/-0)
scripts/dpkg_resource (+50/-0)
scripts/filter_packages (+179/-0)
scripts/filter_templates (+127/-0)
scripts/gconf_resource (+95/-0)
scripts/hal_resource (+471/-0)
scripts/lsb_resource (+55/-0)
scripts/meminfo_resource (+46/-0)
scripts/module_resource (+72/-0)
scripts/package_resource (+125/-0)
scripts/udev_resource (+55/-0)
scripts/uname_resource (+38/-0)
setup.cfg (+38/-0)
setup.py (+232/-0)
test (+179/-0)
Conflict adding file .bzrignore.  Moved existing file to .bzrignore.moved.
Conflict adding file COPYING.  Moved existing file to COPYING.moved.
Conflict adding file bin.  Moved existing file to bin.moved.
Conflict adding file configs.  Moved existing file to configs.moved.
Conflict adding file data.  Moved existing file to data.moved.
Conflict adding file debian.  Moved existing file to debian.moved.
Conflict adding file examples.  Moved existing file to examples.moved.
Conflict adding file jobs.  Moved existing file to jobs.moved.
Conflict adding file plugins.  Moved existing file to plugins.moved.
Conflict adding file po.  Moved existing file to po.moved.
Conflict adding file scripts.  Moved existing file to scripts.moved.
Conflict adding file setup.cfg.  Moved existing file to setup.cfg.moved.
Conflict adding file setup.py.  Moved existing file to setup.py.moved.
To merge this branch: bzr merge lp:~matsubara/checkbox/maas-tests
Reviewer Review Type Date Requested Status
Nicholas Skaggs Pending
Review via email: mp+99817@code.launchpad.net

Description of the change

This branch adds some checkbox manual tests for the MAAS project as well as some juju tests to run against a MAAS cluster.

Tests are categorized like the following:
- tests to be done from the Ubuntu installer;
- tests to be done on the MAAS server web ui;
- tests to be done using juju to deploy to a MAAS cluster;

To post a comment you must log in.
lp:~matsubara/checkbox/maas-tests updated
1355. By Diogo Matsubara

add MAAS from archive test

Unmerged revisions

1355. By Diogo Matsubara

add MAAS from archive test

1354. By Diogo Matsubara

add tests for MAAS server, juju on MAAS and node enlistment.

1353. By Nicholas Skaggs

fix missing scripts and paths

1352. By Nicholas Skaggs

add missing scripts
replace ubuntu friendly reference

1351. By Nicholas Skaggs

migrate to usr/lib from usr/share

1350. By Nicholas Skaggs

remove pycompat, add larger description

1349. By Nicholas Skaggs

remove icon installation
remove staging db location

1348. By Nicholas Skaggs

fix (another) typo

1347. By Nicholas Skaggs

fix typo

1346. By Nicholas Skaggs

fix ini file, and installed files to not conflict with checkbox install

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.bzr-builddeb'
2=== added file '.bzr-builddeb/default.conf'
3--- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000
4+++ .bzr-builddeb/default.conf 2012-03-28 20:34:20 +0000
5@@ -0,0 +1,2 @@
6+[BUILDDEB]
7+native = True
8
9=== added file '.bzrignore'
10--- .bzrignore 1970-01-01 00:00:00 +0000
11+++ .bzrignore 2012-03-28 20:34:20 +0000
12@@ -0,0 +1,38 @@
13+build
14+checkbox.log
15+checkbox.xsl
16+debian/checkbox
17+debian/checkbox-cli
18+debian/checkbox-gtk
19+debian/checkbox-qt
20+debian/checkbox-urwid
21+debian/*-cli.postrm
22+debian/*.debhelper
23+debian/files
24+debian/*-gtk.postrm
25+debian/*-qt.postrm
26+debian/*.log
27+debian/stamp-patched
28+debian/*.substvars
29+debian/tmp
30+debian/*-urwid.postrm
31+gtk/checkbox-gtk.glade.bak
32+gtk/checkbox-gtk.gladep
33+gtk/checkbox-gtk.gladep.bak
34+qt/frontend/Makefile
35+qt/frontend/checkbox-qt-service
36+qt/frontend/moc_qtfront.cpp
37+qt/frontend/ui_qtfront.h
38+qt/frontend/qrc_resources.cpp
39+lock
40+plugins.bpickle
41+plugins.bpickle.old
42+python-build-stamp-2.5
43+scripts/clocktest
44+scripts/threaded_memtest
45+store
46+submission
47+submission.xml
48+submission.xml
49+subunit.log
50+system
51
52=== renamed file '.bzrignore' => '.bzrignore.moved'
53=== added file '.checkbox-editor.cfg'
54--- .checkbox-editor.cfg 1970-01-01 00:00:00 +0000
55+++ .checkbox-editor.cfg 2012-03-28 20:34:20 +0000
56@@ -0,0 +1,18 @@
57+[environment]
58+checkbox_share = .
59+
60+[version control]
61+push_branch = lp:checkbox
62+pull_branch = lp:checkbox
63+push_on_close = False
64+commit_on_save = False
65+pull_on_open = False
66+exclude = .checkbox-editor.cfg
67+
68+[general]
69+checkbox_data_cleanup = True
70+replace_tabs_with_spaces = True
71+number_of_spaces = 4
72+checkbox_binary = ./bin/checkbox-gtk
73+whitelist_resources = True
74+
75
76=== added file 'COPYING'
77--- COPYING 1970-01-01 00:00:00 +0000
78+++ COPYING 2012-03-28 20:34:20 +0000
79@@ -0,0 +1,674 @@
80+ GNU GENERAL PUBLIC LICENSE
81+ Version 3, 29 June 2007
82+
83+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
84+ Everyone is permitted to copy and distribute verbatim copies
85+ of this license document, but changing it is not allowed.
86+
87+ Preamble
88+
89+ The GNU General Public License is a free, copyleft license for
90+software and other kinds of works.
91+
92+ The licenses for most software and other practical works are designed
93+to take away your freedom to share and change the works. By contrast,
94+the GNU General Public License is intended to guarantee your freedom to
95+share and change all versions of a program--to make sure it remains free
96+software for all its users. We, the Free Software Foundation, use the
97+GNU General Public License for most of our software; it applies also to
98+any other work released this way by its authors. You can apply it to
99+your programs, too.
100+
101+ When we speak of free software, we are referring to freedom, not
102+price. Our General Public Licenses are designed to make sure that you
103+have the freedom to distribute copies of free software (and charge for
104+them if you wish), that you receive source code or can get it if you
105+want it, that you can change the software or use pieces of it in new
106+free programs, and that you know you can do these things.
107+
108+ To protect your rights, we need to prevent others from denying you
109+these rights or asking you to surrender the rights. Therefore, you have
110+certain responsibilities if you distribute copies of the software, or if
111+you modify it: responsibilities to respect the freedom of others.
112+
113+ For example, if you distribute copies of such a program, whether
114+gratis or for a fee, you must pass on to the recipients the same
115+freedoms that you received. You must make sure that they, too, receive
116+or can get the source code. And you must show them these terms so they
117+know their rights.
118+
119+ Developers that use the GNU GPL protect your rights with two steps:
120+(1) assert copyright on the software, and (2) offer you this License
121+giving you legal permission to copy, distribute and/or modify it.
122+
123+ For the developers' and authors' protection, the GPL clearly explains
124+that there is no warranty for this free software. For both users' and
125+authors' sake, the GPL requires that modified versions be marked as
126+changed, so that their problems will not be attributed erroneously to
127+authors of previous versions.
128+
129+ Some devices are designed to deny users access to install or run
130+modified versions of the software inside them, although the manufacturer
131+can do so. This is fundamentally incompatible with the aim of
132+protecting users' freedom to change the software. The systematic
133+pattern of such abuse occurs in the area of products for individuals to
134+use, which is precisely where it is most unacceptable. Therefore, we
135+have designed this version of the GPL to prohibit the practice for those
136+products. If such problems arise substantially in other domains, we
137+stand ready to extend this provision to those domains in future versions
138+of the GPL, as needed to protect the freedom of users.
139+
140+ Finally, every program is threatened constantly by software patents.
141+States should not allow patents to restrict development and use of
142+software on general-purpose computers, but in those that do, we wish to
143+avoid the special danger that patents applied to a free program could
144+make it effectively proprietary. To prevent this, the GPL assures that
145+patents cannot be used to render the program non-free.
146+
147+ The precise terms and conditions for copying, distribution and
148+modification follow.
149+
150+ TERMS AND CONDITIONS
151+
152+ 0. Definitions.
153+
154+ "This License" refers to version 3 of the GNU General Public License.
155+
156+ "Copyright" also means copyright-like laws that apply to other kinds of
157+works, such as semiconductor masks.
158+
159+ "The Program" refers to any copyrightable work licensed under this
160+License. Each licensee is addressed as "you". "Licensees" and
161+"recipients" may be individuals or organizations.
162+
163+ To "modify" a work means to copy from or adapt all or part of the work
164+in a fashion requiring copyright permission, other than the making of an
165+exact copy. The resulting work is called a "modified version" of the
166+earlier work or a work "based on" the earlier work.
167+
168+ A "covered work" means either the unmodified Program or a work based
169+on the Program.
170+
171+ To "propagate" a work means to do anything with it that, without
172+permission, would make you directly or secondarily liable for
173+infringement under applicable copyright law, except executing it on a
174+computer or modifying a private copy. Propagation includes copying,
175+distribution (with or without modification), making available to the
176+public, and in some countries other activities as well.
177+
178+ To "convey" a work means any kind of propagation that enables other
179+parties to make or receive copies. Mere interaction with a user through
180+a computer network, with no transfer of a copy, is not conveying.
181+
182+ An interactive user interface displays "Appropriate Legal Notices"
183+to the extent that it includes a convenient and prominently visible
184+feature that (1) displays an appropriate copyright notice, and (2)
185+tells the user that there is no warranty for the work (except to the
186+extent that warranties are provided), that licensees may convey the
187+work under this License, and how to view a copy of this License. If
188+the interface presents a list of user commands or options, such as a
189+menu, a prominent item in the list meets this criterion.
190+
191+ 1. Source Code.
192+
193+ The "source code" for a work means the preferred form of the work
194+for making modifications to it. "Object code" means any non-source
195+form of a work.
196+
197+ A "Standard Interface" means an interface that either is an official
198+standard defined by a recognized standards body, or, in the case of
199+interfaces specified for a particular programming language, one that
200+is widely used among developers working in that language.
201+
202+ The "System Libraries" of an executable work include anything, other
203+than the work as a whole, that (a) is included in the normal form of
204+packaging a Major Component, but which is not part of that Major
205+Component, and (b) serves only to enable use of the work with that
206+Major Component, or to implement a Standard Interface for which an
207+implementation is available to the public in source code form. A
208+"Major Component", in this context, means a major essential component
209+(kernel, window system, and so on) of the specific operating system
210+(if any) on which the executable work runs, or a compiler used to
211+produce the work, or an object code interpreter used to run it.
212+
213+ The "Corresponding Source" for a work in object code form means all
214+the source code needed to generate, install, and (for an executable
215+work) run the object code and to modify the work, including scripts to
216+control those activities. However, it does not include the work's
217+System Libraries, or general-purpose tools or generally available free
218+programs which are used unmodified in performing those activities but
219+which are not part of the work. For example, Corresponding Source
220+includes interface definition files associated with source files for
221+the work, and the source code for shared libraries and dynamically
222+linked subprograms that the work is specifically designed to require,
223+such as by intimate data communication or control flow between those
224+subprograms and other parts of the work.
225+
226+ The Corresponding Source need not include anything that users
227+can regenerate automatically from other parts of the Corresponding
228+Source.
229+
230+ The Corresponding Source for a work in source code form is that
231+same work.
232+
233+ 2. Basic Permissions.
234+
235+ All rights granted under this License are granted for the term of
236+copyright on the Program, and are irrevocable provided the stated
237+conditions are met. This License explicitly affirms your unlimited
238+permission to run the unmodified Program. The output from running a
239+covered work is covered by this License only if the output, given its
240+content, constitutes a covered work. This License acknowledges your
241+rights of fair use or other equivalent, as provided by copyright law.
242+
243+ You may make, run and propagate covered works that you do not
244+convey, without conditions so long as your license otherwise remains
245+in force. You may convey covered works to others for the sole purpose
246+of having them make modifications exclusively for you, or provide you
247+with facilities for running those works, provided that you comply with
248+the terms of this License in conveying all material for which you do
249+not control copyright. Those thus making or running the covered works
250+for you must do so exclusively on your behalf, under your direction
251+and control, on terms that prohibit them from making any copies of
252+your copyrighted material outside their relationship with you.
253+
254+ Conveying under any other circumstances is permitted solely under
255+the conditions stated below. Sublicensing is not allowed; section 10
256+makes it unnecessary.
257+
258+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
259+
260+ No covered work shall be deemed part of an effective technological
261+measure under any applicable law fulfilling obligations under article
262+11 of the WIPO copyright treaty adopted on 20 December 1996, or
263+similar laws prohibiting or restricting circumvention of such
264+measures.
265+
266+ When you convey a covered work, you waive any legal power to forbid
267+circumvention of technological measures to the extent such circumvention
268+is effected by exercising rights under this License with respect to
269+the covered work, and you disclaim any intention to limit operation or
270+modification of the work as a means of enforcing, against the work's
271+users, your or third parties' legal rights to forbid circumvention of
272+technological measures.
273+
274+ 4. Conveying Verbatim Copies.
275+
276+ You may convey verbatim copies of the Program's source code as you
277+receive it, in any medium, provided that you conspicuously and
278+appropriately publish on each copy an appropriate copyright notice;
279+keep intact all notices stating that this License and any
280+non-permissive terms added in accord with section 7 apply to the code;
281+keep intact all notices of the absence of any warranty; and give all
282+recipients a copy of this License along with the Program.
283+
284+ You may charge any price or no price for each copy that you convey,
285+and you may offer support or warranty protection for a fee.
286+
287+ 5. Conveying Modified Source Versions.
288+
289+ You may convey a work based on the Program, or the modifications to
290+produce it from the Program, in the form of source code under the
291+terms of section 4, provided that you also meet all of these conditions:
292+
293+ a) The work must carry prominent notices stating that you modified
294+ it, and giving a relevant date.
295+
296+ b) The work must carry prominent notices stating that it is
297+ released under this License and any conditions added under section
298+ 7. This requirement modifies the requirement in section 4 to
299+ "keep intact all notices".
300+
301+ c) You must license the entire work, as a whole, under this
302+ License to anyone who comes into possession of a copy. This
303+ License will therefore apply, along with any applicable section 7
304+ additional terms, to the whole of the work, and all its parts,
305+ regardless of how they are packaged. This License gives no
306+ permission to license the work in any other way, but it does not
307+ invalidate such permission if you have separately received it.
308+
309+ d) If the work has interactive user interfaces, each must display
310+ Appropriate Legal Notices; however, if the Program has interactive
311+ interfaces that do not display Appropriate Legal Notices, your
312+ work need not make them do so.
313+
314+ A compilation of a covered work with other separate and independent
315+works, which are not by their nature extensions of the covered work,
316+and which are not combined with it such as to form a larger program,
317+in or on a volume of a storage or distribution medium, is called an
318+"aggregate" if the compilation and its resulting copyright are not
319+used to limit the access or legal rights of the compilation's users
320+beyond what the individual works permit. Inclusion of a covered work
321+in an aggregate does not cause this License to apply to the other
322+parts of the aggregate.
323+
324+ 6. Conveying Non-Source Forms.
325+
326+ You may convey a covered work in object code form under the terms
327+of sections 4 and 5, provided that you also convey the
328+machine-readable Corresponding Source under the terms of this License,
329+in one of these ways:
330+
331+ a) Convey the object code in, or embodied in, a physical product
332+ (including a physical distribution medium), accompanied by the
333+ Corresponding Source fixed on a durable physical medium
334+ customarily used for software interchange.
335+
336+ b) Convey the object code in, or embodied in, a physical product
337+ (including a physical distribution medium), accompanied by a
338+ written offer, valid for at least three years and valid for as
339+ long as you offer spare parts or customer support for that product
340+ model, to give anyone who possesses the object code either (1) a
341+ copy of the Corresponding Source for all the software in the
342+ product that is covered by this License, on a durable physical
343+ medium customarily used for software interchange, for a price no
344+ more than your reasonable cost of physically performing this
345+ conveying of source, or (2) access to copy the
346+ Corresponding Source from a network server at no charge.
347+
348+ c) Convey individual copies of the object code with a copy of the
349+ written offer to provide the Corresponding Source. This
350+ alternative is allowed only occasionally and noncommercially, and
351+ only if you received the object code with such an offer, in accord
352+ with subsection 6b.
353+
354+ d) Convey the object code by offering access from a designated
355+ place (gratis or for a charge), and offer equivalent access to the
356+ Corresponding Source in the same way through the same place at no
357+ further charge. You need not require recipients to copy the
358+ Corresponding Source along with the object code. If the place to
359+ copy the object code is a network server, the Corresponding Source
360+ may be on a different server (operated by you or a third party)
361+ that supports equivalent copying facilities, provided you maintain
362+ clear directions next to the object code saying where to find the
363+ Corresponding Source. Regardless of what server hosts the
364+ Corresponding Source, you remain obligated to ensure that it is
365+ available for as long as needed to satisfy these requirements.
366+
367+ e) Convey the object code using peer-to-peer transmission, provided
368+ you inform other peers where the object code and Corresponding
369+ Source of the work are being offered to the general public at no
370+ charge under subsection 6d.
371+
372+ A separable portion of the object code, whose source code is excluded
373+from the Corresponding Source as a System Library, need not be
374+included in conveying the object code work.
375+
376+ A "User Product" is either (1) a "consumer product", which means any
377+tangible personal property which is normally used for personal, family,
378+or household purposes, or (2) anything designed or sold for incorporation
379+into a dwelling. In determining whether a product is a consumer product,
380+doubtful cases shall be resolved in favor of coverage. For a particular
381+product received by a particular user, "normally used" refers to a
382+typical or common use of that class of product, regardless of the status
383+of the particular user or of the way in which the particular user
384+actually uses, or expects or is expected to use, the product. A product
385+is a consumer product regardless of whether the product has substantial
386+commercial, industrial or non-consumer uses, unless such uses represent
387+the only significant mode of use of the product.
388+
389+ "Installation Information" for a User Product means any methods,
390+procedures, authorization keys, or other information required to install
391+and execute modified versions of a covered work in that User Product from
392+a modified version of its Corresponding Source. The information must
393+suffice to ensure that the continued functioning of the modified object
394+code is in no case prevented or interfered with solely because
395+modification has been made.
396+
397+ If you convey an object code work under this section in, or with, or
398+specifically for use in, a User Product, and the conveying occurs as
399+part of a transaction in which the right of possession and use of the
400+User Product is transferred to the recipient in perpetuity or for a
401+fixed term (regardless of how the transaction is characterized), the
402+Corresponding Source conveyed under this section must be accompanied
403+by the Installation Information. But this requirement does not apply
404+if neither you nor any third party retains the ability to install
405+modified object code on the User Product (for example, the work has
406+been installed in ROM).
407+
408+ The requirement to provide Installation Information does not include a
409+requirement to continue to provide support service, warranty, or updates
410+for a work that has been modified or installed by the recipient, or for
411+the User Product in which it has been modified or installed. Access to a
412+network may be denied when the modification itself materially and
413+adversely affects the operation of the network or violates the rules and
414+protocols for communication across the network.
415+
416+ Corresponding Source conveyed, and Installation Information provided,
417+in accord with this section must be in a format that is publicly
418+documented (and with an implementation available to the public in
419+source code form), and must require no special password or key for
420+unpacking, reading or copying.
421+
422+ 7. Additional Terms.
423+
424+ "Additional permissions" are terms that supplement the terms of this
425+License by making exceptions from one or more of its conditions.
426+Additional permissions that are applicable to the entire Program shall
427+be treated as though they were included in this License, to the extent
428+that they are valid under applicable law. If additional permissions
429+apply only to part of the Program, that part may be used separately
430+under those permissions, but the entire Program remains governed by
431+this License without regard to the additional permissions.
432+
433+ When you convey a copy of a covered work, you may at your option
434+remove any additional permissions from that copy, or from any part of
435+it. (Additional permissions may be written to require their own
436+removal in certain cases when you modify the work.) You may place
437+additional permissions on material, added by you to a covered work,
438+for which you have or can give appropriate copyright permission.
439+
440+ Notwithstanding any other provision of this License, for material you
441+add to a covered work, you may (if authorized by the copyright holders of
442+that material) supplement the terms of this License with terms:
443+
444+ a) Disclaiming warranty or limiting liability differently from the
445+ terms of sections 15 and 16 of this License; or
446+
447+ b) Requiring preservation of specified reasonable legal notices or
448+ author attributions in that material or in the Appropriate Legal
449+ Notices displayed by works containing it; or
450+
451+ c) Prohibiting misrepresentation of the origin of that material, or
452+ requiring that modified versions of such material be marked in
453+ reasonable ways as different from the original version; or
454+
455+ d) Limiting the use for publicity purposes of names of licensors or
456+ authors of the material; or
457+
458+ e) Declining to grant rights under trademark law for use of some
459+ trade names, trademarks, or service marks; or
460+
461+ f) Requiring indemnification of licensors and authors of that
462+ material by anyone who conveys the material (or modified versions of
463+ it) with contractual assumptions of liability to the recipient, for
464+ any liability that these contractual assumptions directly impose on
465+ those licensors and authors.
466+
467+ All other non-permissive additional terms are considered "further
468+restrictions" within the meaning of section 10. If the Program as you
469+received it, or any part of it, contains a notice stating that it is
470+governed by this License along with a term that is a further
471+restriction, you may remove that term. If a license document contains
472+a further restriction but permits relicensing or conveying under this
473+License, you may add to a covered work material governed by the terms
474+of that license document, provided that the further restriction does
475+not survive such relicensing or conveying.
476+
477+ If you add terms to a covered work in accord with this section, you
478+must place, in the relevant source files, a statement of the
479+additional terms that apply to those files, or a notice indicating
480+where to find the applicable terms.
481+
482+ Additional terms, permissive or non-permissive, may be stated in the
483+form of a separately written license, or stated as exceptions;
484+the above requirements apply either way.
485+
486+ 8. Termination.
487+
488+ You may not propagate or modify a covered work except as expressly
489+provided under this License. Any attempt otherwise to propagate or
490+modify it is void, and will automatically terminate your rights under
491+this License (including any patent licenses granted under the third
492+paragraph of section 11).
493+
494+ However, if you cease all violation of this License, then your
495+license from a particular copyright holder is reinstated (a)
496+provisionally, unless and until the copyright holder explicitly and
497+finally terminates your license, and (b) permanently, if the copyright
498+holder fails to notify you of the violation by some reasonable means
499+prior to 60 days after the cessation.
500+
501+ Moreover, your license from a particular copyright holder is
502+reinstated permanently if the copyright holder notifies you of the
503+violation by some reasonable means, this is the first time you have
504+received notice of violation of this License (for any work) from that
505+copyright holder, and you cure the violation prior to 30 days after
506+your receipt of the notice.
507+
508+ Termination of your rights under this section does not terminate the
509+licenses of parties who have received copies or rights from you under
510+this License. If your rights have been terminated and not permanently
511+reinstated, you do not qualify to receive new licenses for the same
512+material under section 10.
513+
514+ 9. Acceptance Not Required for Having Copies.
515+
516+ You are not required to accept this License in order to receive or
517+run a copy of the Program. Ancillary propagation of a covered work
518+occurring solely as a consequence of using peer-to-peer transmission
519+to receive a copy likewise does not require acceptance. However,
520+nothing other than this License grants you permission to propagate or
521+modify any covered work. These actions infringe copyright if you do
522+not accept this License. Therefore, by modifying or propagating a
523+covered work, you indicate your acceptance of this License to do so.
524+
525+ 10. Automatic Licensing of Downstream Recipients.
526+
527+ Each time you convey a covered work, the recipient automatically
528+receives a license from the original licensors, to run, modify and
529+propagate that work, subject to this License. You are not responsible
530+for enforcing compliance by third parties with this License.
531+
532+ An "entity transaction" is a transaction transferring control of an
533+organization, or substantially all assets of one, or subdividing an
534+organization, or merging organizations. If propagation of a covered
535+work results from an entity transaction, each party to that
536+transaction who receives a copy of the work also receives whatever
537+licenses to the work the party's predecessor in interest had or could
538+give under the previous paragraph, plus a right to possession of the
539+Corresponding Source of the work from the predecessor in interest, if
540+the predecessor has it or can get it with reasonable efforts.
541+
542+ You may not impose any further restrictions on the exercise of the
543+rights granted or affirmed under this License. For example, you may
544+not impose a license fee, royalty, or other charge for exercise of
545+rights granted under this License, and you may not initiate litigation
546+(including a cross-claim or counterclaim in a lawsuit) alleging that
547+any patent claim is infringed by making, using, selling, offering for
548+sale, or importing the Program or any portion of it.
549+
550+ 11. Patents.
551+
552+ A "contributor" is a copyright holder who authorizes use under this
553+License of the Program or a work on which the Program is based. The
554+work thus licensed is called the contributor's "contributor version".
555+
556+ A contributor's "essential patent claims" are all patent claims
557+owned or controlled by the contributor, whether already acquired or
558+hereafter acquired, that would be infringed by some manner, permitted
559+by this License, of making, using, or selling its contributor version,
560+but do not include claims that would be infringed only as a
561+consequence of further modification of the contributor version. For
562+purposes of this definition, "control" includes the right to grant
563+patent sublicenses in a manner consistent with the requirements of
564+this License.
565+
566+ Each contributor grants you a non-exclusive, worldwide, royalty-free
567+patent license under the contributor's essential patent claims, to
568+make, use, sell, offer for sale, import and otherwise run, modify and
569+propagate the contents of its contributor version.
570+
571+ In the following three paragraphs, a "patent license" is any express
572+agreement or commitment, however denominated, not to enforce a patent
573+(such as an express permission to practice a patent or covenant not to
574+sue for patent infringement). To "grant" such a patent license to a
575+party means to make such an agreement or commitment not to enforce a
576+patent against the party.
577+
578+ If you convey a covered work, knowingly relying on a patent license,
579+and the Corresponding Source of the work is not available for anyone
580+to copy, free of charge and under the terms of this License, through a
581+publicly available network server or other readily accessible means,
582+then you must either (1) cause the Corresponding Source to be so
583+available, or (2) arrange to deprive yourself of the benefit of the
584+patent license for this particular work, or (3) arrange, in a manner
585+consistent with the requirements of this License, to extend the patent
586+license to downstream recipients. "Knowingly relying" means you have
587+actual knowledge that, but for the patent license, your conveying the
588+covered work in a country, or your recipient's use of the covered work
589+in a country, would infringe one or more identifiable patents in that
590+country that you have reason to believe are valid.
591+
592+ If, pursuant to or in connection with a single transaction or
593+arrangement, you convey, or propagate by procuring conveyance of, a
594+covered work, and grant a patent license to some of the parties
595+receiving the covered work authorizing them to use, propagate, modify
596+or convey a specific copy of the covered work, then the patent license
597+you grant is automatically extended to all recipients of the covered
598+work and works based on it.
599+
600+ A patent license is "discriminatory" if it does not include within
601+the scope of its coverage, prohibits the exercise of, or is
602+conditioned on the non-exercise of one or more of the rights that are
603+specifically granted under this License. You may not convey a covered
604+work if you are a party to an arrangement with a third party that is
605+in the business of distributing software, under which you make payment
606+to the third party based on the extent of your activity of conveying
607+the work, and under which the third party grants, to any of the
608+parties who would receive the covered work from you, a discriminatory
609+patent license (a) in connection with copies of the covered work
610+conveyed by you (or copies made from those copies), or (b) primarily
611+for and in connection with specific products or compilations that
612+contain the covered work, unless you entered into that arrangement,
613+or that patent license was granted, prior to 28 March 2007.
614+
615+ Nothing in this License shall be construed as excluding or limiting
616+any implied license or other defenses to infringement that may
617+otherwise be available to you under applicable patent law.
618+
619+ 12. No Surrender of Others' Freedom.
620+
621+ If conditions are imposed on you (whether by court order, agreement or
622+otherwise) that contradict the conditions of this License, they do not
623+excuse you from the conditions of this License. If you cannot convey a
624+covered work so as to satisfy simultaneously your obligations under this
625+License and any other pertinent obligations, then as a consequence you may
626+not convey it at all. For example, if you agree to terms that obligate you
627+to collect a royalty for further conveying from those to whom you convey
628+the Program, the only way you could satisfy both those terms and this
629+License would be to refrain entirely from conveying the Program.
630+
631+ 13. Use with the GNU Affero General Public License.
632+
633+ Notwithstanding any other provision of this License, you have
634+permission to link or combine any covered work with a work licensed
635+under version 3 of the GNU Affero General Public License into a single
636+combined work, and to convey the resulting work. The terms of this
637+License will continue to apply to the part which is the covered work,
638+but the special requirements of the GNU Affero General Public License,
639+section 13, concerning interaction through a network will apply to the
640+combination as such.
641+
642+ 14. Revised Versions of this License.
643+
644+ The Free Software Foundation may publish revised and/or new versions of
645+the GNU General Public License from time to time. Such new versions will
646+be similar in spirit to the present version, but may differ in detail to
647+address new problems or concerns.
648+
649+ Each version is given a distinguishing version number. If the
650+Program specifies that a certain numbered version of the GNU General
651+Public License "or any later version" applies to it, you have the
652+option of following the terms and conditions either of that numbered
653+version or of any later version published by the Free Software
654+Foundation. If the Program does not specify a version number of the
655+GNU General Public License, you may choose any version ever published
656+by the Free Software Foundation.
657+
658+ If the Program specifies that a proxy can decide which future
659+versions of the GNU General Public License can be used, that proxy's
660+public statement of acceptance of a version permanently authorizes you
661+to choose that version for the Program.
662+
663+ Later license versions may give you additional or different
664+permissions. However, no additional obligations are imposed on any
665+author or copyright holder as a result of your choosing to follow a
666+later version.
667+
668+ 15. Disclaimer of Warranty.
669+
670+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
671+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
672+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
673+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
674+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
675+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
676+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
677+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
678+
679+ 16. Limitation of Liability.
680+
681+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
682+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
683+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
684+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
685+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
686+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
687+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
688+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
689+SUCH DAMAGES.
690+
691+ 17. Interpretation of Sections 15 and 16.
692+
693+ If the disclaimer of warranty and limitation of liability provided
694+above cannot be given local legal effect according to their terms,
695+reviewing courts shall apply local law that most closely approximates
696+an absolute waiver of all civil liability in connection with the
697+Program, unless a warranty or assumption of liability accompanies a
698+copy of the Program in return for a fee.
699+
700+ END OF TERMS AND CONDITIONS
701+
702+ How to Apply These Terms to Your New Programs
703+
704+ If you develop a new program, and you want it to be of the greatest
705+possible use to the public, the best way to achieve this is to make it
706+free software which everyone can redistribute and change under these terms.
707+
708+ To do so, attach the following notices to the program. It is safest
709+to attach them to the start of each source file to most effectively
710+state the exclusion of warranty; and each file should have at least
711+the "copyright" line and a pointer to where the full notice is found.
712+
713+ <one line to give the program's name and a brief idea of what it does.>
714+ Copyright (C) <year> <name of author>
715+
716+ This program is free software: you can redistribute it and/or modify
717+ it under the terms of the GNU General Public License as published by
718+ the Free Software Foundation, either version 3 of the License, or
719+ (at your option) any later version.
720+
721+ This program is distributed in the hope that it will be useful,
722+ but WITHOUT ANY WARRANTY; without even the implied warranty of
723+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
724+ GNU General Public License for more details.
725+
726+ You should have received a copy of the GNU General Public License
727+ along with this program. If not, see <http://www.gnu.org/licenses/>.
728+
729+Also add information on how to contact you by electronic and paper mail.
730+
731+ If the program does terminal interaction, make it output a short
732+notice like this when it starts in an interactive mode:
733+
734+ <program> Copyright (C) <year> <name of author>
735+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
736+ This is free software, and you are welcome to redistribute it
737+ under certain conditions; type `show c' for details.
738+
739+The hypothetical commands `show w' and `show c' should show the appropriate
740+parts of the General Public License. Of course, your program's commands
741+might be different; for a GUI interface, you would use an "about box".
742+
743+ You should also get your employer (if you work as a programmer) or school,
744+if any, to sign a "copyright disclaimer" for the program, if necessary.
745+For more information on this, and how to apply and follow the GNU GPL, see
746+<http://www.gnu.org/licenses/>.
747+
748+ The GNU General Public License does not permit incorporating your program
749+into proprietary programs. If your program is a subroutine library, you
750+may consider it more useful to permit linking proprietary applications with
751+the library. If this is what you want to do, use the GNU Lesser General
752+Public License instead of this License. But first, please read
753+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
754
755=== renamed file 'COPYING' => 'COPYING.moved'
756=== added file 'README'
757--- README 1970-01-01 00:00:00 +0000
758+++ README 2012-03-28 20:34:20 +0000
759@@ -0,0 +1,5 @@
760+This is Checkbox which provides an extensible interface for system testing.
761+
762+See the following page for documentation:
763+
764+https://wiki.ubuntu.com/Testing/Automation/Checkbox
765
766=== added directory 'apport'
767=== added file 'apport/checkbox.py'
768--- apport/checkbox.py 1970-01-01 00:00:00 +0000
769+++ apport/checkbox.py 2012-03-28 20:34:20 +0000
770@@ -0,0 +1,24 @@
771+'''apport general hook for checkbox
772+
773+(c) 2009 Canonical Ltd.
774+Author: David Murphy <schwuk@ubuntu.com>
775+'''
776+import os
777+
778+
779+def add_info(report):
780+ HOME = os.environ.get('HOME', '/')
781+ CACHE_HOME = os.environ.get('XDG_CACHE_HOME',
782+ os.path.join(HOME, '.cache'))
783+ SYSTEM = os.path.join(CACHE_HOME, 'checkbox', 'system')
784+ SUBMISSION = os.path.join(CACHE_HOME, 'checkbox', 'submission')
785+
786+ try:
787+ report['CheckboxSystem'] = open(SYSTEM).read()
788+ except IOError:
789+ pass
790+
791+ try:
792+ report['CheckboxSubmission'] = open(SUBMISSION).read()
793+ except IOError:
794+ pass
795
796=== added file 'apport/source_checkbox.py'
797--- apport/source_checkbox.py 1970-01-01 00:00:00 +0000
798+++ apport/source_checkbox.py 2012-03-28 20:34:20 +0000
799@@ -0,0 +1,20 @@
800+'''apport package hook for checkbox
801+
802+(c) 2009 Canonical Ltd.
803+Author: David Murphy <schwuk@ubuntu.com>
804+'''
805+import os
806+
807+from apport.hookutils import attach_file_if_exists
808+
809+
810+def add_info(report):
811+ HOME = os.environ.get('HOME', '/')
812+ CACHE_HOME = os.environ.get('XDG_CACHE_HOME',
813+ os.path.join(HOME, '.cache'))
814+
815+ SUBMISSION = os.path.join(CACHE_HOME, 'checkbox', 'submission.xml')
816+ attach_file_if_exists(report, SUBMISSION)
817+
818+ CHECKBOX_LOG = os.path.join(CACHE_HOME, 'checkbox', 'checkbox.log')
819+ attach_file_if_exists(report, CHECKBOX_LOG)
820
821=== added file 'backend'
822--- backend 1970-01-01 00:00:00 +0000
823+++ backend 2012-03-28 20:34:20 +0000
824@@ -0,0 +1,51 @@
825+#!/usr/bin/python
826+
827+import os
828+import sys
829+
830+from optparse import OptionParser
831+from checkbox.lib.fifo import FifoReader, FifoWriter
832+
833+from checkbox.job import Job, FAIL
834+
835+
836+def main(args):
837+ usage = "Usage: %prog INPUT OUTPUT"
838+ parser = OptionParser(usage=usage)
839+ parser.add_option("-p", "--path",
840+ help="PATH variable to replace in the environment")
841+ (options, args) = parser.parse_args(args)
842+
843+ if len(args) < 2:
844+ parser.error("Missing INPUT and OUTPUT")
845+
846+ if options.path:
847+ os.environ["PATH"] = options.path
848+
849+ reader = FifoReader(args[0])
850+ writer = FifoWriter(args[1])
851+
852+ while True:
853+ try:
854+ message = reader.read_object()
855+ if message == "stop":
856+ break
857+ if message == "ping":
858+ writer.write_object("pong")
859+ continue
860+ if isinstance(message, dict) and "command" in message:
861+ job = Job(message["command"], message.get("environ"),
862+ message.get("timeout"))
863+ result = job.execute()
864+ else:
865+ result = (FAIL, "", 0,)
866+
867+ writer.write_object(result)
868+ except IOError, e:
869+ break
870+
871+ return 0
872+
873+
874+if __name__ == "__main__":
875+ sys.exit(main(sys.argv[1:]))
876
877=== added directory 'bin'
878=== renamed directory 'bin' => 'bin.moved'
879=== added file 'bin/checkbox-app-testing'
880--- bin/checkbox-app-testing 1970-01-01 00:00:00 +0000
881+++ bin/checkbox-app-testing 2012-03-28 20:34:20 +0000
882@@ -0,0 +1,35 @@
883+#!/bin/bash
884+
885+set -e
886+
887+export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
888+
889+#export CHECKBOX_APP_TESTING_LIB=${CHECKBOX_APP_TESTING_LIB:-.}
890+export CHECKBOX_APP_TESTING_LIB=${CHECKBOX_APP_TESTING_LIB:-/usr/lib/checkbox-app-testing}
891+
892+#export CHECKBOX_APP_TESTING_DATA=${CHECKBOX_APP_TESTING_DATA:-.}
893+export CHECKBOX_APP_TESTING_DATA=${CHECKBOX_APP_TESTING_DATA:-$HOME/.checkbox-app-testing}
894+
895+#export CHECKBOX_APP_TESTING_SHARE=${CHECKBOX_APP_TESTING_SHARE:-.}
896+export CHECKBOX_APP_TESTING_SHARE=${CHECKBOX_APP_TESTING_SHARE:-/usr/share/checkbox-app-testing}
897+
898+export CHECKBOX_SHARE=${CHECKBOX_SHARE:-$CHECKBOX_APP_TESTING_SHARE}
899+export CHECKBOX_LIB=${CHECKBOX_LIB:-$CHECKBOX_APP_TESTING_LIB}
900+export CHECKBOX_DATA=${CHECKBOX_DATA:-$CHECKBOX_APP_TESTING_DATA}
901+export CHECKBOX_FRONTEND=${CHECKBOX_FRONTEND:-$CHECKBOX_APP_TESTING_LIB/qt/frontend}
902+
903+export PYTHONPATH=$PYTHONPATH:$CHECKBOX_APP_TESTING_LIB
904+
905+#debug
906+export CHECKBOX_OPTIONS=${CHECKBOX_OPTIONS:---log-level=debug --log=$CHECKBOX_DATA/checkbox-app-testing.log}
907+
908+#staging lp
909+#export APPORT_LAUNCHPAD_INSTANCE=staging
910+
911+
912+if [ -e $CHECKBOX_FRONTEND ]
913+then
914+ (cd $CHECKBOX_FRONTEND; qmake; make; ./checkbox-qt-service &)
915+fi
916+
917+python $CHECKBOX_APP_TESTING_LIB/run "$@" $CHECKBOX_APP_TESTING_SHARE/configs/$(basename $0).ini
918
919=== added directory 'checkbox'
920=== added file 'checkbox/__init__.py'
921=== added file 'checkbox/application.py'
922--- checkbox/application.py 1970-01-01 00:00:00 +0000
923+++ checkbox/application.py 2012-03-28 20:34:20 +0000
924@@ -0,0 +1,136 @@
925+#
926+# This file is part of Checkbox.
927+#
928+# Copyright 2008 Canonical Ltd.
929+#
930+# Checkbox is free software: you can redistribute it and/or modify
931+# it under the terms of the GNU General Public License as published by
932+# the Free Software Foundation, either version 3 of the License, or
933+# (at your option) any later version.
934+#
935+# Checkbox is distributed in the hope that it will be useful,
936+# but WITHOUT ANY WARRANTY; without even the implied warranty of
937+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
938+# GNU General Public License for more details.
939+#
940+# You should have received a copy of the GNU General Public License
941+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
942+#
943+import os
944+import sys
945+import logging
946+import posixpath
947+
948+from gettext import gettext as _
949+
950+from optparse import OptionParser
951+
952+from checkbox.lib.config import Config
953+from checkbox.lib.environ import get_variable
954+from checkbox.lib.log import set_logging
955+from checkbox.lib.safe import safe_make_directory
956+from checkbox.lib.text import split
957+
958+from checkbox.plugin import PluginManager
959+from checkbox.reactor import Reactor
960+
961+
962+class Application(object):
963+
964+ reactor_factory = Reactor
965+
966+ def __init__(self, config):
967+ self._config = config
968+ self.reactor = self.reactor_factory()
969+
970+ # Plugin manager setup
971+ self.plugin_manager = PluginManager(self._config,
972+ self.reactor)
973+
974+ def run(self):
975+ try:
976+ self.reactor.run()
977+ except:
978+ logging.exception("Error running reactor.")
979+ raise
980+
981+
982+class ApplicationManager(object):
983+
984+ application_factory = Application
985+
986+ default_log = os.path.join(get_variable("CHECKBOX_DATA", "."), "checkbox.log")
987+ default_log_level = "info"
988+
989+ def parse_options(self, args):
990+ usage = _("Usage: checkbox [OPTIONS]")
991+ parser = OptionParser(usage=usage)
992+ parser.add_option("--version",
993+ action="store_true",
994+ help=_("Print version information and exit."))
995+ parser.add_option("-l", "--log",
996+ metavar="FILE",
997+ default=self.default_log,
998+ help=_("The file to write the log to."))
999+ parser.add_option("--log-level",
1000+ default=self.default_log_level,
1001+ help=_("One of debug, info, warning, error or critical."))
1002+ parser.add_option("-c", "--config",
1003+ action="append",
1004+ type="string",
1005+ default=[],
1006+ help=_("Configuration override parameters."))
1007+ parser.add_option("-b", "--blacklist",
1008+ help=_("Shorthand for --config=.*/jobs_info/blacklist."))
1009+ parser.add_option("-B", "--blacklist-file",
1010+ help=_("Shorthand for --config=.*/jobs_info/blacklist_file."))
1011+ parser.add_option("-w", "--whitelist",
1012+ help=_("Shorthand for --config=.*/jobs_info/whitelist."))
1013+ parser.add_option("-W", "--whitelist-file",
1014+ help=_("Shorthand for --config=.*/jobs_info/whitelist_file."))
1015+ return parser.parse_args(args)
1016+
1017+ def create_application(self, args=sys.argv):
1018+ # Create data directory
1019+ data_directory = get_variable("CHECKBOX_DATA", ".")
1020+ safe_make_directory(data_directory)
1021+
1022+ # Prepend environment options
1023+ string_options = get_variable("CHECKBOX_OPTIONS", "")
1024+ args[:0] = split(string_options)
1025+ (options, args) = self.parse_options(args)
1026+
1027+ # Replace shorthands
1028+ for shorthand in "blacklist", "blacklist_file", "whitelist", "whitelist_file":
1029+ key = ".*/jobs_info/%s" % shorthand
1030+ value = getattr(options, shorthand)
1031+ if value:
1032+ options.config.append("=".join([key, value]))
1033+
1034+ # Set logging early
1035+ set_logging(options.log_level, options.log)
1036+
1037+ # Config setup
1038+ if len(args) != 2:
1039+ sys.stderr.write(_("Missing configuration file as argument.\n"))
1040+ sys.exit(1)
1041+
1042+ config = Config()
1043+ config_filename = posixpath.expanduser(args[1])
1044+ config.read_filename(config_filename)
1045+ config.read_configs(options.config)
1046+
1047+ section_name = "checkbox/plugins/client_info"
1048+ section = config.get_section(section_name)
1049+ if not section:
1050+ section = config.add_section(section_name)
1051+ section.set("name", posixpath.basename(args[1]) \
1052+ .replace(".ini", ""))
1053+ section.set("version", config.get_defaults().version)
1054+
1055+ # Check options
1056+ if options.version:
1057+ print config.get_defaults().version
1058+ sys.exit(0)
1059+
1060+ return self.application_factory(config)
1061
1062=== added file 'checkbox/arguments.py'
1063--- checkbox/arguments.py 1970-01-01 00:00:00 +0000
1064+++ checkbox/arguments.py 2012-03-28 20:34:20 +0000
1065@@ -0,0 +1,95 @@
1066+#
1067+# This file is part of Checkbox.
1068+#
1069+# Copyright 2008 Canonical Ltd.
1070+#
1071+# Checkbox is free software: you can redistribute it and/or modify
1072+# it under the terms of the GNU General Public License as published by
1073+# the Free Software Foundation, either version 3 of the License, or
1074+# (at your option) any later version.
1075+#
1076+# Checkbox is distributed in the hope that it will be useful,
1077+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1078+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1079+# GNU General Public License for more details.
1080+#
1081+# You should have received a copy of the GNU General Public License
1082+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1083+#
1084+from inspect import getargspec
1085+
1086+from checkbox.lib.decorator import merge_function_metadata
1087+
1088+
1089+class ArgumentReplacer(object):
1090+ """A decorator helper that filters arguments to be passed to a function.
1091+
1092+ Create one with the original function and a function to replace
1093+ the arguments, and then call replace_arguments for each call to
1094+ the function.
1095+ """
1096+ def __init__(self, original_function, argument_replacer):
1097+ """
1098+ @param original_function: The function which will be called
1099+ soon. The function must *not* define any * or ** parameters.
1100+ @param argument_replacer: A function which will be called for
1101+ every argument. It will be passed a parameter name and the
1102+ associated argument. It should return the new value.
1103+ """
1104+ self.original_function = original_function
1105+ self.argument_replacer = argument_replacer
1106+
1107+ spec = getargspec(original_function)
1108+ self.all_arguments = spec[0]
1109+ if getattr(original_function, 'im_self', None) is not None:
1110+ # If it's bound, ignore the bound arguments.
1111+ self.all_arguments = self.all_arguments[1:]
1112+
1113+ def replace_arguments(self, args, kwargs):
1114+ """Filter some arguments destined to be passed to a function.
1115+
1116+ @param args: Original positional arguments.
1117+ @param kwargs: Original keyword arguments.
1118+
1119+ @return: new arguments and kwarguments.
1120+ """
1121+ args = list(args)
1122+ kwargs = kwargs.copy()
1123+
1124+ for name_index, name in enumerate(self.all_arguments):
1125+ # Ok, we've got the name of the argument. Let's find the value
1126+ # of the argument in our original arguments and replace it
1127+ # whether it's a positional or a keyword argument.
1128+ if name_index < len(args):
1129+ # Must be a positional argument
1130+ value = args[name_index]
1131+ args[name_index] = self.argument_replacer(name, value)
1132+ else:
1133+ # Must be a keyword argument
1134+ if name not in kwargs:
1135+ # Oh, but it wasn't passed in. Ignore it.
1136+ continue
1137+ value = kwargs[name]
1138+ kwargs[name] = self.argument_replacer(name, value)
1139+ return args, kwargs
1140+
1141+
1142+def coerce_arguments(**schemas):
1143+ """
1144+ A decorator factory which returns a decorator which coerces arguments.
1145+ """
1146+ def replacer(name, value):
1147+ if name in schemas:
1148+ return schemas[name].coerce(value)
1149+ return value
1150+
1151+ def decorator(original):
1152+ argument_replacer = ArgumentReplacer(original, replacer)
1153+ def replacement(*args, **kwargs):
1154+ new_args, new_kwargs = argument_replacer.replace_arguments(args,
1155+ kwargs)
1156+ return original(*new_args, **new_kwargs)
1157+ merge_function_metadata(original, replacement)
1158+ return replacement
1159+
1160+ return decorator
1161
1162=== added file 'checkbox/attribute.py'
1163--- checkbox/attribute.py 1970-01-01 00:00:00 +0000
1164+++ checkbox/attribute.py 2012-03-28 20:34:20 +0000
1165@@ -0,0 +1,41 @@
1166+#
1167+# This file is part of Checkbox.
1168+#
1169+# Copyright 2008 Canonical Ltd.
1170+#
1171+# Checkbox is free software: you can redistribute it and/or modify
1172+# it under the terms of the GNU General Public License as published by
1173+# the Free Software Foundation, either version 3 of the License, or
1174+# (at your option) any later version.
1175+#
1176+# Checkbox is distributed in the hope that it will be useful,
1177+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1178+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1179+# GNU General Public License for more details.
1180+#
1181+# You should have received a copy of the GNU General Public License
1182+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1183+#
1184+from checkbox.variables import Variable
1185+
1186+
1187+class Attribute(object):
1188+
1189+ def __init__(self, name, cls, variable_factory=None):
1190+ self.name = name
1191+ self.cls = cls
1192+ self.variable_factory = variable_factory or Variable
1193+
1194+
1195+def get_attributes(cls):
1196+ if "__checkbox_attributes__" in cls.__dict__:
1197+ return cls.__dict__["__checkbox_attributes__"]
1198+ else:
1199+ attributes = {}
1200+ for name in dir(cls):
1201+ attribute = getattr(cls, name, None)
1202+ if isinstance(attribute, Attribute):
1203+ attributes[name] = attribute
1204+
1205+ cls.__checkbox_attributes__ = attributes
1206+ return cls.__checkbox_attributes__
1207
1208=== added file 'checkbox/component.py'
1209--- checkbox/component.py 1970-01-01 00:00:00 +0000
1210+++ checkbox/component.py 2012-03-28 20:34:20 +0000
1211@@ -0,0 +1,184 @@
1212+#
1213+# This file is part of Checkbox.
1214+#
1215+# Copyright 2008 Canonical Ltd.
1216+#
1217+# Checkbox is free software: you can redistribute it and/or modify
1218+# it under the terms of the GNU General Public License as published by
1219+# the Free Software Foundation, either version 3 of the License, or
1220+# (at your option) any later version.
1221+#
1222+# Checkbox is distributed in the hope that it will be useful,
1223+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1224+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1225+# GNU General Public License for more details.
1226+#
1227+# You should have received a copy of the GNU General Public License
1228+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
1229+#
1230+import os
1231+import re
1232+import itertools
1233+import logging
1234+import posixpath
1235+
1236+from checkbox.lib.cache import cache
1237+from checkbox.lib.path import path_expand_recursive
1238+
1239+from checkbox.properties import List, String
1240+from checkbox.variables import get_variables
1241+
1242+
1243+class ComponentSection(object):
1244+ """
1245+ Component section which is essentially a container of modules. These
1246+ map to the modules referenced in the configuration passed as argument
1247+ to the constructor.
1248+ """
1249+
1250+ modules = List(type=String())
1251+ whitelist = List(type=String(), default_factory=lambda:"")
1252+ blacklist = List(type=String(), default_factory=lambda:"")
1253+
1254+ def __init__(self, config, name):
1255+ """
1256+ Constructor which takes a configuration instance and name as
1257+ argument. The former is expected to contain modules.
1258+ """
1259+ self._config = config
1260+ self.name = name
1261+
1262+ self.modules = config.modules
1263+ self.whitelist = config.get("whitelist")
1264+ self.blacklist = config.get("blacklist")
1265+
1266+ @cache
1267+ def get_names(self):
1268+ """
1269+ Get all the module names contained in the filenames or directories
1270+ for this section.
1271+ """
1272+ whitelist_patterns = [re.compile(r"^%s$" % r) for r in self.whitelist]
1273+ blacklist_patterns = [re.compile(r"^%s$" % r) for r in self.blacklist]
1274+
1275+ # Determine names
1276+ names = set()
1277+ filenames = itertools.chain(*[path_expand_recursive(m)
1278+ for m in self.modules])
1279+ for filename in filenames:
1280+ name = posixpath.basename(filename)
1281+ if not name.endswith(".py") or name == "__init__.py":
1282+ # Ignore silently
1283+ continue
1284+
1285+ name = name.replace(".py", "")
1286+ if whitelist_patterns:
1287+ if not [name for p in whitelist_patterns if p.match(name)]:
1288+ logging.info("Not whitelisted module: %s", name)
1289+ continue
1290+ elif blacklist_patterns:
1291+ if [name for p in blacklist_patterns if p.match(name)]:
1292+ logging.info("Blacklisted module: %s", name)
1293+ continue
1294+
1295+ names.add(name)
1296+
1297+ return list(names)
1298+
1299+ def has_module(self, name):
1300+ """
1301+ Check if the given name is in this section.
1302+ """
1303+ return name in self.get_names()
1304+
1305+ def load_module(self, name):
1306+ """
1307+ Load a single module by name from this section.
1308+ """
1309+ logging.info("Loading module %s from section %s",
1310+ name, self.name)
1311+
1312+ if not self.has_module(name):
1313+ raise Exception, "No such such module: %s" % name
1314+
1315+ filenames = itertools.chain(*[path_expand_recursive(m)
1316+ for m in self.modules])
1317+ for filename in filenames:
1318+ if filename.endswith(".py") and posixpath.exists(filename):
1319+ basename = posixpath.basename(filename)
1320+ basename = basename.replace(".py", "")
1321+ if basename == name:
1322+ globals = {}
1323+ exec open(filename) in globals
1324+ if "factory" not in globals:
1325+ raise Exception, "Variable 'factory' not found in: %s" \
1326+ % filename
1327+
1328+ module = globals["factory"]()
1329+ module.__module__ = name
1330+
1331+ config_name = "/".join([self.name, name])
1332+ config = self._config.parent.get_section(config_name)
1333+
1334+ # Set configuration values
1335+ variables = get_variables(module)
1336+ environ = dict([(k.lower(), v) for k, v in os.environ.iteritems()])
1337+ for attribute, variable in variables.iteritems():
1338+ if config and attribute.name in config:
1339+ value = config.get(attribute.name)
1340+ variable.set(value)
1341+ else:
1342+ value = variable.get()
1343+ if isinstance(value, basestring):
1344+ value = value % environ
1345+ variable.set(value)
1346+ elif isinstance(value, list):
1347+ value = [v % environ for v in value]
1348+ variable.set(value)
1349+
1350+ # Check required attributes
1351+ for attribute, variable in variables.iteritems():
1352+ value = variable.get()
1353+ if value is None and variable._required:
1354+ raise Exception, "Configuration '%s' missing " \
1355+ "required attribute: %s" \
1356+ % (config_name, attribute.name)
1357+
1358+ return module
1359+
1360+ raise Exception, "Failed to find module '%s' in: %s" % (name, filenames)
1361+
1362+ def load_modules(self):
1363+ """
1364+ Load all modules contained in this section.
1365+ """
1366+ modules = []
1367+ for name in self.get_names():
1368+ module = self.load_module(name)
1369+ modules.append(module)
1370+
1371+ return modules
1372+
1373+
1374+class ComponentManager(object):
1375+ """
1376+ Component manager which is essentially a container of sections.
1377+ """
1378+
1379+ _section_factory = ComponentSection
1380+
1381+ def __init__(self, config):
1382+ """
1383+ Constructor which takes a configuration instance as argument. This
1384+ will be used to load sections by name.
1385+ """
1386+ self._config = config
1387+
1388+ def load_section(self, name):
1389+ """
1390+ Load a section by name which must correspond to a module in the
1391+ configuration instance pased as argument to the constructor.
1392+ """
1393+ logging.info("Loading component section %s", name)
1394+ config = self._config.get_section(name)
1395+ return self._section_factory(config, name)
1396
1397=== added directory 'checkbox/contrib'
1398=== added file 'checkbox/contrib/REThread.py'
1399--- checkbox/contrib/REThread.py 1970-01-01 00:00:00 +0000
1400+++ checkbox/contrib/REThread.py 2012-03-28 20:34:20 +0000
1401@@ -0,0 +1,139 @@
1402+'''Enhanced threading.Thread which can deliver a return value and propagate
1403+exceptions from the called thread to the calling thread.
1404+
1405+Copyright (C) 2007 Canonical Ltd.
1406+Author: Martin Pitt <martin.pitt@ubuntu.com>
1407+
1408+This program is free software; you can redistribute it and/or modify it
1409+under the terms of the GNU General Public License as published by the
1410+Free Software Foundation; either version 2 of the License, or (at your
1411+option) any later version. See http://www.gnu.org/copyleft/gpl.html for
1412+the full text of the license.
1413+'''
1414+
1415+import threading, sys
1416+
1417+class REThread(threading.Thread):
1418+ '''Enhanced threading.Thread which can deliver a return value and propagate
1419+ exceptions from the called thread to the calling thread.'''
1420+
1421+ def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
1422+ verbose=None):
1423+ '''Initialize Thread, identical to threading.Thread.__init__().'''
1424+
1425+ threading.Thread.__init__(self, group, target, name, args, kwargs,
1426+ verbose)
1427+ self.__target = target
1428+ self.__args = args
1429+ self.__kwargs = kwargs
1430+ self._retval = None
1431+ self._exception = None
1432+
1433+ def run(self):
1434+ '''Run target function, identical to threading.Thread.run().'''
1435+
1436+ if self.__target:
1437+ try:
1438+ self._retval = self.__target(*self.__args, **self.__kwargs)
1439+ except:
1440+ self._exception = sys.exc_info()
1441+
1442+ def return_value(self):
1443+ '''Return value from target function.
1444+
1445+ This can only be called after the thread has finished, i. e. when
1446+ isAlive() is False and did not terminate with an exception.'''
1447+
1448+ assert not self.isAlive()
1449+ assert not self._exception
1450+ return self._retval
1451+
1452+ def exc_info(self):
1453+ '''Return a tuple (type, value, traceback) of the exception caught in
1454+ run().'''
1455+
1456+ return self._exception
1457+
1458+ def exc_raise(self):
1459+ '''Raises the exception caught in the thread.
1460+
1461+ Does nothing if no exception was caught.'''
1462+
1463+ if self._exception:
1464+ raise self._exception[0], self._exception[1], self._exception[2]
1465+
1466+#
1467+# Unit test
1468+#
1469+
1470+if __name__ == '__main__':
1471+ import unittest, time, traceback, exceptions
1472+
1473+ def idle(seconds):
1474+ '''Test thread to just wait a bit.'''
1475+
1476+ time.sleep(seconds)
1477+
1478+ def div(x, y):
1479+ '''Test thread to divide two numbers.'''
1480+
1481+ return x / y
1482+
1483+ class _REThreadTest(unittest.TestCase):
1484+ def test_return_value(self):
1485+ '''Test that return value works properly.'''
1486+
1487+ t = REThread(target=div, args=(42, 2))
1488+ t.start()
1489+ t.join()
1490+ # exc_raise() should be a no-op on successful functions
1491+ t.exc_raise()
1492+ self.assertEqual(t.return_value(), 21)
1493+ self.assertEqual(t.exc_info(), None)
1494+
1495+ def test_no_return_value(self):
1496+ '''Test that REThread works if run() does not return anything.'''
1497+
1498+ t = REThread(target=idle, args=(0.5,))
1499+ t.start()
1500+ # thread must be joined first
1501+ self.assertRaises(AssertionError, t.return_value)
1502+ t.join()
1503+ self.assertEqual(t.return_value(), None)
1504+ self.assertEqual(t.exc_info(), None)
1505+
1506+ def test_exception(self):
1507+ '''Test that exception in thread is caught and passed.'''
1508+
1509+ t = REThread(target=div, args=(1, 0))
1510+ t.start()
1511+ t.join()
1512+ # thread did not terminate normally, no return value
1513+ self.assertRaises(AssertionError, t.return_value)
1514+ self.assert_(t.exc_info()[0] == exceptions.ZeroDivisionError)
1515+ exc = traceback.format_exception(t.exc_info()[0], t.exc_info()[1],
1516+ t.exc_info()[2])
1517+ self.assert_(exc[-1].startswith('ZeroDivisionError'))
1518+ self.assert_(exc[-2].endswith('return x / y\n'))
1519+
1520+ def test_exc_raise(self):
1521+ '''Test that exc_raise() raises caught thread exception.'''
1522+
1523+ t = REThread(target=div, args=(1, 0))
1524+ t.start()
1525+ t.join()
1526+ # thread did not terminate normally, no return value
1527+ self.assertRaises(AssertionError, t.return_value)
1528+ raised = False
1529+ try:
1530+ t.exc_raise()
1531+ except:
1532+ raised = True
1533+ e = sys.exc_info()
1534+ exc = traceback.format_exception(e[0], e[1], e[2])
1535+ self.assert_(exc[-1].startswith('ZeroDivisionError'))
1536+ self.assert_(exc[-2].endswith('return x / y\n'))
1537+ self.assert_(raised)
1538+
1539+ unittest.main()
1540+
1541
1542=== added file 'checkbox/contrib/__init__.py'
1543=== added file 'checkbox/contrib/bpickle.py'
1544--- checkbox/contrib/bpickle.py 1970-01-01 00:00:00 +0000
1545+++ checkbox/contrib/bpickle.py 2012-03-28 20:34:20 +0000
1546@@ -0,0 +1,167 @@
1547+"""
1548+Copyright (c) 2006, Gustavo Niemeyer <gustavo@niemeyer.net>
1549+
1550+All rights reserved.
1551+
1552+Redistribution and use in source and binary forms, with or without
1553+modification, are permitted provided that the following conditions are met:
1554+
1555+ * Redistributions of source code must retain the above copyright notice,
1556+ this list of conditions and the following disclaimer.
1557+ * Redistributions in binary form must reproduce the above copyright notice,
1558+ this list of conditions and the following disclaimer in the documentation
1559+ and/or other materials provided with the distribution.
1560+ * Neither the name of the copyright holder nor the names of its
1561+ contributors may be used to endorse or promote products derived from
1562+ this software without specific prior written permission.
1563+
1564+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1565+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1566+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1567+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1568+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1569+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1570+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1571+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1572+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1573+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1574+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1575+"""
1576+
1577+
1578+dumps_table = {}
1579+loads_table = {}
1580+
1581+
1582+def dumps(obj, _dt=None):
1583+ if not _dt:
1584+ _dt = dumps_table
1585+
1586+ type_names = [type(obj)]
1587+ for type_name in type_names:
1588+ if _dt.has_key(type_name):
1589+ return _dt[type_name](obj)
1590+
1591+ type_names.extend(type_name.__bases__)
1592+
1593+ raise ValueError, "Unsupported type: %s" % type(obj)
1594+
1595+
1596+def loads(str, _lt=loads_table):
1597+ if not str:
1598+ raise ValueError, "Can't load empty string"
1599+ try:
1600+ return _lt[str[0]](str, 0)[0]
1601+ except KeyError, e:
1602+ raise ValueError, "Unknown type character: %s" % e
1603+ except IndexError:
1604+ raise ValueError, "Corrupted data"
1605+
1606+def dumps_bool(obj):
1607+ return "b%d" % int(obj)
1608+
1609+def dumps_int(obj):
1610+ return "i%s;" % obj
1611+
1612+def dumps_float(obj):
1613+ return "f%r;" % obj
1614+
1615+def dumps_str(obj):
1616+ return "s%s:%s" % (len(obj), obj)
1617+
1618+def dumps_unicode(obj):
1619+ obj = obj.encode("utf-8")
1620+ return "u%s:%s" % (len(obj), obj)
1621+
1622+def dumps_list(obj, _dt=None):
1623+ return "l%s;" % "".join([dumps(val, _dt) for val in obj])
1624+
1625+def dumps_tuple(obj, _dt=None):
1626+ return "t%s;" % "".join([dumps(val, _dt) for val in obj])
1627+
1628+def dumps_dict(obj, _dt=None):
1629+ res = []
1630+ keys = sorted(obj.iterkeys())
1631+ append = res.append
1632+ for key in keys:
1633+ val = obj[key]
1634+ append(dumps(key, _dt))
1635+ append(dumps(val, _dt))
1636+ return "d%s;" % "".join(res)
1637+
1638+def dumps_none(obj):
1639+ return "n"
1640+
1641+def loads_bool(str, pos):
1642+ return bool(int(str[pos+1])), pos+2
1643+
1644+def loads_int(str, pos):
1645+ endpos = str.index(";", pos)
1646+ return int(str[pos+1:endpos]), endpos+1
1647+
1648+def loads_float(str, pos):
1649+ endpos = str.index(";", pos)
1650+ return float(str[pos+1:endpos]), endpos+1
1651+
1652+def loads_str(str, pos):
1653+ startpos = str.index(":", pos)+1
1654+ endpos = startpos+int(str[pos+1:startpos-1])
1655+ return str[startpos:endpos], endpos
1656+
1657+def loads_unicode(str, pos):
1658+ startpos = str.index(":", pos)+1
1659+ endpos = startpos+int(str[pos+1:startpos-1])
1660+ return str[startpos:endpos].decode("utf-8"), endpos
1661+
1662+def loads_list(str, pos, _lt=loads_table):
1663+ pos += 1
1664+ res = []
1665+ append = res.append
1666+ while str[pos] != ";":
1667+ obj, pos = _lt[str[pos]](str, pos)
1668+ append(obj)
1669+ return res, pos+1
1670+
1671+def loads_tuple(str, pos, _lt=loads_table):
1672+ pos += 1
1673+ res = []
1674+ append = res.append
1675+ while str[pos] != ";":
1676+ obj, pos = _lt[str[pos]](str, pos)
1677+ append(obj)
1678+ return tuple(res), pos+1
1679+
1680+def loads_dict(str, pos, _lt=loads_table):
1681+ pos += 1
1682+ res = {}
1683+ while str[pos] != ";":
1684+ key, pos = _lt[str[pos]](str, pos)
1685+ val, pos = _lt[str[pos]](str, pos)
1686+ res[key] = val
1687+ return res, pos+1
1688+
1689+def loads_none(str, pos):
1690+ return None, pos+1
1691+
1692+
1693+dumps_table.update({ bool: dumps_bool,
1694+ int: dumps_int,
1695+ long: dumps_int,
1696+ float: dumps_float,
1697+ str: dumps_str,
1698+ unicode: dumps_unicode,
1699+ list: dumps_list,
1700+ tuple: dumps_tuple,
1701+ dict: dumps_dict,
1702+ type(None): dumps_none })
1703+
1704+loads_table.update({ "b": loads_bool,
1705+ "i": loads_int,
1706+ "f": loads_float,
1707+ "s": loads_str,
1708+ "u": loads_unicode,
1709+ "l": loads_list,
1710+ "t": loads_tuple,
1711+ "d": loads_dict,
1712+ "n": loads_none })
1713+
1714
1715=== added file 'checkbox/contrib/glock.py'
1716--- checkbox/contrib/glock.py 1970-01-01 00:00:00 +0000
1717+++ checkbox/contrib/glock.py 2012-03-28 20:34:20 +0000
1718@@ -0,0 +1,316 @@
1719+#!/usr/bin/env python
1720+# -*- coding: latin1 -*-
1721+#----------------------------------------------------------------------------
1722+# glock.py: Global mutex
1723+#
1724+# See __doc__ string below.
1725+#
1726+# Requires:
1727+# - Python 1.5.2 or newer (www.python.org)
1728+# - On windows: win32 extensions installed
1729+# (http://www.python.org/windows/win32all/win32all.exe)
1730+# - OS: Unix, Windows.
1731+#
1732+# $Id: //depot/rgutils/rgutils/glock.py#5 $
1733+#----------------------------------------------------------------------------
1734+'''
1735+This module defines the class GlobalLock that implements a global
1736+(inter-process) mutex on Windows and Unix, using file-locking on
1737+Unix.
1738+
1739+@see: class L{GlobalLock} for more details.
1740+'''
1741+__version__ = '0.2.' + '$Revision: #5 $'[12:-2]
1742+__author__ = 'Richard Gruet', 'rjgruet@yahoo.com'
1743+__date__ = '$Date: 2005/06/19 $'[7:-2], '$Author: rgruet $'[9:-2]
1744+__since__ = '2000-01-22'
1745+__doc__ += '\n@author: %s (U{%s})\n@version: %s' % (__author__[0],
1746+ __author__[1], __version__)
1747+__all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner']
1748+
1749+# Imports:
1750+import sys, string, os, errno, re, posixpath
1751+
1752+# System-dependent imports for locking implementation:
1753+_windows = (sys.platform == 'win32')
1754+
1755+if _windows:
1756+ try:
1757+ import win32event, win32api, pywintypes
1758+ except ImportError:
1759+ sys.stderr.write('The win32 extensions need to be installed!')
1760+ try:
1761+ import ctypes
1762+ except ImportError:
1763+ ctypes = None
1764+else: # assume Unix
1765+ try:
1766+ import fcntl
1767+ except ImportError:
1768+ sys.stderr.write("On what kind of OS am I ? (Mac?) I should be on "
1769+ "Unix but can't import fcntl.\n")
1770+ raise
1771+ import threading
1772+
1773+# Exceptions :
1774+# ----------
1775+class GlobalLockError(Exception):
1776+ ''' Error raised by the glock module.
1777+ '''
1778+ pass
1779+
1780+class NotOwner(GlobalLockError):
1781+ ''' Attempt to release somebody else's lock.
1782+ '''
1783+ pass
1784+
1785+class LockAlreadyAcquired(GlobalLockError):
1786+ ''' Non-blocking acquire but lock already seized.
1787+ '''
1788+ pass
1789+
1790+
1791+# Constants
1792+# ---------:
1793+if sys.version[:3] < '2.2':
1794+ True, False = 1, 0 # built-in in Python 2.2+
1795+
1796+#----------------------------------------------------------------------------
1797+class GlobalLock:
1798+#----------------------------------------------------------------------------
1799+ ''' A global mutex.
1800+
1801+ B{Specification}
1802+
1803+ - The lock must act as a global mutex, ie block between different
1804+ candidate processus, but ALSO between different candidate
1805+ threads of the same process.
1806+
1807+ - It must NOT block in case of reentrant lock request issued by
1808+ the SAME thread.
1809+ - Extraneous unlocks should be ideally harmless.
1810+
1811+ B{Implementation}
1812+
1813+ In Python there is no portable global lock AFAIK. There is only a
1814+ LOCAL/ in-process Lock mechanism (threading.RLock), so we have to
1815+ implement our own solution:
1816+
1817+ - Unix: use fcntl.flock(). Recursive calls OK. Different process OK.
1818+ But <> threads, same process don't block so we have to use an extra
1819+ threading.RLock to fix that point.
1820+ - Windows: We use WIN32 mutex from Python Win32 extensions. Can't use
1821+ std module msvcrt.locking(), because global lock is OK, but
1822+ blocks also for 2 calls from the same thread!
1823+ '''
1824+ RE_ERROR_MSG = re.compile ("^\[Errno ([0-9]+)\]")
1825+
1826+ def __init__(self, fpath, lockInitially=False, logger=None):
1827+ ''' Creates (or opens) a global lock.
1828+
1829+ @param fpath: Path of the file used as lock target. This is also
1830+ the global id of the lock. The file will be created
1831+ if non existent.
1832+ @param lockInitially: if True locks initially.
1833+ @param logger: an optional logger object.
1834+ '''
1835+ self.logger = logger
1836+ self.fpath = fpath
1837+ if posixpath.exists(fpath):
1838+ self.previous_lockfile_present = True
1839+ else:
1840+ self.previous_lockfile_present = False
1841+ if _windows:
1842+ self.name = string.replace(fpath, '\\', '_')
1843+ self.mutex = win32event.CreateMutex(None, lockInitially, self.name)
1844+ else: # Unix
1845+ self.name = fpath
1846+ self.flock = open(fpath, 'w')
1847+ self.fdlock = self.flock.fileno()
1848+ self.threadLock = threading.RLock()
1849+ if lockInitially:
1850+ self.acquire()
1851+
1852+ def __del__(self):
1853+ #print '__del__ called' ##
1854+ try: self.release()
1855+ except: pass
1856+ if _windows:
1857+ win32api.CloseHandle(self.mutex)
1858+ else:
1859+ try: self.flock.close()
1860+ except: pass
1861+
1862+ def __repr__(self):
1863+ return '<Global lock @ %s>' % self.name
1864+
1865+ def acquire(self, blocking=False):
1866+ """ Locks. Attemps to acquire a lock.
1867+
1868+ @param blocking: If True, suspends caller until done. Otherwise,
1869+ LockAlreadyAcquired is raised if the lock cannot be acquired immediately.
1870+
1871+ On windows an IOError is always raised after ~10 sec if the lock
1872+ can't be acquired.
1873+ @exception GlobalLockError: if lock can't be acquired (timeout)
1874+ @exception LockAlreadyAcquired: someone already has the lock and
1875+ the caller decided not to block.
1876+ """
1877+ if self.logger:
1878+ self.logger.info('creating lockfile')
1879+ if _windows:
1880+ if blocking:
1881+ timeout = win32event.INFINITE
1882+ else:
1883+ timeout = 0
1884+ r = win32event.WaitForSingleObject(self.mutex, timeout)
1885+ if r == win32event.WAIT_FAILED:
1886+ raise GlobalLockError("Can't acquire mutex: error")
1887+ if not blocking and r == win32event.WAIT_TIMEOUT:
1888+ raise LockAlreadyAcquired('Lock %s already acquired by '
1889+ 'someone else' % self.name)
1890+ else:
1891+ # First, acquire the global (inter-process) lock:
1892+ if blocking:
1893+ options = fcntl.LOCK_EX
1894+ else:
1895+ options = fcntl.LOCK_EX|fcntl.LOCK_NB
1896+ try:
1897+ fcntl.flock(self.fdlock, options)
1898+ except IOError, message: #(errno 13: perm. denied,
1899+ # 36: Resource deadlock avoided)
1900+ if not blocking and self._errnoOf (message) == errno.EWOULDBLOCK:
1901+ raise LockAlreadyAcquired('Lock %s already acquired by '
1902+ 'someone else' % self.name)
1903+ else:
1904+ raise GlobalLockError('Cannot acquire lock on "file" '
1905+ '%s: %s\n' % (self.name, message))
1906+ #print 'got file lock.' ##
1907+
1908+ # Then acquire the local (inter-thread) lock:
1909+ if not self.threadLock.acquire(blocking):
1910+ fcntl.flock(self.fdlock, fcntl.LOCK_UN) # release global lock
1911+ raise LockAlreadyAcquired('Lock %s already acquired by '
1912+ 'someone else' % self.name)
1913+ if self.previous_lockfile_present and self.logger:
1914+ self.logger.warn("Stale lockfile detected and claimed.")
1915+ #print 'got thread lock.' ##
1916+
1917+ self.is_locked = True
1918+
1919+ def release(self, skip_delete=False):
1920+ ''' Unlocks. (caller must own the lock!)
1921+
1922+ @param skip_delete: don't try to delete the file. This can
1923+ be used when the original filename has changed; for
1924+ instance, if the lockfile is erased out-of-band, or if
1925+ the directory it contains has been renamed.
1926+
1927+ @return: The lock count.
1928+ @exception IOError: if file lock can't be released
1929+ @exception NotOwner: Attempt to release somebody else's lock.
1930+ '''
1931+ if not self.is_locked:
1932+ return
1933+ if not skip_delete:
1934+ if self.logger:
1935+ self.logger.debug('Removing lock file: %s', self.fpath)
1936+ os.unlink(self.fpath)
1937+ elif self.logger:
1938+ # At certain times the lockfile will have been removed or
1939+ # moved away before we call release(); log a message because
1940+ # this is unusual and could be an error.
1941+ self.logger.debug('Oops, my lock file disappeared: %s', self.fpath)
1942+ if _windows:
1943+ if ctypes:
1944+ result = ctypes.windll.kernel32.ReleaseMutex(self.mutex.handle)
1945+ if not result:
1946+ raise NotOwner("Attempt to release somebody else's lock")
1947+ else:
1948+ try:
1949+ win32event.ReleaseMutex(self.mutex)
1950+ #print "released mutex"
1951+ except pywintypes.error, e:
1952+ errCode, fctName, errMsg = e.args
1953+ if errCode == 288:
1954+ raise NotOwner("Attempt to release somebody else's lock")
1955+ else:
1956+ raise GlobalLockError('%s: err#%d: %s' % (fctName, errCode,
1957+ errMsg))
1958+ else:
1959+ # First release the local (inter-thread) lock:
1960+ try:
1961+ self.threadLock.release()
1962+ except AssertionError:
1963+ raise NotOwner("Attempt to release somebody else's lock")
1964+
1965+ # Then release the global (inter-process) lock:
1966+ try:
1967+ fcntl.flock(self.fdlock, fcntl.LOCK_UN)
1968+ except IOError: # (errno 13: permission denied)
1969+ raise GlobalLockError('Unlock of file "%s" failed\n' %
1970+ self.name)
1971+ self.is_locked = False
1972+
1973+ def _errnoOf (self, message):
1974+ match = self.RE_ERROR_MSG.search(str(message))
1975+ if match:
1976+ return int(match.group(1))
1977+ else:
1978+ raise Exception ('Malformed error message "%s"' % message)
1979+
1980+#----------------------------------------------------------------------------
1981+def test():
1982+#----------------------------------------------------------------------------
1983+ ##TODO: a more serious test with distinct processes !
1984+
1985+ print 'Testing glock.py...'
1986+
1987+ # unfortunately can't test inter-process lock here!
1988+ lockName = 'myFirstLock'
1989+ l = GlobalLock(lockName)
1990+ if not _windows:
1991+ assert posixpath.exists(lockName)
1992+ l.acquire()
1993+ l.acquire() # reentrant lock, must not block
1994+ l.release()
1995+ l.release()
1996+
1997+ try: l.release()
1998+ except NotOwner: pass
1999+ else: raise Exception('should have raised a NotOwner exception')
2000+
2001+ # Check that <> threads of same process do block:
2002+ import threading, time
2003+ thread = threading.Thread(target=threadMain, args=(l,))
2004+ print 'main: locking...',
2005+ l.acquire()
2006+ print ' done.'
2007+ thread.start()
2008+ time.sleep(3)
2009+ print '\nmain: unlocking...',
2010+ l.release()
2011+ print ' done.'
2012+ time.sleep(0.1)
2013+
2014+ print '=> Test of glock.py passed.'
2015+ return l
2016+
2017+def threadMain(lock):
2018+ print 'thread started(%s).' % lock
2019+ try: lock.acquire(blocking=False)
2020+ except LockAlreadyAcquired: pass
2021+ else: raise Exception('should have raised LockAlreadyAcquired')
2022+ print 'thread: locking (should stay blocked for ~ 3 sec)...',
2023+ lock.acquire()
2024+ print 'thread: locking done.'
2025+ print 'thread: unlocking...',
2026+ lock.release()
2027+ print ' done.'
2028+ print 'thread ended.'
2029+
2030+#----------------------------------------------------------------------------
2031+# M A I N
2032+#----------------------------------------------------------------------------
2033+if __name__ == "__main__":
2034+ l = test()
2035
2036=== added file 'checkbox/contrib/persist.py'
2037--- checkbox/contrib/persist.py 1970-01-01 00:00:00 +0000
2038+++ checkbox/contrib/persist.py 2012-03-28 20:34:20 +0000
2039@@ -0,0 +1,552 @@
2040+# Copyright (c) 2006 Canonical
2041+# Copyright (c) 2004 Conectiva, Inc.
2042+#
2043+# Written by Gustavo Niemeyer <gustavo@niemeyer.net>
2044+#
2045+# This Python module is free software; you can redistribute it and/or
2046+# modify it under the terms of the GNU General Public License as published
2047+# by the Free Software Foundation; either version 2 of the License, or (at
2048+# your option) any later version.
2049+#
2050+# This Python module is distributed in the hope that it will be useful,
2051+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2052+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2053+# General Public License for more details.
2054+#
2055+# You should have received a copy of the GNU General Public License
2056+# along with this Python module; if not, write to the Free Software
2057+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2058+#
2059+import os
2060+import sys
2061+import copy
2062+import re
2063+import posixpath
2064+
2065+from checkbox.lib.safe import safe_close
2066+
2067+__all__ = ["Persist", "MemoryBackend", "PickleBackend", "BPickleBackend",
2068+ "path_string_to_tuple", "path_tuple_to_string", "RootedPersist",
2069+ "PersistError", "PersistReadOnlyError"]
2070+
2071+
2072+NOTHING = object()
2073+
2074+
2075+class PersistError(Exception):
2076+ pass
2077+
2078+
2079+class PersistReadOnlyError(PersistError):
2080+ pass
2081+
2082+
2083+class Persist(object):
2084+ """Persistence handler.
2085+
2086+ There are three different kinds of opition maps, regarding the
2087+ persistence and priority that maps are queried.
2088+
2089+ hard - Options are persistent.
2090+ soft - Options are not persistent, and have a higher priority
2091+ than persistent options.
2092+ weak - Options are not persistent, and have a lower priority
2093+ than persistent options.
2094+
2095+ @ivar filename: The name of the file where persist data is saved
2096+ or None if not filename is available.
2097+ """
2098+
2099+
2100+ def __init__(self, filename=None, backend=None):
2101+ """
2102+ @param backend: The backend to use. If none is specified,
2103+ L{BPickleBackend} will be used.
2104+ @param filename: The default filename to save to and load from. If
2105+ specified, and the file exists, it will be immediately
2106+ loaded. Specifying this will also allow L{save} to be called
2107+ without any arguments to save the persist.
2108+ """
2109+ if backend is None:
2110+ backend = BPickleBackend()
2111+ self._backend = backend
2112+ self._hardmap = backend.new()
2113+ self._softmap = {}
2114+ self._weakmap = {}
2115+ self._readonly = False
2116+ self._modified = False
2117+ self.filename = filename
2118+ if filename is not None and posixpath.exists(filename):
2119+ self.load(filename)
2120+
2121+ def _get_readonly(self):
2122+ return self._readonly
2123+
2124+ def _set_readonly(self, flag):
2125+ self._readonly = bool(flag)
2126+
2127+ def _get_modified(self):
2128+ return self._modified
2129+
2130+ readonly = property(_get_readonly, _set_readonly)
2131+ modified = property(_get_modified)
2132+
2133+ def reset_modified(self):
2134+ self._modified = False
2135+
2136+ def assert_writable(self):
2137+ if self._readonly:
2138+ raise PersistReadOnlyError("Configuration is in readonly mode.")
2139+
2140+ def load(self, filepath):
2141+ filepath = posixpath.expanduser(filepath)
2142+ if not posixpath.isfile(filepath):
2143+ raise PersistError("File not found: %s" % filepath)
2144+ if posixpath.getsize(filepath) == 0:
2145+ return
2146+ try:
2147+ self._hardmap = self._backend.load(filepath)
2148+ except:
2149+ filepathold = filepath+".old"
2150+ if (posixpath.isfile(filepathold) and
2151+ posixpath.getsize(filepathold) > 0):
2152+ # warning("Broken configuration file at %s" % filepath)
2153+ # warning("Trying backup at %s" % filepathold)
2154+ try:
2155+ self._hardmap = self._backend.load(filepathold)
2156+ except:
2157+ raise PersistError("Broken configuration file at %s" %
2158+ filepathold)
2159+ else:
2160+ raise PersistError("Broken configuration file at %s" %
2161+ filepath)
2162+
2163+ def save(self, filepath=None):
2164+ """Save the persist to the given C{filepath}.
2165+
2166+ If None is specified, then the filename passed during construction will
2167+ be used.
2168+ """
2169+ if filepath is None:
2170+ if self.filename is None:
2171+ return
2172+ filepath = self.filename
2173+ filepath = posixpath.expanduser(filepath)
2174+ if posixpath.isfile(filepath):
2175+ os.rename(filepath, filepath+".old")
2176+ dirname = posixpath.dirname(filepath)
2177+ if dirname and not posixpath.isdir(dirname):
2178+ os.makedirs(dirname)
2179+ self._backend.save(filepath, self._hardmap)
2180+
2181+ def _traverse(self, obj, path, default=NOTHING, setvalue=NOTHING):
2182+ if setvalue is not NOTHING:
2183+ setvalue = self._backend.copy(setvalue)
2184+ queue = list(path)
2185+ marker = NOTHING
2186+ newobj = obj
2187+ while queue:
2188+ obj = newobj
2189+ elem = queue.pop(0)
2190+ newobj = self._backend.get(obj, elem)
2191+ if newobj is NotImplemented:
2192+ if queue:
2193+ path = path[:-len(queue)]
2194+ raise PersistError("Can't traverse %r (%r): %r" %
2195+ (type(obj), path_tuple_to_string(path),
2196+ str(obj)))
2197+ if newobj is marker:
2198+ break
2199+ if newobj is not marker:
2200+ if setvalue is not marker:
2201+ newobj = self._backend.set(obj, elem, setvalue)
2202+ else:
2203+ if setvalue is marker:
2204+ newobj = default
2205+ else:
2206+ while True:
2207+ if len(queue) > 0:
2208+ if type(queue[0]) is int:
2209+ newvalue = []
2210+ else:
2211+ newvalue = {}
2212+ else:
2213+ newvalue = setvalue
2214+ newobj = self._backend.set(obj, elem, newvalue)
2215+ if newobj is NotImplemented:
2216+ raise PersistError("Can't traverse %r with %r" %
2217+ (type(obj), type(elem)))
2218+ if not queue:
2219+ break
2220+ obj = newobj
2221+ elem = queue.pop(0)
2222+ return newobj
2223+
2224+ def _getvalue(self, path, soft=False, hard=False, weak=False):
2225+ if type(path) is str:
2226+ path = path_string_to_tuple(path)
2227+ marker = NOTHING
2228+ if soft:
2229+ value = self._traverse(self._softmap, path, marker)
2230+ elif hard:
2231+ value = self._traverse(self._hardmap, path, marker)
2232+ elif weak:
2233+ value = self._traverse(self._weakmap, path, marker)
2234+ else:
2235+ value = self._traverse(self._softmap, path, marker)
2236+ if value is marker:
2237+ value = self._traverse(self._hardmap, path, marker)
2238+ if value is marker:
2239+ value = self._traverse(self._weakmap, path, marker)
2240+ return value
2241+
2242+ def has(self, path, value=NOTHING, soft=False, hard=False, weak=False):
2243+ obj = self._getvalue(path, soft, hard, weak)
2244+ marker = NOTHING
2245+ if obj is marker:
2246+ return False
2247+ elif value is marker:
2248+ return True
2249+ result = self._backend.has(obj, value)
2250+ if result is NotImplemented:
2251+ raise PersistError("Can't check %r for containment" % type(obj))
2252+ return result
2253+
2254+ def keys(self, path, soft=False, hard=False, weak=False):
2255+ obj = self._getvalue(path, soft, hard, weak)
2256+ if obj is NOTHING:
2257+ return []
2258+ result = self._backend.keys(obj)
2259+ if result is NotImplemented:
2260+ raise PersistError("Can't return keys for %s" % type(obj))
2261+ return result
2262+
2263+ def get(self, path, default=None, soft=False, hard=False, weak=False):
2264+ value = self._getvalue(path, soft, hard, weak)
2265+ if value is NOTHING:
2266+ return default
2267+ return self._backend.copy(value)
2268+
2269+ def set(self, path, value, soft=False, weak=False):
2270+ assert path
2271+ if type(path) is str:
2272+ path = path_string_to_tuple(path)
2273+ if soft:
2274+ map = self._softmap
2275+ elif weak:
2276+ map = self._weakmap
2277+ else:
2278+ self.assert_writable()
2279+ self._modified = True
2280+ map = self._hardmap
2281+ self._traverse(map, path, setvalue=value)
2282+
2283+ def add(self, path, value, unique=False, soft=False, weak=False):
2284+ assert path
2285+ if type(path) is str:
2286+ path = path_string_to_tuple(path)
2287+ if soft:
2288+ map = self._softmap
2289+ elif weak:
2290+ map = self._weakmap
2291+ else:
2292+ self.assert_writable()
2293+ self._modified = True
2294+ map = self._hardmap
2295+ if unique:
2296+ current = self._traverse(map, path)
2297+ if type(current) is list and value in current:
2298+ return
2299+ path = path+(sys.maxint,)
2300+ self._traverse(map, path, setvalue=value)
2301+
2302+ def remove(self, path, value=NOTHING, soft=False, weak=False):
2303+ assert path
2304+ if type(path) is str:
2305+ path = path_string_to_tuple(path)
2306+ if soft:
2307+ map = self._softmap
2308+ elif weak:
2309+ map = self._weakmap
2310+ else:
2311+ self.assert_writable()
2312+ self._modified = True
2313+ map = self._hardmap
2314+ marker = NOTHING
2315+ while path:
2316+ if value is marker:
2317+ obj = self._traverse(map, path[:-1])
2318+ elem = path[-1]
2319+ isvalue = False
2320+ else:
2321+ obj = self._traverse(map, path)
2322+ elem = value
2323+ isvalue = True
2324+ result = False
2325+ if obj is not marker:
2326+ result = self._backend.remove(obj, elem, isvalue)
2327+ if result is NotImplemented:
2328+ raise PersistError("Can't remove %r from %r" %
2329+ (elem, type(obj)))
2330+ if self._backend.empty(obj):
2331+ if value is not marker:
2332+ value = marker
2333+ else:
2334+ path = path[:-1]
2335+ else:
2336+ break
2337+ return result
2338+
2339+ def move(self, oldpath, newpath, soft=False, weak=False):
2340+ if not (soft or weak):
2341+ self.assert_writable()
2342+ if type(oldpath) is str:
2343+ oldpath = path_string_to_tuple(oldpath)
2344+ if type(newpath) is str:
2345+ newpath = path_string_to_tuple(newpath)
2346+ result = False
2347+ marker = NOTHING
2348+ value = self._getvalue(oldpath, soft, not (soft or weak), weak)
2349+ if value is not marker:
2350+ self.remove(oldpath, soft=soft, weak=weak)
2351+ self.set(newpath, value, weak, soft)
2352+ result = True
2353+ return result
2354+
2355+ def root_at(self, path):
2356+ return RootedPersist(self, path)
2357+
2358+
2359+class RootedPersist(object):
2360+
2361+ def __init__(self, parent, root):
2362+ self.parent = parent
2363+ if type(root) is str:
2364+ self.root = path_string_to_tuple(root)
2365+ else:
2366+ self.root = root
2367+
2368+ readonly = property(lambda self: self.parent.readonly)
2369+ modified = property(lambda self: self.parent.modified)
2370+
2371+ def assert_writable(self):
2372+ self.parent.assert_writable()
2373+
2374+ def save(self):
2375+ self.parent.save()
2376+
2377+ def has(self, path, value=NOTHING, soft=False, hard=False, weak=False):
2378+ if type(path) is str:
2379+ path = path_string_to_tuple(path)
2380+ return self.parent.has(self.root+path, value, soft, hard, weak)
2381+
2382+ def keys(self, path, soft=False, hard=False, weak=False):
2383+ if type(path) is str:
2384+ path = path_string_to_tuple(path)
2385+ return self.parent.keys(self.root+path, soft, hard, weak)
2386+
2387+ def get(self, path, default=None, soft=False, hard=False, weak=False):
2388+ if type(path) is str:
2389+ path = path_string_to_tuple(path)
2390+ return self.parent.get(self.root+path, default, soft, hard, weak)
2391+
2392+ def set(self, path, value, soft=False, weak=False):
2393+ if type(path) is str:
2394+ path = path_string_to_tuple(path)
2395+ return self.parent.set(self.root+path, value, soft, weak)
2396+
2397+ def add(self, path, value, unique=False, soft=False, weak=False):
2398+ if type(path) is str:
2399+ path = path_string_to_tuple(path)
2400+ return self.parent.add(self.root+path, value, unique, soft, weak)
2401+
2402+ def remove(self, path, value=NOTHING, soft=False, weak=False):
2403+ if type(path) is str:
2404+ path = path_string_to_tuple(path)
2405+ return self.parent.remove(self.root+path, value, soft, weak)
2406+
2407+ def move(self, oldpath, newpath, soft=False, weak=False):
2408+ if type(oldpath) is str:
2409+ oldpath = path_string_to_tuple(oldpath)
2410+ if type(newpath) is str:
2411+ newpath = path_string_to_tuple(newpath)
2412+ return self.parent.move(self.root+oldpath, self.root+newpath,
2413+ soft, weak)
2414+
2415+ def root_at(self, path):
2416+ if type(path) is str:
2417+ path = path_string_to_tuple(path)
2418+ return self.parent.root_at(self.root+path)
2419+
2420+
2421+_splitpath = re.compile(r"(\[-?\d+\])|(?<!\\)\.").split
2422+
2423+def path_string_to_tuple(path):
2424+ if "." not in path and "[" not in path:
2425+ return (path,)
2426+ result = []
2427+ tokens = _splitpath(path)
2428+ for token in tokens:
2429+ if token:
2430+ if token[0] == "[" and token[-1] == "]":
2431+ try:
2432+ result.append(int(token[1:-1]))
2433+ except ValueError:
2434+ raise PersistError("Invalid path index: %r" % token)
2435+ else:
2436+ result.append(token.replace(r"\.", "."))
2437+ return tuple(result)
2438+
2439+
2440+def path_tuple_to_string(path):
2441+ result = []
2442+ for elem in path:
2443+ if type(elem) is int:
2444+ result[-1] += "[%d]" % elem
2445+ else:
2446+ result.append(str(elem).replace(".", "\."))
2447+ return ".".join(result)
2448+
2449+
2450+class Backend(object):
2451+
2452+ def new(self):
2453+ return {}
2454+
2455+ def load(self, filepath):
2456+ raise NotImplementedError
2457+
2458+ def save(self, filepath, map):
2459+ raise NotImplementedError
2460+
2461+ def get(self, obj, elem, _marker=NOTHING):
2462+ if type(obj) is dict:
2463+ newobj = obj.get(elem, _marker)
2464+ elif type(obj) in (tuple, list):
2465+ if type(elem) is int:
2466+ try:
2467+ newobj = obj[elem]
2468+ except IndexError:
2469+ newobj = _marker
2470+ elif elem in obj:
2471+ newobj = elem
2472+ else:
2473+ newobj = _marker
2474+ else:
2475+ newobj = NotImplemented
2476+ return newobj
2477+
2478+ def set(self, obj, elem, value):
2479+ if type(obj) is dict:
2480+ newobj = obj[elem] = value
2481+ elif type(obj) is list and type(elem) is int:
2482+ lenobj = len(obj)
2483+ if lenobj <= elem:
2484+ obj.append(None)
2485+ elem = lenobj
2486+ elif elem < 0 and abs(elem) > lenobj:
2487+ obj.insert(0, None)
2488+ elem = 0
2489+ newobj = obj[elem] = value
2490+ else:
2491+ newobj = NotImplemented
2492+ return newobj
2493+
2494+ def remove(self, obj, elem, isvalue):
2495+ result = False
2496+ if type(obj) is dict:
2497+ if elem in obj:
2498+ del obj[elem]
2499+ result = True
2500+ elif type(obj) is list:
2501+ if not isvalue and type(elem) is int:
2502+ try:
2503+ del obj[elem]
2504+ result = True
2505+ except IndexError:
2506+ pass
2507+ elif elem in obj:
2508+ obj[:] = [x for x in obj if x != elem]
2509+ result = True
2510+ else:
2511+ result = NotImplemented
2512+ return result
2513+
2514+ def copy(self, value):
2515+ if type(value) in (dict, list):
2516+ return copy.deepcopy(value)
2517+ return value
2518+
2519+ def empty(self, obj):
2520+ return (not obj)
2521+
2522+ def has(self, obj, elem):
2523+ contains = getattr(obj, "__contains__", None)
2524+ if contains:
2525+ return contains(elem)
2526+ return NotImplemented
2527+
2528+ def keys(self, obj):
2529+ keys = getattr(obj, "keys", None)
2530+ if keys:
2531+ return keys()
2532+ elif type(obj) is list:
2533+ return range(len(obj))
2534+ return NotImplemented
2535+
2536+
2537+class MemoryBackend(Backend):
2538+
2539+ def __init__(self):
2540+ self._store = {}
2541+
2542+ def load(self, filepath):
2543+ return self._store.get(filepath)
2544+
2545+ def save(self, filepath, map):
2546+ self._store[filepath] = map
2547+
2548+class DiskBackend(Backend):
2549+
2550+ safe_file_closing = True
2551+
2552+class PickleBackend(DiskBackend):
2553+
2554+ def __init__(self):
2555+ import cPickle
2556+ self._pickle = cPickle
2557+
2558+ def load(self, filepath):
2559+ file = open(filepath)
2560+ try:
2561+ return self._pickle.load(file)
2562+ finally:
2563+ safe_close(file, self.safe_file_closing)
2564+
2565+ def save(self, filepath, map):
2566+ file = open(filepath, "w")
2567+ try:
2568+ self._pickle.dump(map, file, 2)
2569+ finally:
2570+ safe_close(file, self.safe_file_closing)
2571+
2572+
2573+class BPickleBackend(DiskBackend):
2574+
2575+ def __init__(self):
2576+ from checkbox.contrib import bpickle
2577+ self._bpickle = bpickle
2578+
2579+ def load(self, filepath):
2580+ file = open(filepath)
2581+ try:
2582+ return self._bpickle.loads(file.read())
2583+ finally:
2584+ safe_close(file, self.safe_file_closing)
2585+
2586+ def save(self, filepath, map):
2587+ file = open(filepath, "w")
2588+ try:
2589+ file.write(self._bpickle.dumps(map))
2590+ finally:
2591+ safe_close(file, self.safe_file_closing)
2592
2593=== added file 'checkbox/dispatcher.py'
2594--- checkbox/dispatcher.py 1970-01-01 00:00:00 +0000
2595+++ checkbox/dispatcher.py 2012-03-28 20:34:20 +0000
2596@@ -0,0 +1,201 @@
2597+# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
2598+# GNU Affero General Public License version 3 (see the file LICENSE).
2599+
2600+__metaclass__ = type
2601+
2602+__all__ = [
2603+ "Dispatcher",
2604+ "DispatcherList",
2605+ "DispatcherQueue",
2606+ ]
2607+
2608+import logging
2609+
2610+from itertools import product
2611+
2612+
2613+class Event:
2614+ """Event payload containing the positional and keywoard arguments
2615+ passed to the handler in the event listener."""
2616+
2617+ def __init__(self, type, *args, **kwargs):
2618+ self.type = type
2619+ self.args = args
2620+ self.kwargs = kwargs
2621+
2622+
2623+class Listener:
2624+ """Event listener notified when events are published by the dispatcher."""
2625+
2626+ def __init__(self, event_type, handler, count):
2627+ self.event_type = event_type
2628+ self.handler = handler
2629+ self.count = count
2630+
2631+ def notify(self, event):
2632+ """Notify the handler with the payload of the event.
2633+
2634+ :param event: The event containint the payload for the handler.
2635+ """
2636+ if self.count is None or self.count:
2637+ self.handler(*event.args, **event.kwargs)
2638+ if self.count:
2639+ self.count -= 1
2640+
2641+
2642+class ListenerList(Listener):
2643+ """Event listener notified for lists of events."""
2644+
2645+ def __init__(self, *args, **kwargs):
2646+ super(ListenerList, self).__init__(*args, **kwargs)
2647+ self.event_types = set(self.event_type)
2648+ self.kwargs = {}
2649+
2650+ def notify(self, event):
2651+ """Only notify the handler when all the events for this listener
2652+ have been published by the dispatcher. When duplicate events
2653+ occur, the latest event is preserved and the previous one are
2654+ overwritten until all events have been published.
2655+ """
2656+ if self.count is None or self.count:
2657+ self.kwargs[event.type] = event.args[0]
2658+ if self.event_types.issubset(self.kwargs):
2659+ self.handler(**self.kwargs)
2660+ if self.count:
2661+ self.count -= 1
2662+
2663+
2664+class ListenerQueue(ListenerList):
2665+
2666+ def notify(self, event):
2667+ """Only notify the handler when all the events for this listener
2668+ have been published by the dispatcher. Duplicate events are enqueued
2669+ and dequeued only when all events have been published.
2670+ """
2671+ arg = event.args[0]
2672+ queue = self.kwargs.setdefault(event.type, [])
2673+
2674+ # Strip duplicates from the queue.
2675+ if arg not in queue:
2676+ queue.append(arg)
2677+
2678+ # Once the queue has handler has been called, the queue
2679+ # then behaves like a list using the latest events.
2680+ if self.event_types.issubset(self.kwargs):
2681+ self.notify = notify = super(ListenerQueue, self).notify
2682+ keys = self.kwargs.keys()
2683+ for values in product(*self.kwargs.values()):
2684+ self.kwargs = dict(zip(keys, values))
2685+ notify(event)
2686+
2687+
2688+class Dispatcher:
2689+ """Register handlers and publish events for them identified by strings."""
2690+
2691+ listener_factory = Listener
2692+
2693+ def __init__(self, listener_factory=None):
2694+ self._event_listeners = {}
2695+
2696+ if listener_factory is not None:
2697+ self.listener_factory = listener_factory
2698+
2699+ def registerHandler(self, event_type, handler, count=None):
2700+ """Register an event handler and return its listener.
2701+
2702+ :param event_type: The name of the event type to handle.
2703+ :param handler: The function handling the given event type.
2704+ :param count: Optionally, the number times to call the handler.
2705+ """
2706+ listener = self.listener_factory(event_type, handler, count)
2707+
2708+ listeners = self._event_listeners.setdefault(event_type, [])
2709+ listeners.append(listener)
2710+
2711+ return listener
2712+
2713+ def unregisterHandler(self, handler):
2714+ """Unregister a handler.
2715+
2716+ :param handler: The handler to unregister.
2717+ """
2718+ for event_type, listeners in self._event_listeners.items():
2719+ listeners = [
2720+ listener for listener in listeners
2721+ if listener.handler == handler]
2722+ if listeners:
2723+ self._event_listeners[event_type] = listeners
2724+ else:
2725+ del self._event_listeners[event_type]
2726+
2727+ def unregisterListener(self, listener, event_type=None):
2728+ """Unregister a listener.
2729+
2730+ :param listener: The listener of the handler to unregister.
2731+ :param event_type: Optionally, the event_type to unregister.
2732+ """
2733+ if event_type is None:
2734+ event_type = listener.event_type
2735+
2736+ self._event_listeners[event_type].remove(listener)
2737+ if not self._event_listeners[event_type]:
2738+ del self._event_listeners[event_type]
2739+
2740+ def publishEvent(self, event_type, *args, **kwargs):
2741+ """Publish an event of a given type and notify all listeners.
2742+
2743+ :param event_type: The name of the event type to publish.
2744+ :param args: Positional arguments to pass to the registered handlers.
2745+ :param kwargs: Keyword arguments to pass to the registered handlers.
2746+ """
2747+ if event_type in self._event_listeners:
2748+ event = Event(event_type, *args, **kwargs)
2749+ for listener in list(self._event_listeners[event_type]):
2750+ try:
2751+ listener.notify(event)
2752+ if listener.count is not None and not listener.count:
2753+ self.unregisterListener(listener)
2754+ except:
2755+ logging.exception(
2756+ "Error running event handler for %r with args %r %r",
2757+ event_type, args, kwargs)
2758+
2759+
2760+class DispatcherList(Dispatcher):
2761+ """
2762+ Register handlers and publish events for them identified by lists
2763+ of strings.
2764+ """
2765+
2766+ listener_factory = ListenerList
2767+
2768+ def registerHandler(self, event_types, handler, count=None):
2769+ """See Dispatcher."""
2770+ if not isinstance(event_types, (list, tuple,)):
2771+ event_types = (event_types,)
2772+
2773+ listener = self.listener_factory(event_types, handler, count)
2774+ for event_type in event_types:
2775+ listeners = self._event_listeners.setdefault(event_type, [])
2776+ listeners.append(listener)
2777+
2778+ return listener
2779+
2780+ def unregisterListener(self, listener):
2781+ """See Dispatcher."""
2782+ for event_type in listener.event_types:
2783+ super(DispatcherList, self).unregisterListener(
2784+ listener, event_type)
2785+
2786+ def publishEvent(self, event_type, arg):
2787+ """See Dispatcher."""
2788+ super(DispatcherList, self).publishEvent(event_type, arg)
2789+
2790+
2791+class DispatcherQueue(DispatcherList):
2792+ """
2793+ Register handlers and publish events for them identified by lists
2794+ of strings in queue order.
2795+ """
2796+
2797+ listener_factory = ListenerQueue
2798
2799=== added file 'checkbox/job.py'
2800--- checkbox/job.py 1970-01-01 00:00:00 +0000
2801+++ checkbox/job.py 2012-03-28 20:34:20 +0000
2802@@ -0,0 +1,140 @@
2803+#
2804+# This file is part of Checkbox.
2805+#
2806+# Copyright 2008 Canonical Ltd.
2807+#
2808+# Checkbox is free software: you can redistribute it and/or modify
2809+# it under the terms of the GNU General Public License as published by
2810+# the Free Software Foundation, either version 3 of the License, or
2811+# (at your option) any later version.
2812+#
2813+# Checkbox is distributed in the hope that it will be useful,
2814+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2815+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2816+# GNU General Public License for more details.
2817+#
2818+# You should have received a copy of the GNU General Public License
2819+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
2820+#
2821+import os
2822+import logging
2823+
2824+from gettext import gettext as _
2825+from string import Template
2826+
2827+from checkbox.lib.process import Process
2828+from checkbox.lib.signal import signal_to_name, signal_to_description
2829+
2830+from checkbox.message import MessageStore
2831+
2832+
2833+FAIL = "fail"
2834+PASS = "pass"
2835+UNINITIATED = "uninitiated"
2836+UNRESOLVED = "unresolved"
2837+UNSUPPORTED = "unsupported"
2838+UNTESTED = "untested"
2839+
2840+ALL_STATUS = [FAIL, PASS, UNINITIATED, UNRESOLVED, UNSUPPORTED, UNTESTED]
2841+
2842+DEFAULT_JOB_TIMEOUT = 30 # used in case a job specifies invalid timeout
2843+
2844+class Job(object):
2845+
2846+ def __init__(self, command, environ=None, timeout=None):
2847+ if environ is None:
2848+ environ = []
2849+
2850+ self.command = command
2851+ self.environ = environ
2852+ self.timeout = timeout
2853+ if self.timeout is not None:
2854+ try:
2855+ self.timeout = float(self.timeout)
2856+ except:
2857+ self.timeout = DEFAULT_JOB_TIMEOUT
2858+ finally:
2859+ if self.timeout < 0:
2860+ self.timeout = DEFAULT_JOB_TIMEOUT
2861+
2862+ def execute(self):
2863+ # Sanitize environment
2864+ process_environ = dict(os.environ)
2865+ for environ in self.environ:
2866+ key, value = environ.split("=", 1)
2867+ value = Template(value).safe_substitute(process_environ)
2868+ process_environ[key] = value
2869+
2870+ logging.info("Running command: %s", self.command)
2871+ process = Process(self.command, process_environ)
2872+ if not process.read(self.timeout):
2873+ logging.info("Command timed out, killing process.")
2874+ process.kill()
2875+
2876+ process_status = process.cleanup()
2877+ if os.WIFEXITED(process_status):
2878+ exit_status = os.WEXITSTATUS(process_status)
2879+ if exit_status == 0:
2880+ status = PASS
2881+ data = process.outdata
2882+ if not data:
2883+ data = process.errdata
2884+ elif exit_status == 127:
2885+ status = UNRESOLVED
2886+ data = _("Command not found.")
2887+ else:
2888+ status = FAIL
2889+ data = (process.errdata
2890+ or process.outdata)
2891+ elif os.WIFSIGNALED(process_status):
2892+ status = UNRESOLVED
2893+ term_signal = os.WTERMSIG(process_status)
2894+ data = _("Command received signal %s: %s") % \
2895+ (signal_to_name(term_signal),
2896+ signal_to_description(term_signal))
2897+ else:
2898+ raise Exception, "Command not terminated: %s" \
2899+ % self.command
2900+
2901+ duration = process.endtime - process.starttime
2902+
2903+ return (status, data, duration,)
2904+
2905+
2906+class JobStore(MessageStore):
2907+ """A job store which stores its jobs in a file system hierarchy."""
2908+
2909+ def add(self, job):
2910+ # TODO: Order alphabetically within suite or non-suite
2911+
2912+ # Remove the same job if it already exists without a suite
2913+ if "suite" in job:
2914+ for filename in self._find_matching_messages(name=job["name"], suite=None):
2915+ os.unlink(filename)
2916+
2917+ # Return if the same job is already in the store
2918+ if list(self._find_matching_messages(name=job["name"])):
2919+ return
2920+
2921+ message_id = super(JobStore, self).add(job)
2922+
2923+ # TODO: Apply dependencies
2924+ if "depends" in job:
2925+ for depends in job["depends"]:
2926+ for filename in self._find_matching_messages():
2927+ message = self._read_message(filename, cache=True)
2928+ if job["name"] in message.get("depends", []):
2929+ new_filename = self._get_next_message_filename()
2930+ os.rename(filename, new_filename)
2931+
2932+ return message_id
2933+
2934+ # TODO: Optimize by only searching backwards until a given condition
2935+ def _find_matching_messages(self, **kwargs):
2936+ for filename in self._walk_messages():
2937+ message = self._read_message(filename,cache=True)
2938+ for key, value in kwargs.iteritems():
2939+ if message.get(key) != value:
2940+ break
2941+ else:
2942+ yield filename
2943
2944=== added directory 'checkbox/lib'
2945=== added file 'checkbox/lib/__init__.py'
2946=== added file 'checkbox/lib/bit.py'
2947--- checkbox/lib/bit.py 1970-01-01 00:00:00 +0000
2948+++ checkbox/lib/bit.py 2012-03-28 20:34:20 +0000
2949@@ -0,0 +1,46 @@
2950+#
2951+# This file is part of Checkbox.
2952+#
2953+# Copyright 2008 Canonical Ltd.
2954+#
2955+# Checkbox is free software: you can redistribute it and/or modify
2956+# it under the terms of the GNU General Public License as published by
2957+# the Free Software Foundation, either version 3 of the License, or
2958+# (at your option) any later version.
2959+#
2960+# Checkbox is distributed in the hope that it will be useful,
2961+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2962+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2963+# GNU General Public License for more details.
2964+#
2965+# You should have received a copy of the GNU General Public License
2966+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
2967+#
2968+from struct import calcsize
2969+
2970+
2971+def get_bitmask(key):
2972+ bitmask = []
2973+ for value in reversed(key.split()):
2974+ value = int(value, 16)
2975+ bitmask.append(value)
2976+
2977+ return bitmask
2978+
2979+def get_bitcount(bitmask):
2980+ bitcount = 0
2981+ for value in bitmask:
2982+ while value:
2983+ bitcount += 1
2984+ value &= (value - 1)
2985+
2986+ return bitcount
2987+
2988+def test_bit(bit, bitmask, bits=None):
2989+ if bits is None:
2990+ bits = calcsize("l") * 8
2991+ offset = bit % bits
2992+ long = int(bit / bits)
2993+ if long >= len(bitmask):
2994+ return 0
2995+ return (bitmask[long] >> offset) & 1
2996
2997=== added file 'checkbox/lib/cache.py'
2998--- checkbox/lib/cache.py 1970-01-01 00:00:00 +0000
2999+++ checkbox/lib/cache.py 2012-03-28 20:34:20 +0000
3000@@ -0,0 +1,37 @@
3001+#
3002+# This file is part of Checkbox.
3003+#
3004+# Copyright 2008 Canonical Ltd.
3005+#
3006+# Checkbox is free software: you can redistribute it and/or modify
3007+# it under the terms of the GNU General Public License as published by
3008+# the Free Software Foundation, either version 3 of the License, or
3009+# (at your option) any later version.
3010+#
3011+# Checkbox is distributed in the hope that it will be useful,
3012+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3013+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3014+# GNU General Public License for more details.
3015+#
3016+# You should have received a copy of the GNU General Public License
3017+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3018+#
3019+class Cache(object):
3020+
3021+ def __init__(self, function):
3022+ self._cache = {}
3023+ self._function = function
3024+
3025+ def __get__(self, instance, cls=None):
3026+ self._instance = instance
3027+ return self
3028+
3029+ def __call__(self, *args):
3030+ if not self._cache.has_key((self._instance,) + args):
3031+ self._cache[(self._instance,) + args] = self._function(self._instance, *args)
3032+
3033+ return self._cache[(self._instance,) + args]
3034+
3035+
3036+def cache(function):
3037+ return Cache(function)
3038
3039=== added file 'checkbox/lib/config.py'
3040--- checkbox/lib/config.py 1970-01-01 00:00:00 +0000
3041+++ checkbox/lib/config.py 2012-03-28 20:34:20 +0000
3042@@ -0,0 +1,173 @@
3043+#
3044+# This file is part of Checkbox.
3045+#
3046+# Copyright 2008 Canonical Ltd.
3047+#
3048+# Checkbox is free software: you can redistribute it and/or modify
3049+# it under the terms of the GNU General Public License as published by
3050+# the Free Software Foundation, either version 3 of the License, or
3051+# (at your option) any later version.
3052+#
3053+# Checkbox is distributed in the hope that it will be useful,
3054+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3055+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3056+# GNU General Public License for more details.
3057+#
3058+# You should have received a copy of the GNU General Public License
3059+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3060+#
3061+import os
3062+import re
3063+import logging
3064+import posixpath
3065+
3066+from ConfigParser import ConfigParser
3067+
3068+from checkbox.lib.text import split
3069+
3070+
3071+class IncludeDict(dict):
3072+
3073+ def __init__(self, parser):
3074+ super(IncludeDict, self).__init__()
3075+ self._parser = parser
3076+
3077+ for (key, value) in os.environ.iteritems():
3078+ if key.startswith("CHECKBOX"):
3079+ super(IncludeDict, self).__setitem__(key.lower(), value)
3080+
3081+ def __setitem__(self, key, value):
3082+ if key == "includes":
3083+ if isinstance(value, list):
3084+ value = value[0]
3085+ for path in split(value):
3086+ path = self._parser._interpolate("DEFAULT", None, path, self)
3087+ path = posixpath.expanduser(path)
3088+ if not posixpath.exists(path):
3089+ raise Exception, "No such configuration file: %s" % path
3090+ if posixpath.isdir(path):
3091+ logging.info("Parsing config filenames from directory: %s",
3092+ path)
3093+ def walk_func(arg, directory, names):
3094+ for name in names:
3095+ path = posixpath.join(directory, name)
3096+ if not posixpath.isdir(path):
3097+ arg._parser.read(path)
3098+
3099+ posixpath.walk(path, walk_func, self)
3100+ else:
3101+ logging.info("Parsing config filename: %s", path)
3102+ self._parser.read(path)
3103+
3104+ # Environment has precedence over configuration
3105+ elif not key.startswith("CHECKBOX") or key.upper() not in os.environ:
3106+ super(IncludeDict, self).__setitem__(key, value)
3107+
3108+
3109+class ConfigSection(object):
3110+
3111+ def __init__(self, parent, name, attributes={}):
3112+ self.parent = parent
3113+ self.name = name
3114+ self.attributes = {}
3115+ for key, value in attributes.iteritems():
3116+ self.attributes[key] = re.sub("\n\.\n", "\n\n", value)
3117+
3118+ def __getattr__(self, name):
3119+ if name in self.attributes:
3120+ return self.get(name)
3121+
3122+ raise AttributeError, name
3123+
3124+ def __contains__(self, name):
3125+ return name in self.attributes
3126+
3127+ def get(self, name):
3128+ return self.attributes.get(name, "")
3129+
3130+ def set(self, name, value):
3131+ self.parent._parser.set(self.name, name, value)
3132+ self.attributes[name] = value
3133+
3134+
3135+class ConfigDefaults(ConfigSection):
3136+
3137+ def __getattr__(self, name):
3138+ if name in self.attributes:
3139+ return self.get(name)
3140+
3141+ raise AttributeError, name
3142+
3143+ def get(self, name):
3144+ name_upper = name.upper()
3145+ if not name_upper.startswith("CHECKBOX") or name_upper not in os.environ:
3146+ return super(ConfigDefaults, self).get(name)
3147+ else:
3148+ return os.environ[name_upper]
3149+
3150+
3151+class Config(object):
3152+
3153+ def __init__(self):
3154+ self._parser = ConfigParser()
3155+ self._parser._defaults = IncludeDict(self._parser)
3156+
3157+ # Copy attributes from the parser to avoid one additional
3158+ # function call on each access.
3159+ for attr in ["has_section", "remove_section"]:
3160+ setattr(self, attr, getattr(self._parser, attr))
3161+
3162+ def read_configs(self, configs):
3163+ for config in configs:
3164+ match = re.match("(.*)/([^/]+)=(.*)", config)
3165+ if not match:
3166+ raise Exception, "Invalid config string: %s" % config
3167+
3168+ (name, option, value) = match.groups()
3169+
3170+ # Match section names
3171+ name_regex = re.compile(name)
3172+ sections = [section for section in self._parser.sections()
3173+ if name_regex.match(section)]
3174+
3175+ if not sections:
3176+ self._parser.add_section(name)
3177+ sections.append(name)
3178+
3179+ for section in sections:
3180+ logging.debug('Setting configuration parameter: '
3181+ '%(section)s/%(option)s = %(value)s'
3182+ % {'section': section,
3183+ 'option': option,
3184+ 'value': value})
3185+ self._parser.set(section, option, value)
3186+
3187+ def read_file(self, file, filename="<stream>"):
3188+ logging.info("Reading configurations from: %s", filename)
3189+
3190+ self._parser.readfp(file, filename)
3191+
3192+ def read_filename(self, filename):
3193+ if not posixpath.exists(filename):
3194+ raise Exception, "No such configuration file: %s" % filename
3195+
3196+ file = open(filename, "r")
3197+ return self.read_file(file, filename)
3198+
3199+ def get_defaults(self):
3200+ attributes = self._parser.defaults()
3201+ return ConfigDefaults(self, 'DEFAULT', attributes)
3202+
3203+ def get_section(self, name):
3204+ if self._parser.has_section(name):
3205+ attributes = dict(self._parser.items(name))
3206+ return ConfigSection(self, name, attributes)
3207+
3208+ return None
3209+
3210+ def get_section_names(self):
3211+ return self._parser.sections()
3212+
3213+ def add_section(self, name):
3214+ self._parser.add_section(name)
3215+ return self.get_section(name)
3216
3217=== added file 'checkbox/lib/conversion.py'
3218--- checkbox/lib/conversion.py 1970-01-01 00:00:00 +0000
3219+++ checkbox/lib/conversion.py 2012-03-28 20:34:20 +0000
3220@@ -0,0 +1,169 @@
3221+#
3222+# This file is part of Checkbox.
3223+#
3224+# Copyright 2008 Canonical Ltd.
3225+#
3226+# Checkbox is free software: you can redistribute it and/or modify
3227+# it under the terms of the GNU General Public License as published by
3228+# the Free Software Foundation, either version 3 of the License, or
3229+# (at your option) any later version.
3230+#
3231+# Checkbox is distributed in the hope that it will be useful,
3232+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3233+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3234+# GNU General Public License for more details.
3235+#
3236+# You should have received a copy of the GNU General Public License
3237+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3238+#
3239+import re
3240+
3241+from dateutil import tz
3242+from datetime import (
3243+ datetime,
3244+ timedelta,
3245+ )
3246+
3247+
3248+DATETIME_RE = re.compile(r"""
3249+ ^(?P<year>\d\d\d\d)-?(?P<month>\d\d)-?(?P<day>\d\d)
3250+ T(?P<hour>\d\d):?(?P<minute>\d\d):?(?P<second>\d\d)
3251+ (?:\.(?P<second_fraction>\d{0,6}))?
3252+ (?P<tz>
3253+ (?:(?P<tz_sign>[-+])(?P<tz_hour>\d\d):(?P<tz_minute>\d\d))
3254+ | Z)?$
3255+ """, re.VERBOSE)
3256+
3257+TYPE_FORMATS = (
3258+ (r"(yes|true)", lambda v: True),
3259+ (r"(no|false)", lambda v: False),
3260+ (r"-?\d+", lambda v: int(v.group(0))),
3261+ (r"-?\d+\.\d+", lambda v: float(v.group(0))),
3262+ (r"(-?\d+) ?([kmgt]?b?)", lambda v: int(v.group(1))),
3263+ (r"(-?\d+\.\d+) ?([kmgt]?b?)", lambda v: float(v.group(1))),
3264+ (r"(-?\d+) ?([kmgt]?hz)", lambda v: int(v.group(1))),
3265+ (r"(-?\d+\.\d+) ?([kmgt]?hz)", lambda v: float(v.group(1))))
3266+TYPE_FORMATS = tuple(
3267+ (re.compile(r"^%s$" % pattern, re.IGNORECASE), format)
3268+ for pattern, format in TYPE_FORMATS)
3269+
3270+TYPE_MULTIPLIERS = (
3271+ (r"b", 1),
3272+ (r"kb?", 1024),
3273+ (r"mb?", 1024 * 1024),
3274+ (r"gb?", 1024 * 1024 * 1024),
3275+ (r"tb?", 1024 * 1024 * 1024 * 1024),
3276+ (r"hz", 1),
3277+ (r"khz?", 1024),
3278+ (r"mhz?", 1024 * 1024),
3279+ (r"ghz?", 1024 * 1024 * 1024),
3280+ (r"thz?", 1024 * 1024 * 1024 * 1024))
3281+TYPE_MULTIPLIERS = tuple(
3282+ (re.compile(r"^%s$" % pattern, re.IGNORECASE), multiplier)
3283+ for pattern, multiplier in TYPE_MULTIPLIERS)
3284+
3285+
3286+def datetime_to_string(dt):
3287+ """Return a consistent string representation for a given datetime.
3288+
3289+ :param dt: The datetime object.
3290+ """
3291+ return dt.isoformat()
3292+
3293+def string_to_datetime(string):
3294+ """Return a datetime object from a consistent string representation.
3295+
3296+ :param string: The string representation.
3297+ """
3298+ # we cannot use time.strptime: this function accepts neither fractions
3299+ # of a second nor a time zone given e.g. as '+02:30'.
3300+ match = DATETIME_RE.match(string)
3301+
3302+ # The Relax NG schema allows a leading minus sign and year numbers
3303+ # with more than four digits, which are not "covered" by _time_regex.
3304+ if not match:
3305+ raise ValueError("Datetime with unreasonable value: %s" % string)
3306+
3307+ time_parts = match.groupdict()
3308+
3309+ year = int(time_parts['year'])
3310+ month = int(time_parts['month'])
3311+ day = int(time_parts['day'])
3312+ hour = int(time_parts['hour'])
3313+ minute = int(time_parts['minute'])
3314+ second = int(time_parts['second'])
3315+ second_fraction = time_parts['second_fraction']
3316+ if second_fraction is not None:
3317+ milliseconds = second_fraction + '0' * (6 - len(second_fraction))
3318+ milliseconds = int(milliseconds)
3319+ else:
3320+ milliseconds = 0
3321+
3322+ # The Relax NG validator accepts leap seconds, but the datetime
3323+ # constructor rejects them. The time values submitted by the HWDB
3324+ # client are not necessarily very precise, hence we can round down
3325+ # to 59.999999 seconds without losing any real precision.
3326+ if second > 59:
3327+ second = 59
3328+ milliseconds = 999999
3329+
3330+ dt = datetime(
3331+ year, month, day, hour, minute, second, milliseconds,
3332+ tzinfo=tz.tzutc())
3333+
3334+ tz_sign = time_parts['tz_sign']
3335+ tz_hour = time_parts['tz_hour']
3336+ tz_minute = time_parts['tz_minute']
3337+ if tz_sign in ('-', '+'):
3338+ delta = timedelta(hours=int(tz_hour), minutes=int(tz_minute))
3339+ if tz_sign == '-':
3340+ dt = dt + delta
3341+ else:
3342+ dt = dt - delta
3343+
3344+ return dt
3345+
3346+def sizeof_bytes(bytes):
3347+ for x in ["bytes", "KB", "MB", "GB", "TB"]:
3348+ string = "%3.1f%s" % (bytes, x)
3349+ if bytes < 1024.0:
3350+ break
3351+ bytes /= 1024.0
3352+
3353+ return string
3354+
3355+def sizeof_hertz(hertz):
3356+ for x in ["Hz", "KHz", "MHz", "GHz"]:
3357+ string = "%3.1f%s" % (hertz, x)
3358+ if hertz < 1000.0:
3359+ break
3360+ hertz /= 1000.0
3361+
3362+ return string
3363+
3364+def string_to_type(string):
3365+ """Return a typed representation for the given string.
3366+
3367+ The result might be a bool, int or float. The string might also be
3368+ supplemented by a multiplier like KB which would return an int or
3369+ float multiplied by 1024 for example.
3370+
3371+ :param string: The string representation.
3372+ """
3373+ if isinstance(string, basestring):
3374+ for regex, formatter in TYPE_FORMATS:
3375+ match = regex.match(string)
3376+ if match:
3377+ string = formatter(match)
3378+ if len(match.groups()) > 1:
3379+ unit = match.group(2)
3380+ for regex, multiplier in TYPE_MULTIPLIERS:
3381+ match = regex.match(unit)
3382+ if match:
3383+ string *= multiplier
3384+ break
3385+ else:
3386+ raise ValueError("Unknown multiplier: %s" % unit)
3387+ break
3388+
3389+ return string
3390
3391=== added file 'checkbox/lib/decorator.py'
3392--- checkbox/lib/decorator.py 1970-01-01 00:00:00 +0000
3393+++ checkbox/lib/decorator.py 2012-03-28 20:34:20 +0000
3394@@ -0,0 +1,28 @@
3395+#
3396+# This file is part of Checkbox.
3397+#
3398+# Copyright 2008 Canonical Ltd.
3399+#
3400+# Checkbox is free software: you can redistribute it and/or modify
3401+# it under the terms of the GNU General Public License as published by
3402+# the Free Software Foundation, either version 3 of the License, or
3403+# (at your option) any later version.
3404+#
3405+# Checkbox is distributed in the hope that it will be useful,
3406+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3407+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3408+# GNU General Public License for more details.
3409+#
3410+# You should have received a copy of the GNU General Public License
3411+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3412+#
3413+def merge_function_metadata(original, new):
3414+ """Overwrite C{new}'s docstring and instance dictionary from C{original}.
3415+
3416+ This also sets an C{original_function} attribute on the new
3417+ function to C{original}. This is to allow code
3418+ introspect various things about the original function.
3419+ """
3420+ new.__doc__ = original.__doc__
3421+ new.__dict__.update(original.__dict__)
3422+ new.original_function = original
3423
3424=== added file 'checkbox/lib/dmi.py'
3425--- checkbox/lib/dmi.py 1970-01-01 00:00:00 +0000
3426+++ checkbox/lib/dmi.py 2012-03-28 20:34:20 +0000
3427@@ -0,0 +1,225 @@
3428+#
3429+# This file is part of Checkbox.
3430+#
3431+# Copyright 2008 Canonical Ltd.
3432+#
3433+# Checkbox is free software: you can redistribute it and/or modify
3434+# it under the terms of the GNU General Public License as published by
3435+# the Free Software Foundation, either version 3 of the License, or
3436+# (at your option) any later version.
3437+#
3438+# Checkbox is distributed in the hope that it will be useful,
3439+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3440+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3441+# GNU General Public License for more details.
3442+#
3443+# You should have received a copy of the GNU General Public License
3444+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3445+#
3446+import os
3447+
3448+
3449+# See also 3.3.4.1 of the "System Management BIOS Reference Specification,
3450+# Version 2.6.1" (Preliminary Standard) document, available from
3451+# http://www.dmtf.org/standards/smbios.
3452+class Dmi:
3453+ chassis = (
3454+ ("Undefined", "unknown"), # 0x00
3455+ ("Other", "unknown"),
3456+ ("Unknown", "unknown"),
3457+ ("Desktop", "desktop"),
3458+ ("Low Profile Desktop", "desktop"),
3459+ ("Pizza Box", "server"),
3460+ ("Mini Tower", "desktop"),
3461+ ("Tower", "desktop"),
3462+ ("Portable", "laptop"),
3463+ ("Laptop", "laptop"),
3464+ ("Notebook", "laptop"),
3465+ ("Hand Held", "handheld"),
3466+ ("Docking Station", "laptop"),
3467+ ("All In One", "unknown"),
3468+ ("Sub Notebook", "laptop"),
3469+ ("Space-saving", "desktop"),
3470+ ("Lunch Box", "unknown"),
3471+ ("Main Server Chassis", "server"),
3472+ ("Expansion Chassis", "unknown"),
3473+ ("Sub Chassis", "unknown"),
3474+ ("Bus Expansion Chassis", "unknown"),
3475+ ("Peripheral Chassis", "unknown"),
3476+ ("RAID Chassis", "unknown"),
3477+ ("Rack Mount Chassis", "unknown"),
3478+ ("Sealed-case PC", "unknown"),
3479+ ("Multi-system", "unknown"),
3480+ ("CompactPCI", "unknonw"),
3481+ ("AdvancedTCA", "unknown"),
3482+ ("Blade", "server"),
3483+ ("Blade Enclosure", "unknown"))
3484+
3485+ chassis_names = tuple(c[0] for c in chassis)
3486+ chassis_types = tuple(c[1] for c in chassis)
3487+ chassis_name_to_type = dict(chassis)
3488+
3489+ type_names = (
3490+ "BIOS", # 0x00
3491+ "System",
3492+ "Base Board",
3493+ "Chassis",
3494+ "Processor",
3495+ "Memory Controller",
3496+ "Memory Module",
3497+ "Cache",
3498+ "Port Connector",
3499+ "System Slots",
3500+ "On Board Devices",
3501+ "OEM Strings",
3502+ "System Configuration Options",
3503+ "BIOS Language",
3504+ "Group Associations",
3505+ "System Event Log",
3506+ "Physical Memory Array",
3507+ "Memory Device",
3508+ "32-bit Memory Error",
3509+ "Memory Array Mapped Address",
3510+ "Memory Device Mapped Address",
3511+ "Built-in Pointing Device",
3512+ "Portable Battery",
3513+ "System Reset",
3514+ "Hardware Security",
3515+ "System Power Controls",
3516+ "Voltage Probe",
3517+ "Cooling Device",
3518+ "Temperature Probe",
3519+ "Electrical Current Probe",
3520+ "Out-of-band Remote Access",
3521+ "Boot Integrity Services",
3522+ "System Boot",
3523+ "64-bit Memory Error",
3524+ "Management Device",
3525+ "Management Device Component",
3526+ "Management Device Threshold Data",
3527+ "Memory Channel",
3528+ "IPMI Device",
3529+ "Power Supply",
3530+ )
3531+
3532+
3533+class DmiDevice:
3534+
3535+ bus = "dmi"
3536+ driver = None
3537+ product_id = None
3538+ vendor_id = None
3539+
3540+ _product_blacklist = (
3541+ "<BAD INDEX>",
3542+ "N/A",
3543+ "Not Available",
3544+ "INVALID",
3545+ "OEM",
3546+ "Product Name",
3547+ "System Product Name",
3548+ "To be filled by O.E.M.",
3549+ "To Be Filled By O.E.M.",
3550+ "To Be Filled By O.E.M. by More String",
3551+ "Unknown",
3552+ "Uknown",
3553+ "Unknow",
3554+ "xxxxxxxxxxxxxx",
3555+ )
3556+ _vendor_blacklist = (
3557+ "<BAD INDEX>",
3558+ "Not Available",
3559+ "OEM",
3560+ "OEM Manufacturer",
3561+ "System manufacturer",
3562+ "System Manufacturer",
3563+ "System Name",
3564+ "To be filled by O.E.M.",
3565+ "To Be Filled By O.E.M.",
3566+ "To Be Filled By O.E.M. by More String",
3567+ "Unknow", # XXX This is correct mispelling
3568+ "Unknown",
3569+ )
3570+ _serial_blacklist = (
3571+ "0",
3572+ "00000000",
3573+ "00 00 00 00 00 00 00 00",
3574+ "0123456789",
3575+ "Base Board Serial Number",
3576+ "Chassis Serial Number",
3577+ "N/A",
3578+ "None",
3579+ "Not Applicable",
3580+ "Not Available",
3581+ "Not Specified",
3582+ "OEM",
3583+ "System Serial Number",
3584+ )
3585+ _version_blacklist = (
3586+ "-1",
3587+ "<BAD INDEX>",
3588+ "N/A",
3589+ "None",
3590+ "Not Applicable",
3591+ "Not Available",
3592+ "Not Specified",
3593+ "OEM",
3594+ "System Version",
3595+ "Unknown",
3596+ "x.x",
3597+ )
3598+
3599+ def __init__(self, attributes, category):
3600+ self._attributes = attributes
3601+ self.category = category
3602+
3603+ @property
3604+ def path(self):
3605+ path = "/devices/virtual/dmi/id"
3606+ return os.path.join(path, self.category.lower())
3607+
3608+ @property
3609+ def product(self):
3610+ if self.category == "CHASSIS":
3611+ type_string = self._attributes.get("chassis_type", "0")
3612+ try:
3613+ type_index = int(type_string)
3614+ return Dmi.chassis_names[type_index]
3615+ except ValueError:
3616+ return type_string
3617+
3618+ for name in "name", "version":
3619+ attribute = "%s_%s" % (self.category.lower(), name)
3620+ product = self._attributes.get(attribute)
3621+ if product and product not in self._product_blacklist:
3622+ return product
3623+
3624+ return None
3625+
3626+ @property
3627+ def vendor(self):
3628+ for name in "manufacturer", "vendor":
3629+ attribute = "%s_%s" % (self.category.lower(), name)
3630+ vendor = self._attributes.get(attribute)
3631+ if vendor and vendor not in self._vendor_blacklist:
3632+ return vendor
3633+
3634+ return None
3635+
3636+ @property
3637+ def serial(self):
3638+ attribute = "%s_serial" % self.category.lower()
3639+ serial = self._attributes.get(attribute)
3640+ if serial and serial not in self._serial_blacklist:
3641+ return serial
3642+
3643+ return None
3644+
3645+ @property
3646+ def version(self):
3647+ attribute = "%s_version" % self.category.lower()
3648+ version = self._attributes.get(attribute)
3649+ if version and version not in self._version_blacklist:
3650+ return version
3651+
3652+ return None
3653
3654=== added file 'checkbox/lib/enum.py'
3655--- checkbox/lib/enum.py 1970-01-01 00:00:00 +0000
3656+++ checkbox/lib/enum.py 2012-03-28 20:34:20 +0000
3657@@ -0,0 +1,72 @@
3658+#
3659+# This file is part of Checkbox.
3660+#
3661+# Copyright 2011 Canonical Ltd.
3662+#
3663+# Checkbox is free software: you can redistribute it and/or modify
3664+# it under the terms of the GNU General Public License as published by
3665+# the Free Software Foundation, either version 3 of the License, or
3666+# (at your option) any later version.
3667+#
3668+# Checkbox is distributed in the hope that it will be useful,
3669+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3670+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3671+# GNU General Public License for more details.
3672+#
3673+# You should have received a copy of the GNU General Public License
3674+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3675+#
3676+__all__ = [
3677+ "EnumException", "Enum", "enum_name_to_value", "enum_value_to_name"]
3678+
3679+
3680+class EnumException(Exception):
3681+
3682+ pass
3683+
3684+
3685+class Enum(object):
3686+
3687+ def __init__(self, *names):
3688+ value = 0
3689+ unique_names = set()
3690+ for name in names:
3691+ if isinstance(name, (list, tuple)):
3692+ name, value = name
3693+
3694+ if not isinstance(name, str):
3695+ raise EnumException(
3696+ "enum name is not a string: %s" % name)
3697+
3698+ if isinstance(value, str):
3699+ if value not in unique_names:
3700+ raise EnumException(
3701+ "enum value does not define: %s" % value)
3702+ value = getattr(self, value)
3703+
3704+ if not isinstance(value, (int, long)):
3705+ raise EnumException(
3706+ "enum value is not an integer: %s" % value)
3707+
3708+ if name in unique_names:
3709+ raise EnumException(
3710+ "enum name is not unique: %s" % name)
3711+
3712+ unique_names.add(name)
3713+ setattr(self, name, value)
3714+ value += 1
3715+
3716+
3717+def enum_name_to_value(enum, name):
3718+ if not hasattr(enum, name):
3719+ raise EnumException("enum name unknown: %s" % name)
3720+
3721+ return getattr(enum, name)
3722+
3723+
3724+def enum_value_to_name(enum, value):
3725+ for k, v in enum.__dict__.items():
3726+ if v == value:
3727+ return k
3728+
3729+ raise EnumException("enum value unknown: %s" % value)
3730
3731=== added file 'checkbox/lib/environ.py'
3732--- checkbox/lib/environ.py 1970-01-01 00:00:00 +0000
3733+++ checkbox/lib/environ.py 2012-03-28 20:34:20 +0000
3734@@ -0,0 +1,113 @@
3735+#
3736+# This file is part of Checkbox.
3737+#
3738+# Copyright 2008 Canonical Ltd.
3739+#
3740+# Checkbox is free software: you can redistribute it and/or modify
3741+# it under the terms of the GNU General Public License as published by
3742+# the Free Software Foundation, either version 3 of the License, or
3743+# (at your option) any later version.
3744+#
3745+# Checkbox is distributed in the hope that it will be useful,
3746+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3747+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3748+# GNU General Public License for more details.
3749+#
3750+# You should have received a copy of the GNU General Public License
3751+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3752+#
3753+import os
3754+import posixpath
3755+
3756+from os import environ
3757+from stat import ST_MODE, S_IEXEC
3758+
3759+
3760+def get_variables():
3761+ return dict(environ)
3762+
3763+def get_variable(name, default=None):
3764+ """Get the value of an environment variable name.
3765+
3766+ Keyword arguments:
3767+ name -- name of the environment variable
3768+ """
3769+
3770+ return environ.get(name, default)
3771+
3772+def add_variable(name, value):
3773+ """Add or change the value of an environment variable name.
3774+
3775+ Keyword arguments:
3776+ name -- name of the environment variable
3777+ value -- value given to the environment variable
3778+ """
3779+
3780+ if value is not None:
3781+ environ[name] = value
3782+
3783+def remove_variable(name):
3784+ """Remove an environment variable name.
3785+
3786+ Keyword arguments:
3787+ name -- name of the environment variable
3788+ """
3789+
3790+ if name in environ:
3791+ del environ[name]
3792+
3793+def get_paths():
3794+ paths = []
3795+ if "PATH" in environ:
3796+ paths = environ["PATH"].split(":")
3797+
3798+ return paths
3799+
3800+def get_path(command):
3801+ for path in get_paths():
3802+ absolute = posixpath.join(path, command)
3803+ if posixpath.exists(absolute):
3804+ mode = os.stat(absolute)[ST_MODE]
3805+ if mode & S_IEXEC:
3806+ return absolute
3807+
3808+ return None
3809+
3810+def append_path(path):
3811+ """Prepend a path to the PATH environment variable if it doesn't
3812+ exist already.
3813+
3814+ Keyword arguments:
3815+ path -- path to add
3816+ """
3817+
3818+ environ_path = get_paths()
3819+ if path not in environ_path:
3820+ environ_path.append(path)
3821+ environ["PATH"] = ":".join(environ_path)
3822+
3823+def prepend_path(path):
3824+ """Prepend a path to the PATH environment variable if it doesn't
3825+ exist already.
3826+
3827+ Keyword arguments:
3828+ path -- path to add
3829+ """
3830+
3831+ environ_path = get_paths()
3832+ if path not in environ_path:
3833+ environ_path.insert(0, path)
3834+ environ["PATH"] = ":".join(environ_path)
3835+
3836+def remove_path(path):
3837+ """Remove a path from the PATH environment variable if it exists
3838+ already.
3839+
3840+ Keyword arguments:
3841+ path -- path to remove
3842+ """
3843+
3844+ environ_path = get_paths()
3845+ if path in environ_path:
3846+ environ_path.remove(path)
3847+ environ["PATH"] = ":".join(environ_path)
3848
3849=== added file 'checkbox/lib/fifo.py'
3850--- checkbox/lib/fifo.py 1970-01-01 00:00:00 +0000
3851+++ checkbox/lib/fifo.py 2012-03-28 20:34:20 +0000
3852@@ -0,0 +1,105 @@
3853+#
3854+# This file is part of Checkbox.
3855+#
3856+# Copyright 2010 Canonical Ltd.
3857+#
3858+# Checkbox is free software: you can redistribute it and/or modify
3859+# it under the terms of the GNU General Public License as published by
3860+# the Free Software Foundation, either version 3 of the License, or
3861+# (at your option) any later version.
3862+#
3863+# Checkbox is distributed in the hope that it will be useful,
3864+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3865+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3866+# GNU General Public License for more details.
3867+#
3868+# You should have received a copy of the GNU General Public License
3869+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3870+#
3871+import os
3872+import struct
3873+
3874+from checkbox.contrib.bpickle import dumps, loads
3875+from checkbox.lib.selector import Selector, SelectorIO
3876+
3877+class FifoBase(object):
3878+
3879+ mode = None
3880+
3881+ def __init__(self, path, timeout=None):
3882+ self.path = path
3883+ self.file = open(path, self.mode)
3884+ self._timeout = timeout
3885+
3886+ def __del__(self):
3887+ self.close()
3888+
3889+ def close(self):
3890+ self.file.close()
3891+
3892+ def wait_for(self, operation):
3893+ if self._timeout is not None:
3894+ selector = Selector()
3895+ selector.set_timeout(self._timeout)
3896+ selector.add_fd(self.file.fileno(), operation)
3897+
3898+ selector.execute()
3899+
3900+ if not selector.has_ready():
3901+ return False
3902+ return True
3903+
3904+class FifoReader(FifoBase):
3905+
3906+ #on Linux, opening a FIFO in read-write mode is non-blocking and
3907+ #succeeds even if other end is not open as per FIFO(7)
3908+ mode = "w+"
3909+
3910+ def read_string(self):
3911+ # Check if a connection arrived within the timeout
3912+ if not self.wait_for(SelectorIO.READ):
3913+ return None
3914+
3915+ size = struct.calcsize("i")
3916+ length_string = self.file.read(size)
3917+ if not length_string:
3918+ return ""
3919+
3920+ length = struct.unpack(">i", length_string)[0]
3921+ return self.file.read(length)
3922+
3923+ def read_object(self):
3924+ string = self.read_string()
3925+ if not string:
3926+ return None
3927+
3928+ return loads(string)
3929+
3930+
3931+class FifoWriter(FifoBase):
3932+
3933+ #on Linux, opening a FIFO in read-write mode is non-blocking and
3934+ #succeeds even if other end is not open as per FIFO(7)
3935+ mode = "w+"
3936+
3937+ def write_string(self, string):
3938+
3939+ # Wait until I can write
3940+ if not self.wait_for(SelectorIO.WRITE):
3941+ return None
3942+
3943+ length = len(string)
3944+ length_string = struct.pack(">i", length)
3945+ self.file.write(length_string)
3946+ self.file.write(string)
3947+ self.file.flush()
3948+ return length
3949+
3950+ def write_object(self, object):
3951+ string = dumps(object)
3952+ return self.write_string(string)
3953+
3954+
3955+def create_fifo(path, mode=0666):
3956+ os.mkfifo(path, mode)
3957+ return path
3958
3959=== added file 'checkbox/lib/input.py'
3960--- checkbox/lib/input.py 1970-01-01 00:00:00 +0000
3961+++ checkbox/lib/input.py 2012-03-28 20:34:20 +0000
3962@@ -0,0 +1,585 @@
3963+#
3964+# This file is part of Checkbox.
3965+#
3966+# Copyright 2008 Canonical Ltd.
3967+#
3968+# Checkbox is free software: you can redistribute it and/or modify
3969+# it under the terms of the GNU General Public License as published by
3970+# the Free Software Foundation, either version 3 of the License, or
3971+# (at your option) any later version.
3972+#
3973+# Checkbox is distributed in the hope that it will be useful,
3974+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3975+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3976+# GNU General Public License for more details.
3977+#
3978+# You should have received a copy of the GNU General Public License
3979+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
3980+#
3981+
3982+# See linux/input.h
3983+class Input:
3984+ KEY_RESERVED = 0
3985+ KEY_ESC = 1
3986+ KEY_1 = 2
3987+ KEY_2 = 3
3988+ KEY_3 = 4
3989+ KEY_4 = 5
3990+ KEY_5 = 6
3991+ KEY_6 = 7
3992+ KEY_7 = 8
3993+ KEY_8 = 9
3994+ KEY_9 = 10
3995+ KEY_0 = 11
3996+ KEY_MINUS = 12
3997+ KEY_EQUAL = 13
3998+ KEY_BACKSPACE = 14
3999+ KEY_TAB = 15
4000+ KEY_Q = 16
4001+ KEY_W = 17
4002+ KEY_E = 18
4003+ KEY_R = 19
4004+ KEY_T = 20
4005+ KEY_Y = 21
4006+ KEY_U = 22
4007+ KEY_I = 23
4008+ KEY_O = 24
4009+ KEY_P = 25
4010+ KEY_LEFTBRACE = 26
4011+ KEY_RIGHTBRACE = 27
4012+ KEY_ENTER = 28
4013+ KEY_LEFTCTRL = 29
4014+ KEY_A = 30
4015+ KEY_S = 31
4016+ KEY_D = 32
4017+ KEY_F = 33
4018+ KEY_G = 34
4019+ KEY_H = 35
4020+ KEY_J = 36
4021+ KEY_K = 37
4022+ KEY_L = 38
4023+ KEY_SEMICOLON = 39
4024+ KEY_APOSTROPHE = 40
4025+ KEY_GRAVE = 41
4026+ KEY_LEFTSHIFT = 42
4027+ KEY_BACKSLASH = 43
4028+ KEY_Z = 44
4029+ KEY_X = 45
4030+ KEY_C = 46
4031+ KEY_V = 47
4032+ KEY_B = 48
4033+ KEY_N = 49
4034+ KEY_M = 50
4035+ KEY_COMMA = 51
4036+ KEY_DOT = 52
4037+ KEY_SLASH = 53
4038+ KEY_RIGHTSHIFT = 54
4039+ KEY_KPASTERISK = 55
4040+ KEY_LEFTALT = 56
4041+ KEY_SPACE = 57
4042+ KEY_CAPSLOCK = 58
4043+ KEY_F1 = 59
4044+ KEY_F2 = 60
4045+ KEY_F3 = 61
4046+ KEY_F4 = 62
4047+ KEY_F5 = 63
4048+ KEY_F6 = 64
4049+ KEY_F7 = 65
4050+ KEY_F8 = 66
4051+ KEY_F9 = 67
4052+ KEY_F10 = 68
4053+ KEY_NUMLOCK = 69
4054+ KEY_SCROLLLOCK = 70
4055+ KEY_KP7 = 71
4056+ KEY_KP8 = 72
4057+ KEY_KP9 = 73
4058+ KEY_KPMINUS = 74
4059+ KEY_KP4 = 75
4060+ KEY_KP5 = 76
4061+ KEY_KP6 = 77
4062+ KEY_KPPLUS = 78
4063+ KEY_KP1 = 79
4064+ KEY_KP2 = 80
4065+ KEY_KP3 = 81
4066+ KEY_KP0 = 82
4067+ KEY_KPDOT = 83
4068+
4069+ KEY_ZENKAKUHANKAKU = 85
4070+ KEY_102ND = 86
4071+ KEY_F11 = 87
4072+ KEY_F12 = 88
4073+ KEY_RO = 89
4074+ KEY_KATAKANA = 90
4075+ KEY_HIRAGANA = 91
4076+ KEY_HENKAN = 92
4077+ KEY_KATAKANAHIRAGANA = 93
4078+ KEY_MUHENKAN = 94
4079+ KEY_KPJPCOMMA = 95
4080+ KEY_KPENTER = 96
4081+ KEY_RIGHTCTRL = 97
4082+ KEY_KPSLASH = 98
4083+ KEY_SYSRQ = 99
4084+ KEY_RIGHTALT = 100
4085+ KEY_LINEFEED = 101
4086+ KEY_HOME = 102
4087+ KEY_UP = 103
4088+ KEY_PAGEUP = 104
4089+ KEY_LEFT = 105
4090+ KEY_RIGHT = 106
4091+ KEY_END = 107
4092+ KEY_DOWN = 108
4093+ KEY_PAGEDOWN = 109
4094+ KEY_INSERT = 110
4095+ KEY_DELETE = 111
4096+ KEY_MACRO = 112
4097+ KEY_MUTE = 113
4098+ KEY_VOLUMEDOWN = 114
4099+ KEY_VOLUMEUP = 115
4100+ KEY_POWER = 116 # SC System Power Down
4101+ KEY_KPEQUAL = 117
4102+ KEY_KPPLUSMINUS = 118
4103+ KEY_PAUSE = 119
4104+ KEY_SCALE = 120 # AL Compiz Scale (Expose)
4105+
4106+ KEY_KPCOMMA = 121
4107+ KEY_HANGEUL = 122
4108+ KEY_HANGUEL = KEY_HANGEUL
4109+ KEY_HANJA = 123
4110+ KEY_YEN = 124
4111+ KEY_LEFTMETA = 125
4112+ KEY_RIGHTMETA = 126
4113+ KEY_COMPOSE = 127
4114+
4115+ KEY_STOP = 128 # AC Stop
4116+ KEY_AGAIN = 129
4117+ KEY_PROPS = 130 # AC Properties
4118+ KEY_UNDO = 131 # AC Undo
4119+ KEY_FRONT = 132
4120+ KEY_COPY = 133 # AC Copy
4121+ KEY_OPEN = 134 # AC Open
4122+ KEY_PASTE = 135 # AC Paste
4123+ KEY_FIND = 136 # AC Search
4124+ KEY_CUT = 137 # AC Cut
4125+ KEY_HELP = 138 # AL Integrated Help Center
4126+ KEY_MENU = 139 # Menu (show menu)
4127+ KEY_CALC = 140 # AL Calculator
4128+ KEY_SETUP = 141
4129+ KEY_SLEEP = 142 # SC System Sleep
4130+ KEY_WAKEUP = 143 # System Wake Up
4131+ KEY_FILE = 144 # AL Local Machine Browser
4132+ KEY_SENDFILE = 145
4133+ KEY_DELETEFILE = 146
4134+ KEY_XFER = 147
4135+ KEY_PROG1 = 148
4136+ KEY_PROG2 = 149
4137+ KEY_WWW = 150 # AL Internet Browser
4138+ KEY_MSDOS = 151
4139+ KEY_COFFEE = 152 # AL Terminal Lock/Screensaver
4140+ KEY_SCREENLOCK = KEY_COFFEE
4141+ KEY_DIRECTION = 153
4142+ KEY_CYCLEWINDOWS = 154
4143+ KEY_MAIL = 155
4144+ KEY_BOOKMARKS = 156 # AC Bookmarks
4145+ KEY_COMPUTER = 157
4146+ KEY_BACK = 158 # AC Back
4147+ KEY_FORWARD = 159 # AC Forward
4148+ KEY_CLOSECD = 160
4149+ KEY_EJECTCD = 161
4150+ KEY_EJECTCLOSECD = 162
4151+ KEY_NEXTSONG = 163
4152+ KEY_PLAYPAUSE = 164
4153+ KEY_PREVIOUSSONG = 165
4154+ KEY_STOPCD = 166
4155+ KEY_RECORD = 167
4156+ KEY_REWIND = 168
4157+ KEY_PHONE = 169 # Media Select Telephone
4158+ KEY_ISO = 170
4159+ KEY_CONFIG = 171 # AL Consumer Control Configuration
4160+ KEY_HOMEPAGE = 172 # AC Home
4161+ KEY_REFRESH = 173 # AC Refresh
4162+ KEY_EXIT = 174 # AC Exit
4163+ KEY_MOVE = 175
4164+ KEY_EDIT = 176
4165+ KEY_SCROLLUP = 177
4166+ KEY_SCROLLDOWN = 178
4167+ KEY_KPLEFTPAREN = 179
4168+ KEY_KPRIGHTPAREN = 180
4169+ KEY_NEW = 181 # AC New
4170+ KEY_REDO = 182 # AC Redo/Repeat
4171+
4172+ KEY_F13 = 183
4173+ KEY_F14 = 184
4174+ KEY_F15 = 185
4175+ KEY_F16 = 186
4176+ KEY_F17 = 187
4177+ KEY_F18 = 188
4178+ KEY_F19 = 189
4179+ KEY_F20 = 190
4180+ KEY_F21 = 191
4181+ KEY_F22 = 192
4182+ KEY_F23 = 193
4183+ KEY_F24 = 194
4184+
4185+ KEY_PLAYCD = 200
4186+ KEY_PAUSECD = 201
4187+ KEY_PROG3 = 202
4188+ KEY_PROG4 = 203
4189+ KEY_DASHBOARD = 204 # AL Dashboard
4190+ KEY_SUSPEND = 205
4191+ KEY_CLOSE = 206 # AC Close
4192+ KEY_PLAY = 207
4193+ KEY_FASTFORWARD = 208
4194+ KEY_BASSBOOST = 209
4195+ KEY_PRINT = 210 # AC Print
4196+ KEY_HP = 211
4197+ KEY_CAMERA = 212
4198+ KEY_SOUND = 213
4199+ KEY_QUESTION = 214
4200+ KEY_EMAIL = 215
4201+ KEY_CHAT = 216
4202+ KEY_SEARCH = 217
4203+ KEY_CONNECT = 218
4204+ KEY_FINANCE = 219 # AL Checkbook/Finance
4205+ KEY_SPORT = 220
4206+ KEY_SHOP = 221
4207+ KEY_ALTERASE = 222
4208+ KEY_CANCEL = 223 # AC Cancel
4209+ KEY_BRIGHTNESSDOWN = 224
4210+ KEY_BRIGHTNESSUP = 225
4211+ KEY_MEDIA = 226
4212+
4213+ KEY_SWITCHVIDEOMODE = 227 # Cycle between available video
4214+ # outputs (Monitor/LCD/TV-out/etc)
4215+ KEY_KBDILLUMTOGGLE = 228
4216+ KEY_KBDILLUMDOWN = 229
4217+ KEY_KBDILLUMUP = 230
4218+
4219+ KEY_SEND = 231 # AC Send
4220+ KEY_REPLY = 232 # AC Reply
4221+ KEY_FORWARDMAIL = 233 # AC Forward Msg
4222+ KEY_SAVE = 234 # AC Save
4223+ KEY_DOCUMENTS = 235
4224+
4225+ KEY_BATTERY = 236
4226+
4227+ KEY_BLUETOOTH = 237
4228+ KEY_WLAN = 238
4229+ KEY_UWB = 239
4230+
4231+ KEY_UNKNOWN = 240
4232+
4233+ KEY_VIDEO_NEXT = 241 # drive next video source
4234+ KEY_VIDEO_PREV = 242 # drive previous video source
4235+ KEY_BRIGHTNESS_CYCLE = 243 # brightness up, after max is min
4236+ KEY_BRIGHTNESS_ZERO = 244 # brightness off, use ambient
4237+ KEY_DISPLAY_OFF = 245 # display device to off state
4238+
4239+ KEY_WIMAX = 246
4240+
4241+ # Range = 248 - 255 is reserved for special needs of AT keyboard driver
4242+
4243+ BTN_MISC = 0x100
4244+ BTN_0 = 0x100
4245+ BTN_1 = 0x101
4246+ BTN_2 = 0x102
4247+ BTN_3 = 0x103
4248+ BTN_4 = 0x104
4249+ BTN_5 = 0x105
4250+ BTN_6 = 0x106
4251+ BTN_7 = 0x107
4252+ BTN_8 = 0x108
4253+ BTN_9 = 0x109
4254+
4255+ BTN_MOUSE = 0x110
4256+ BTN_LEFT = 0x110
4257+ BTN_RIGHT = 0x111
4258+ BTN_MIDDLE = 0x112
4259+ BTN_SIDE = 0x113
4260+ BTN_EXTRA = 0x114
4261+ BTN_FORWARD = 0x115
4262+ BTN_BACK = 0x116
4263+ BTN_TASK = 0x117
4264+
4265+ BTN_JOYSTICK = 0x120
4266+ BTN_TRIGGER = 0x120
4267+ BTN_THUMB = 0x121
4268+ BTN_THUMB2 = 0x122
4269+ BTN_TOP = 0x123
4270+ BTN_TOP2 = 0x124
4271+ BTN_PINKIE = 0x125
4272+ BTN_BASE = 0x126
4273+ BTN_BASE2 = 0x127
4274+ BTN_BASE3 = 0x128
4275+ BTN_BASE4 = 0x129
4276+ BTN_BASE5 = 0x12a
4277+ BTN_BASE6 = 0x12b
4278+ BTN_DEAD = 0x12f
4279+
4280+ BTN_GAMEPAD = 0x130
4281+ BTN_A = 0x130
4282+ BTN_B = 0x131
4283+ BTN_C = 0x132
4284+ BTN_X = 0x133
4285+ BTN_Y = 0x134
4286+ BTN_Z = 0x135
4287+ BTN_TL = 0x136
4288+ BTN_TR = 0x137
4289+ BTN_TL2 = 0x138
4290+ BTN_TR2 = 0x139
4291+ BTN_SELECT = 0x13a
4292+ BTN_START = 0x13b
4293+ BTN_MODE = 0x13c
4294+ BTN_THUMBL = 0x13d
4295+ BTN_THUMBR = 0x13e
4296+
4297+ BTN_DIGI = 0x140
4298+ BTN_TOOL_PEN = 0x140
4299+ BTN_TOOL_RUBBER = 0x141
4300+ BTN_TOOL_BRUSH = 0x142
4301+ BTN_TOOL_PENCIL = 0x143
4302+ BTN_TOOL_AIRBRUSH = 0x144
4303+ BTN_TOOL_FINGER = 0x145
4304+ BTN_TOOL_MOUSE = 0x146
4305+ BTN_TOOL_LENS = 0x147
4306+ BTN_TOUCH = 0x14a
4307+ BTN_STYLUS = 0x14b
4308+ BTN_STYLUS2 = 0x14c
4309+ BTN_TOOL_DOUBLETAP = 0x14d
4310+ BTN_TOOL_TRIPLETAP = 0x14e
4311+
4312+ BTN_WHEEL = 0x150
4313+ BTN_GEAR_DOWN = 0x150
4314+ BTN_GEAR_UP = 0x151
4315+
4316+ KEY_OK = 0x160
4317+ KEY_SELECT = 0x161
4318+ KEY_GOTO = 0x162
4319+ KEY_CLEAR = 0x163
4320+ KEY_POWER2 = 0x164
4321+ KEY_OPTION = 0x165
4322+ KEY_INFO = 0x166 # AL OEM Features/Tips/Tutorial
4323+ KEY_TIME = 0x167
4324+ KEY_VENDOR = 0x168
4325+ KEY_ARCHIVE = 0x169
4326+ KEY_PROGRAM = 0x16a # Media Select Program Guide
4327+ KEY_CHANNEL = 0x16b
4328+ KEY_FAVORITES = 0x16c
4329+ KEY_EPG = 0x16d
4330+ KEY_PVR = 0x16e # Media Select Home
4331+ KEY_MHP = 0x16f
4332+ KEY_LANGUAGE = 0x170
4333+ KEY_TITLE = 0x171
4334+ KEY_SUBTITLE = 0x172
4335+ KEY_ANGLE = 0x173
4336+ KEY_ZOOM = 0x174
4337+ KEY_MODE = 0x175
4338+ KEY_KEYBOARD = 0x176
4339+ KEY_SCREEN = 0x177
4340+ KEY_PC = 0x178 # Media Select Computer
4341+ KEY_TV = 0x179 # Media Select TV
4342+ KEY_TV2 = 0x17a # Media Select Cable
4343+ KEY_VCR = 0x17b # Media Select VCR
4344+ KEY_VCR2 = 0x17c # VCR Plus
4345+ KEY_SAT = 0x17d # Media Select Satellite
4346+ KEY_SAT2 = 0x17e
4347+ KEY_CD = 0x17f # Media Select CD
4348+ KEY_TAPE = 0x180 # Media Select Tape
4349+ KEY_RADIO = 0x181
4350+ KEY_TUNER = 0x182 # Media Select Tuner
4351+ KEY_PLAYER = 0x183
4352+ KEY_TEXT = 0x184
4353+ KEY_DVD = 0x185 # Media Select DVD
4354+ KEY_AUX = 0x186
4355+ KEY_MP3 = 0x187
4356+ KEY_AUDIO = 0x188
4357+ KEY_VIDEO = 0x189
4358+ KEY_DIRECTORY = 0x18a
4359+ KEY_LIST = 0x18b
4360+ KEY_MEMO = 0x18c # Media Select Messages
4361+ KEY_CALENDAR = 0x18d
4362+ KEY_RED = 0x18e
4363+ KEY_GREEN = 0x18f
4364+ KEY_YELLOW = 0x190
4365+ KEY_BLUE = 0x191
4366+ KEY_CHANNELUP = 0x192 # Channel Increment
4367+ KEY_CHANNELDOWN = 0x193 # Channel Decrement
4368+ KEY_FIRST = 0x194
4369+ KEY_LAST = 0x195 # Recall Last
4370+ KEY_AB = 0x196
4371+ KEY_NEXT = 0x197
4372+ KEY_RESTART = 0x198
4373+ KEY_SLOW = 0x199
4374+ KEY_SHUFFLE = 0x19a
4375+ KEY_BREAK = 0x19b
4376+ KEY_PREVIOUS = 0x19c
4377+ KEY_DIGITS = 0x19d
4378+ KEY_TEEN = 0x19e
4379+ KEY_TWEN = 0x19f
4380+ KEY_VIDEOPHONE = 0x1a0 # Media Select Video Phone
4381+ KEY_GAMES = 0x1a1 # Media Select Games
4382+ KEY_ZOOMIN = 0x1a2 # AC Zoom In
4383+ KEY_ZOOMOUT = 0x1a3 # AC Zoom Out
4384+ KEY_ZOOMRESET = 0x1a4 # AC Zoom
4385+ KEY_WORDPROCESSOR = 0x1a5 # AL Word Processor
4386+ KEY_EDITOR = 0x1a6 # AL Text Editor
4387+ KEY_SPREADSHEET = 0x1a7 # AL Spreadsheet
4388+ KEY_GRAPHICSEDITOR = 0x1a8 # AL Graphics Editor
4389+ KEY_PRESENTATION = 0x1a9 # AL Presentation App
4390+ KEY_DATABASE = 0x1aa # AL Database App
4391+ KEY_NEWS = 0x1ab # AL Newsreader
4392+ KEY_VOICEMAIL = 0x1ac # AL Voicemail
4393+ KEY_ADDRESSBOOK = 0x1ad # AL Contacts/Address Book
4394+ KEY_MESSENGER = 0x1ae # AL Instant Messaging
4395+ KEY_DISPLAYTOGGLE = 0x1af # Turn display (LCD) on and off
4396+ KEY_SPELLCHECK = 0x1b0 # AL Spell Check
4397+ KEY_LOGOFF = 0x1b1 # AL Logoff
4398+
4399+ KEY_DOLLAR = 0x1b2
4400+ KEY_EURO = 0x1b3
4401+
4402+ KEY_FRAMEBACK = 0x1b4 # Consumer - transport controls
4403+ KEY_FRAMEFORWARD = 0x1b5
4404+ KEY_CONTEXT_MENU = 0x1b6 # GenDesc - system context menu
4405+ KEY_MEDIA_REPEAT = 0x1b7 # Consumer - transport control
4406+
4407+ KEY_DEL_EOL = 0x1c0
4408+ KEY_DEL_EOS = 0x1c1
4409+ KEY_INS_LINE = 0x1c2
4410+ KEY_DEL_LINE = 0x1c3
4411+
4412+ KEY_FN = 0x1d0
4413+ KEY_FN_ESC = 0x1d1
4414+ KEY_FN_F1 = 0x1d2
4415+ KEY_FN_F2 = 0x1d3
4416+ KEY_FN_F3 = 0x1d4
4417+ KEY_FN_F4 = 0x1d5
4418+ KEY_FN_F5 = 0x1d6
4419+ KEY_FN_F6 = 0x1d7
4420+ KEY_FN_F7 = 0x1d8
4421+ KEY_FN_F8 = 0x1d9
4422+ KEY_FN_F9 = 0x1da
4423+ KEY_FN_F10 = 0x1db
4424+ KEY_FN_F11 = 0x1dc
4425+ KEY_FN_F12 = 0x1dd
4426+ KEY_FN_1 = 0x1de
4427+ KEY_FN_2 = 0x1df
4428+ KEY_FN_D = 0x1e0
4429+ KEY_FN_E = 0x1e1
4430+ KEY_FN_F = 0x1e2
4431+ KEY_FN_S = 0x1e3
4432+ KEY_FN_B = 0x1e4
4433+
4434+ KEY_BRL_DOT1 = 0x1f1
4435+ KEY_BRL_DOT2 = 0x1f2
4436+ KEY_BRL_DOT3 = 0x1f3
4437+ KEY_BRL_DOT4 = 0x1f4
4438+ KEY_BRL_DOT5 = 0x1f5
4439+ KEY_BRL_DOT6 = 0x1f6
4440+ KEY_BRL_DOT7 = 0x1f7
4441+ KEY_BRL_DOT8 = 0x1f8
4442+ KEY_BRL_DOT9 = 0x1f9
4443+ KEY_BRL_DOT10 = 0x1fa
4444+
4445+ KEY_NUMERIC_0 = 0x200 # used by phones, remote controls,
4446+ KEY_NUMERIC_1 = 0x201 # and other keypads
4447+ KEY_NUMERIC_2 = 0x202
4448+ KEY_NUMERIC_3 = 0x203
4449+ KEY_NUMERIC_4 = 0x204
4450+ KEY_NUMERIC_5 = 0x205
4451+ KEY_NUMERIC_6 = 0x206
4452+ KEY_NUMERIC_7 = 0x207
4453+ KEY_NUMERIC_8 = 0x208
4454+ KEY_NUMERIC_9 = 0x209
4455+ KEY_NUMERIC_STAR = 0x20a
4456+ KEY_NUMERIC_POUND = 0x20b
4457+
4458+ # Relative axes
4459+
4460+ REL_X = 0x00
4461+ REL_Y = 0x01
4462+ REL_Z = 0x02
4463+ REL_RX = 0x03
4464+ REL_RY = 0x04
4465+ REL_RZ = 0x05
4466+ REL_HWHEEL = 0x06
4467+ REL_DIAL = 0x07
4468+ REL_WHEEL = 0x08
4469+ REL_MISC = 0x09
4470+ REL_MAX = 0x0f
4471+ REL_CNT = REL_MAX+1
4472+
4473+ # Absolute axes
4474+
4475+ ABS_X = 0x00
4476+ ABS_Y = 0x01
4477+ ABS_Z = 0x02
4478+ ABS_RX = 0x03
4479+ ABS_RY = 0x04
4480+ ABS_RZ = 0x05
4481+ ABS_THROTTLE = 0x06
4482+ ABS_RUDDER = 0x07
4483+ ABS_WHEEL = 0x08
4484+ ABS_GAS = 0x09
4485+ ABS_BRAKE = 0x0a
4486+ ABS_HAT0X = 0x10
4487+ ABS_HAT0Y = 0x11
4488+ ABS_HAT1X = 0x12
4489+ ABS_HAT1Y = 0x13
4490+ ABS_HAT2X = 0x14
4491+ ABS_HAT2Y = 0x15
4492+ ABS_HAT3X = 0x16
4493+ ABS_HAT3Y = 0x17
4494+ ABS_PRESSURE = 0x18
4495+ ABS_DISTANCE = 0x19
4496+ ABS_TILT_X = 0x1a
4497+ ABS_TILT_Y = 0x1b
4498+ ABS_TOOL_WIDTH = 0x1c
4499+ ABS_VOLUME = 0x20
4500+ ABS_MISC = 0x28
4501+ ABS_MAX = 0x3f
4502+ ABS_CNT = ABS_MAX+1
4503+
4504+ # Switch events
4505+
4506+ SW_LID = 0x00 # set = lid shut
4507+ SW_TABLET_MODE = 0x01 # set = tablet mode
4508+ SW_HEADPHONE_INSERT = 0x02 # set = inserted
4509+ SW_RFKILL_ALL = 0x03 # rfkill master switch, type "any"
4510+ # set = radio enabled
4511+ SW_RADIO = SW_RFKILL_ALL # deprecated
4512+ SW_MICROPHONE_INSERT = 0x04 # set = inserted
4513+ SW_DOCK = 0x05 # set = plugged into dock
4514+ SW_MAX = 0x0f
4515+ SW_CNT = SW_MAX+1
4516+
4517+ # Misc events
4518+
4519+ MSC_SERIAL = 0x00
4520+ MSC_PULSELED = 0x01
4521+ MSC_GESTURE = 0x02
4522+ MSC_RAW = 0x03
4523+ MSC_SCAN = 0x04
4524+ MSC_MAX = 0x07
4525+ MSC_CNT = MSC_MAX+1
4526+
4527+ # LEDs
4528+
4529+ LED_NUML = 0x00
4530+ LED_CAPSL = 0x01
4531+ LED_SCROLLL = 0x02
4532+ LED_COMPOSE = 0x03
4533+ LED_KANA = 0x04
4534+ LED_SLEEP = 0x05
4535+ LED_SUSPEND = 0x06
4536+ LED_MUTE = 0x07
4537+ LED_MISC = 0x08
4538+ LED_MAIL = 0x09
4539+ LED_CHARGING = 0x0a
4540+ LED_MAX = 0x0f
4541+ LED_CNT = LED_MAX+1
4542+
4543+ # Autorepeat values
4544+
4545+ REP_DELAY = 0x00
4546+ REP_PERIOD = 0x01
4547+ REP_MAX = 0x01
4548
4549=== added file 'checkbox/lib/log.py'
4550--- checkbox/lib/log.py 1970-01-01 00:00:00 +0000
4551+++ checkbox/lib/log.py 2012-03-28 20:34:20 +0000
4552@@ -0,0 +1,77 @@
4553+#
4554+# This file is part of Checkbox.
4555+#
4556+# Copyright 2008 Canonical Ltd.
4557+#
4558+# Checkbox is free software: you can redistribute it and/or modify
4559+# it under the terms of the GNU General Public License as published by
4560+# the Free Software Foundation, either version 3 of the License, or
4561+# (at your option) any later version.
4562+#
4563+# Checkbox is distributed in the hope that it will be useful,
4564+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4565+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4566+# GNU General Public License for more details.
4567+#
4568+# You should have received a copy of the GNU General Public License
4569+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
4570+#
4571+import inspect
4572+import logging
4573+
4574+from logging import StreamHandler, FileHandler, Formatter
4575+
4576+
4577+def format_class(cls):
4578+ return "%s.%s" % (cls.__module__, cls.__name__)
4579+
4580+def format_object(object, *args, **kwargs):
4581+ """
4582+ Returns a fully-qualified name for the specified object, such as
4583+ 'checkbox.log.format_object()'.
4584+ """
4585+ args_string = ""
4586+ if args:
4587+ args_string += ", ".join(str(a) for a in args)
4588+ if kwargs:
4589+ args_string += ", "
4590+ if kwargs:
4591+ args_string += ", ".join(["%s=%s" % (k, v) for k, v in kwargs.iteritems()])
4592+
4593+ module = object.__module__ if object.__module__ else inspect.getfile(object)
4594+ if inspect.ismethod(object):
4595+ # FIXME If the method is implemented on a base class of
4596+ # object's class, the module name and function name will be
4597+ # from the base class and the method's class name will be from
4598+ # object's class.
4599+ name = repr(object).split(" ")[2]
4600+ return "%s %s(%s)" % (module, name, args_string)
4601+ elif inspect.isfunction(object):
4602+ name = repr(object).split(" ")[1]
4603+ return "%s %s(%s)" % (module, name, args_string)
4604+ return format_class(object.__class__)
4605+
4606+def format_delta(seconds):
4607+ if not seconds:
4608+ seconds = 0.0
4609+ return "%.02fs" % float(seconds)
4610+
4611+def set_logging(level, log=None):
4612+ log_level = logging.getLevelName(level.upper())
4613+ log_handlers = []
4614+ if log:
4615+ log_filename = log
4616+ log_handlers.append(FileHandler(log_filename))
4617+ else:
4618+ log_handlers.append(StreamHandler())
4619+
4620+ # Log setup
4621+ format = ("%(asctime)s %(levelname)-8s %(message)s")
4622+ if log_handlers:
4623+ for handler in log_handlers:
4624+ handler.setFormatter(Formatter(format))
4625+ logging.getLogger().addHandler(handler)
4626+ if log_level:
4627+ logging.getLogger().setLevel(log_level)
4628+ elif not logging.getLogger().handlers:
4629+ logging.disable(logging.CRITICAL)
4630
4631=== added file 'checkbox/lib/path.py'
4632--- checkbox/lib/path.py 1970-01-01 00:00:00 +0000
4633+++ checkbox/lib/path.py 2012-03-28 20:34:20 +0000
4634@@ -0,0 +1,66 @@
4635+#
4636+# This file is part of Checkbox.
4637+#
4638+# Copyright 2008 Canonical Ltd.
4639+#
4640+# Checkbox is free software: you can redistribute it and/or modify
4641+# it under the terms of the GNU General Public License as published by
4642+# the Free Software Foundation, either version 3 of the License, or
4643+# (at your option) any later version.
4644+#
4645+# Checkbox is distributed in the hope that it will be useful,
4646+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4647+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4648+# GNU General Public License for more details.
4649+#
4650+# You should have received a copy of the GNU General Public License
4651+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
4652+#
4653+import posixpath
4654+
4655+from glob import glob
4656+
4657+
4658+def path_split(path):
4659+ return path.split(posixpath.sep)
4660+
4661+def path_common(l1, l2, common=[]):
4662+ if len(l1) < 1:
4663+ return (common, l1, l2)
4664+
4665+ if len(l2) < 1:
4666+ return (common, l1, l2)
4667+
4668+ if l1[0] != l2[0]:
4669+ return (common, l1, l2)
4670+
4671+ return path_common(l1[1:], l2[1:], common + [l1[0]])
4672+
4673+def path_relative(p1, p2):
4674+ (common, l1, l2) = path_common(path_split(p1), path_split(p2))
4675+ p = []
4676+ if len(l1) > 0:
4677+ p = ["..%s" % posixpath.sep * len(l1)]
4678+
4679+ p = p + l2
4680+ return posixpath.join( *p )
4681+
4682+def path_expand(path):
4683+ path = posixpath.expanduser(path)
4684+ return glob(path)
4685+
4686+def path_expand_recursive(path):
4687+ paths = []
4688+ for path in path_expand(path):
4689+ if posixpath.isdir(path):
4690+ def walk_func(arg, directory, names):
4691+ for name in names:
4692+ path = posixpath.join(directory, name)
4693+ if not posixpath.isdir(path):
4694+ arg.append(path)
4695+
4696+ posixpath.walk(path, walk_func, paths)
4697+ else:
4698+ paths.append(path)
4699+
4700+ return paths
4701
4702=== added file 'checkbox/lib/pci.py'
4703--- checkbox/lib/pci.py 1970-01-01 00:00:00 +0000
4704+++ checkbox/lib/pci.py 2012-03-28 20:34:20 +0000
4705@@ -0,0 +1,86 @@
4706+#
4707+# This file is part of Checkbox.
4708+#
4709+# Copyright 2008 Canonical Ltd.
4710+#
4711+# Checkbox is free software: you can redistribute it and/or modify
4712+# it under the terms of the GNU General Public License as published by
4713+# the Free Software Foundation, either version 3 of the License, or
4714+# (at your option) any later version.
4715+#
4716+# Checkbox is distributed in the hope that it will be useful,
4717+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4718+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4719+# GNU General Public License for more details.
4720+#
4721+# You should have received a copy of the GNU General Public License
4722+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
4723+#
4724+
4725+# See http://pciids.sourceforge.net/pci.ids.bz2
4726+class Pci:
4727+
4728+ BASE_CLASS_STORAGE = 1
4729+ CLASS_STORAGE_SCSI = 0
4730+ CLASS_STORAGE_IDE = 1
4731+ CLASS_STORAGE_FLOPPY = 2
4732+ CLASS_STORAGE_IPI = 3
4733+ CLASS_STORAGE_RAID = 4
4734+ CLASS_STORAGE_OTHER = 80
4735+
4736+ BASE_CLASS_NETWORK = 2
4737+ CLASS_NETWORK_ETHERNET = 0
4738+ CLASS_NETWORK_TOKEN_RING = 1
4739+ CLASS_NETWORK_FDDI = 2
4740+ CLASS_NETWORK_ATM = 3
4741+ CLASS_NETWORK_OTHER = 80
4742+ CLASS_NETWORK_WIRELESS = 128
4743+
4744+ BASE_CLASS_DISPLAY = 3
4745+ CLASS_DISPLAY_VGA = 0
4746+ CLASS_DISPLAY_XGA = 1
4747+ CLASS_DISPLAY_3D = 2
4748+ CLASS_DISPLAY_OTHER = 80
4749+
4750+ BASE_CLASS_MULTIMEDIA = 4
4751+ CLASS_MULTIMEDIA_VIDEO = 0
4752+ CLASS_MULTIMEDIA_AUDIO = 1
4753+ CLASS_MULTIMEDIA_PHONE = 2
4754+ CLASS_MULTIMEDIA_AUDIO_DEVICE = 3
4755+ CLASS_MULTIMEDIA_OTHER = 80
4756+
4757+ BASE_CLASS_BRIDGE = 6
4758+ CLASS_BRIDGE_HOST = 0
4759+ CLASS_BRIDGE_ISA = 1
4760+ CLASS_BRIDGE_EISA = 2
4761+ CLASS_BRIDGE_MC = 3
4762+ CLASS_BRIDGE_PCI = 4
4763+ CLASS_BRIDGE_PCMCIA = 5
4764+ CLASS_BRIDGE_NUBUS = 6
4765+ CLASS_BRIDGE_CARDBUS = 7
4766+ CLASS_BRIDGE_RACEWAY = 8
4767+ CLASS_BRIDGE_OTHER = 80
4768+
4769+ BASE_CLASS_COMMUNICATION = 7
4770+ CLASS_COMMUNICATION_SERIAL = 0
4771+ CLASS_COMMUNICATION_PARALLEL = 1
4772+ CLASS_COMMUNICATION_MULTISERIAL = 2
4773+ CLASS_COMMUNICATION_MODEM = 3
4774+ CLASS_COMMUNICATION_OTHER = 80
4775+
4776+ BASE_CLASS_INPUT = 9
4777+ CLASS_INPUT_KEYBOARD = 0
4778+ CLASS_INPUT_PEN = 1
4779+ CLASS_INPUT_MOUSE = 2
4780+ CLASS_INPUT_SCANNER = 3
4781+ CLASS_INPUT_GAMEPORT = 4
4782+ CLASS_INPUT_OTHER = 80
4783+
4784+ BASE_CLASS_SERIAL = 12
4785+ CLASS_SERIAL_FIREWIRE = 0
4786+ CLASS_SERIAL_ACCESS = 1
4787+
4788+ CLASS_SERIAL_SSA = 2
4789+ CLASS_SERIAL_USB = 3
4790+ CLASS_SERIAL_FIBER = 4
4791+ CLASS_SERIAL_SMBUS = 5
4792
4793=== added file 'checkbox/lib/process.py'
4794--- checkbox/lib/process.py 1970-01-01 00:00:00 +0000
4795+++ checkbox/lib/process.py 2012-03-28 20:34:20 +0000
4796@@ -0,0 +1,139 @@
4797+#
4798+# This file is part of Checkbox.
4799+#
4800+# Copyright 2008 Canonical Ltd.
4801+#
4802+# Checkbox is free software: you can redistribute it and/or modify
4803+# it under the terms of the GNU General Public License as published by
4804+# the Free Software Foundation, either version 3 of the License, or
4805+# (at your option) any later version.
4806+#
4807+# Checkbox is distributed in the hope that it will be useful,
4808+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4809+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4810+# GNU General Public License for more details.
4811+#
4812+# You should have received a copy of the GNU General Public License
4813+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
4814+#
4815+from __future__ import absolute_import
4816+
4817+import os
4818+import time
4819+import fcntl
4820+import select
4821+import signal
4822+
4823+
4824+STDIN_FILENO = 0
4825+STDOUT_FILENO = 1
4826+STDERR_FILENO = 2
4827+
4828+DEFAULT_OPEN_MAX = 1024
4829+
4830+
4831+class Process:
4832+ """Class representing a child process which is non blocking. This makes
4833+ it possible to return within a specified timeout."""
4834+
4835+ def __init__(self, cmd, env={}, bufsize=8192):
4836+ """The parameter 'cmd' is the shell command to execute in a
4837+ sub-process. If the 'bufsize' parameter is specified, it
4838+ specifies the size of the I/O buffers from the child process."""
4839+ self.cleaned=False
4840+ self.BUFSIZ=bufsize
4841+ self.outr, self.outw = os.pipe()
4842+ self.errr, self.errw = os.pipe()
4843+ self.pid = os.fork()
4844+ if self.pid == 0:
4845+ self._child(cmd, env)
4846+ os.close(self.outw) #parent doesn't write so close
4847+ os.close(self.errw)
4848+ # Note we could use self.stdout=fdopen(self.outr) here
4849+ # to get a higher level file object like popen2.Popen3 uses.
4850+ # This would have the advantages of auto handling the BUFSIZ
4851+ # and closing the files when deleted. However it would mean
4852+ # that it would block waiting for a full BUFSIZ unless we explicitly
4853+ # set the files non blocking, and there would be extra uneeded
4854+ # overhead like EOL conversion. So I think it's handier to use os.read()
4855+ self.outdata = self.errdata = ""
4856+ self.starttime = self.endtime = None
4857+ self._outeof = self._erreof = False
4858+
4859+ def _child(self, cmd, env):
4860+ # Force FD_CLOEXEC on all inherited descriptors
4861+ try:
4862+ open_max = os.sysconf('SC_OPEN_MAX')
4863+ except (AttributeError, ValueError):
4864+ open_max = DEFAULT_OPEN_MAX
4865+ for fileno in range(STDERR_FILENO+1, open_max):
4866+ try:
4867+ flags = fcntl.fcntl(fileno, fcntl.F_GETFD)
4868+ except IOError:
4869+ continue
4870+ flags |= fcntl.FD_CLOEXEC
4871+ fcntl.fcntl(fileno, fcntl.F_SETFD, flags)
4872+ # stdout and stderr to write side of pipe
4873+ os.dup2(self.outw, STDOUT_FILENO)
4874+ os.dup2(self.errw, STDERR_FILENO)
4875+ # stdout and stderr connected to pipe, so close all other files
4876+ map(os.close, [self.outr, self.outw, self.errr, self.errw])
4877+ try:
4878+ cmd = ["/bin/bash", "-c", cmd]
4879+ os.execve(cmd[0], cmd, env)
4880+ finally: #exit child on error
4881+ os._exit(1)
4882+
4883+ def read(self, timeout=None):
4884+ """return False when finished
4885+ else return True every timeout seconds
4886+ data will be in outdata and errdata"""
4887+ has_finished = True
4888+ self.starttime = time.time()
4889+ while True:
4890+ tocheck=[]
4891+ if not self._outeof:
4892+ tocheck.append(self.outr)
4893+ if not self._erreof:
4894+ tocheck.append(self.errr)
4895+ ready = select.select(tocheck, [], [], timeout)
4896+ if not len(ready[0]): # no data timeout
4897+ has_finished = False
4898+ break
4899+ else:
4900+ if self.outr in ready[0]:
4901+ outchunk = os.read(self.outr, self.BUFSIZ)
4902+ if outchunk == "":
4903+ self._outeof = True
4904+ self.outdata += outchunk
4905+ if self.errr in ready[0]:
4906+ errchunk = os.read(self.errr, self.BUFSIZ)
4907+ if errchunk == "":
4908+ self._erreof = True
4909+ self.errdata += errchunk
4910+ if self._outeof and self._erreof:
4911+ break
4912+ elif timeout:
4913+ if (time.time() - self.starttime) > timeout:
4914+ has_finished = False
4915+ break # may be more data but time to go
4916+
4917+ self.endtime = time.time()
4918+ return has_finished
4919+
4920+ def kill(self):
4921+ os.kill(self.pid, signal.SIGTERM)
4922+
4923+ def cleanup(self):
4924+ """Wait for and return the exit status of the child process."""
4925+ self.cleaned = True
4926+ os.close(self.outr)
4927+ os.close(self.errr)
4928+ pid, status = os.waitpid(self.pid, 0)
4929+ if pid == self.pid:
4930+ self.status = status
4931+ return self.status
4932+
4933+ def __del__(self):
4934+ if not self.cleaned:
4935+ self.cleanup()
4936
4937=== added file 'checkbox/lib/redirect.py'
4938--- checkbox/lib/redirect.py 1970-01-01 00:00:00 +0000
4939+++ checkbox/lib/redirect.py 2012-03-28 20:34:20 +0000
4940@@ -0,0 +1,158 @@
4941+#
4942+# This file is part of Checkbox.
4943+#
4944+# Copyright 2008 Canonical Ltd.
4945+#
4946+# Checkbox is free software: you can redistribute it and/or modify
4947+# it under the terms of the GNU General Public License as published by
4948+# the Free Software Foundation, either version 3 of the License, or
4949+# (at your option) any later version.
4950+#
4951+# Checkbox is distributed in the hope that it will be useful,
4952+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4953+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4954+# GNU General Public License for more details.
4955+#
4956+# You should have received a copy of the GNU General Public License
4957+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
4958+#
4959+import os
4960+import sys
4961+import tempfile
4962+
4963+
4964+def _file_write(file):
4965+ # file is a filename, a pipe-command, a fileno(), or a file
4966+ # returns file.
4967+ if not hasattr(file, "write"):
4968+ if file[0] == "|":
4969+ file = os.popen(file[1:], "w")
4970+ else:
4971+ file = open(file, "w")
4972+
4973+ return file
4974+
4975+def _file_read(file):
4976+ # file is a filename, a pipe-command, or a file
4977+ # returns file.
4978+ if not hasattr(file, "read"):
4979+ if file[-1] == "|":
4980+ file = os.popen(file[1:], "r")
4981+ else:
4982+ file = open(file, "r")
4983+
4984+ return file
4985+
4986+def redirect_to_file(file, func, *args):
4987+ # apply func(args), temporarily redirecting stdout to file.
4988+ # file can be a file or any writable object, or a filename string.
4989+ # a "|cmd" string will pipe output to cmd.
4990+ # Returns value of apply(func, *args)
4991+ ret = None
4992+ file = _file_write(file)
4993+ sys.stdout, file = file, sys.stdout
4994+ try:
4995+ ret = apply(func, args)
4996+ finally:
4997+ print ret
4998+ sys.stdout, file = file, sys.stdout
4999+ return ret
5000+
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches