Merge lp:~udienz/ubuntu/natty/checkbox/checkbox.fix.514401 into lp:checkbox

Proposed by Michael Terry
Status: Superseded
Proposed branch: lp:~udienz/ubuntu/natty/checkbox/checkbox.fix.514401
Merge into: lp:checkbox
Diff against target: 59248 lines (+57780/-0) (has conflicts)
266 files modified
.bzr-builddeb/default.conf (+2/-0)
COPYING (+674/-0)
README (+5/-0)
apport/checkbox.py (+24/-0)
apport/source_checkbox.py (+17/-0)
backend (+46/-0)
bin/checkbox-cli (+18/-0)
bin/checkbox-gtk (+18/-0)
bin/checkbox-urwid (+18/-0)
checkbox/application.py (+133/-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 (+542/-0)
checkbox/job.py (+131/-0)
checkbox/lib/bit.py (+42/-0)
checkbox/lib/cache.py (+37/-0)
checkbox/lib/config.py (+156/-0)
checkbox/lib/conversion.py (+80/-0)
checkbox/lib/decorator.py (+28/-0)
checkbox/lib/dmi.py (+74/-0)
checkbox/lib/environ.py (+113/-0)
checkbox/lib/fifo.py (+80/-0)
checkbox/lib/input.py (+585/-0)
checkbox/lib/log.py (+68/-0)
checkbox/lib/path.py (+66/-0)
checkbox/lib/pci.py (+86/-0)
checkbox/lib/process.py (+137/-0)
checkbox/lib/redirect.py (+158/-0)
checkbox/lib/resolver.py (+126/-0)
checkbox/lib/safe.py (+96/-0)
checkbox/lib/script.py (+33/-0)
checkbox/lib/signal.py (+89/-0)
checkbox/lib/template.py (+144/-0)
checkbox/lib/template_i18n.py (+133/-0)
checkbox/lib/tests/resolver.py (+100/-0)
checkbox/lib/text.py (+100/-0)
checkbox/lib/transport.py (+279/-0)
checkbox/lib/update.py (+42/-0)
checkbox/lib/url.py (+41/-0)
checkbox/lib/usb.py (+57/-0)
checkbox/message.py (+311/-0)
checkbox/plugin.py (+50/-0)
checkbox/properties.py (+204/-0)
checkbox/reactor.py (+113/-0)
checkbox/report.py (+150/-0)
checkbox/reports/launchpad_report.py (+287/-0)
checkbox/reports/xml_report.py (+191/-0)
checkbox/resource.py (+121/-0)
checkbox/tests/report.py (+109/-0)
checkbox/user_interface.py (+216/-0)
checkbox/variables.py (+288/-0)
checkbox_cli/cli_interface.py (+355/-0)
checkbox_gtk/gtk_interface.py (+521/-0)
checkbox_gtk/hyper_text_view.py (+116/-0)
checkbox_urwid/urwid_interface.py (+807/-0)
data/documents/RTF_Russian.rtf (+51/-0)
data/images/SVG_Color_Image_Xubuntu.svg (+109/-0)
data/websites/SWF_Test.as (+14/-0)
data/websites/flashtest.html (+6/-0)
data/websites/flashvideo.html (+6/-0)
data/websites/javatest.html (+9/-0)
data/websites/testindex.html (+6/-0)
debian/changelog (+447/-0)
debian/checkbox-cli.install (+3/-0)
debian/checkbox-cli.links (+1/-0)
debian/checkbox-cli.postinst (+6/-0)
debian/checkbox-gtk.install (+5/-0)
debian/checkbox-gtk.links (+1/-0)
debian/checkbox-gtk.postinst (+6/-0)
debian/checkbox-urwid.install (+3/-0)
debian/checkbox-urwid.links (+1/-0)
debian/checkbox-urwid.postinst (+6/-0)
debian/checkbox.config (+19/-0)
debian/checkbox.dirs (+2/-0)
debian/checkbox.install (+16/-0)
debian/checkbox.links (+1/-0)
debian/checkbox.manpages (+1/-0)
debian/checkbox.postinst (+6/-0)
debian/checkbox.postrm (+26/-0)
debian/checkbox.templates (+40/-0)
debian/compat (+1/-0)
debian/control (+82/-0)
debian/copyright (+33/-0)
debian/hwtest-cli.postinst (+6/-0)
debian/hwtest-gtk.postinst (+6/-0)
debian/hwtest.postinst (+6/-0)
debian/hwtest.postrm (+26/-0)
debian/po/POTFILES.in (+1/-0)
debian/po/templates.pot (+113/-0)
debian/pycompat (+1/-0)
debian/rules (+34/-0)
debian/watch (+3/-0)
examples/checkbox-cli.ini (+14/-0)
examples/checkbox-gtk.ini (+16/-0)
examples/checkbox-urwid.ini (+14/-0)
examples/checkbox.ini (+26/-0)
gtk/checkbox-gtk.desktop.in (+11/-0)
gtk/checkbox-gtk.glade (+754/-0)
icons/scalable/apps/checkbox.svg (+336/-0)
install/config (+162/-0)
install/postinst (+83/-0)
jobs/audio.txt.in (+62/-0)
jobs/autotest.txt.in (+6/-0)
jobs/disk.txt.in (+21/-0)
jobs/fingerprint.txt.in (+27/-0)
jobs/firewire.txt.in (+10/-0)
jobs/kms.txt.in (+13/-0)
jobs/local.txt.in (+107/-0)
jobs/ltp.txt.in (+12/-0)
jobs/media.txt.in (+148/-0)
jobs/monitor.txt.in (+21/-0)
jobs/network.txt.in (+21/-0)
jobs/peripheral.txt.in (+27/-0)
jobs/phoronix.txt.in (+9/-0)
jobs/qa_regression.txt.in (+7/-0)
jobs/resource.txt.in (+40/-0)
jobs/sleep.txt.in (+186/-0)
jobs/user_apps.txt.in (+276/-0)
jobs/video.txt.in (+123/-0)
man/checkbox.1 (+106/-0)
patches/0.1-ubuntu13 (+21/-0)
patches/0.1-ubuntu14 (+40/-0)
patches/0.1-ubuntu15 (+17/-0)
patches/0.1-ubuntu2 (+10/-0)
patches/0.1-ubuntu3 (+12/-0)
patches/0.1-ubuntu4 (+7/-0)
patches/0.1-ubuntu5 (+11/-0)
patches/0.1-ubuntu6 (+5/-0)
patches/0.1-ubuntu9 (+12/-0)
patches/0.4 (+48/-0)
patches/0.5 (+30/-0)
patches/0.7.2 (+31/-0)
patches/0.8 (+31/-0)
patches/0.9 (+39/-0)
plugins/apport_prompt.py (+267/-0)
plugins/attachment_info.py (+39/-0)
plugins/backend_info.py (+102/-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 (+52/-0)
plugins/jobs_info.py (+117/-0)
plugins/jobs_prompt.py (+103/-0)
plugins/launchpad_exchange.py (+173/-0)
plugins/launchpad_prompt.py (+102/-0)
plugins/launchpad_report.py (+149/-0)
plugins/local_suite.py (+47/-0)
plugins/lock_prompt.py (+64/-0)
plugins/manual_test.py (+46/-0)
plugins/message_info.py (+97/-0)
plugins/metric_test.py (+41/-0)
plugins/persist_info.py (+53/-0)
plugins/proxy_info.py (+84/-0)
plugins/recover_prompt.py (+56/-0)
plugins/remote_suite.py (+48/-0)
plugins/report_prompt.py (+38/-0)
plugins/resource_info.py (+64/-0)
plugins/scripts_info.py (+39/-0)
plugins/shell_test.py (+62/-0)
plugins/submission_info.py (+64/-0)
plugins/subunit_report.py (+79/-0)
plugins/suites_prompt.py (+115/-0)
plugins/system_info.py (+81/-0)
plugins/tests_prompt.py (+33/-0)
plugins/user_interface.py (+76/-0)
po/POTFILES.in (+42/-0)
po/ar.po (+749/-0)
po/ast.po (+731/-0)
po/bg.po (+762/-0)
po/ca.po (+747/-0)
po/checkbox.pot (+1429/-0)
po/cs.po (+749/-0)
po/da.po (+706/-0)
po/de.po (+846/-0)
po/el.po (+749/-0)
po/en_CA.po (+659/-0)
po/en_GB.po (+744/-0)
po/es.po (+827/-0)
po/eu.po (+664/-0)
po/fi.po (+791/-0)
po/fr.po (+845/-0)
po/he.po (+755/-0)
po/hr.po (+681/-0)
po/hu.po (+818/-0)
po/id.po (+810/-0)
po/is.po (+658/-0)
po/it.po (+837/-0)
po/ja.po (+724/-0)
po/jbo.po (+650/-0)
po/ka.po (+659/-0)
po/ko.po (+658/-0)
po/lt.po (+739/-0)
po/lv.po (+653/-0)
po/mk.po (+712/-0)
po/nb.po (+737/-0)
po/nds.po (+650/-0)
po/nl.po (+674/-0)
po/pl.po (+720/-0)
po/pt.po (+650/-0)
po/pt_BR.po (+773/-0)
po/ro.po (+730/-0)
po/ru.po (+767/-0)
po/sk.po (+737/-0)
po/sq.po (+650/-0)
po/sv.po (+825/-0)
po/th.po (+735/-0)
po/tr.po (+700/-0)
po/ug.po (+650/-0)
po/uk.po (+704/-0)
po/vi.po (+676/-0)
po/zh_CN.po (+748/-0)
po/zh_TW.po (+710/-0)
report/checkbox.js (+16/-0)
report/checkbox.xsl (+188/-0)
report/styles.css (+258/-0)
run (+40/-0)
scripts/alsa_record_playback (+7/-0)
scripts/ansi_parser (+160/-0)
scripts/autotest_filter (+128/-0)
scripts/autotest_suite (+118/-0)
scripts/cdimage_resource (+95/-0)
scripts/compiz-check (+968/-0)
scripts/cpu_scaling_test (+525/-0)
scripts/cpuinfo_resource (+196/-0)
scripts/cycle_vts (+21/-0)
scripts/dead_pixel_test (+34/-0)
scripts/disk_bench_test (+18/-0)
scripts/dpkg_resource (+50/-0)
scripts/filter_packages (+179/-0)
scripts/filter_templates (+127/-0)
scripts/gconf_resource (+95/-0)
scripts/gcov_tarball (+11/-0)
scripts/gst_pipeline_test (+38/-0)
scripts/hal_resource (+476/-0)
scripts/internet_test (+143/-0)
scripts/keyboard_test (+80/-0)
scripts/lsb_resource (+55/-0)
scripts/ltp_filter (+90/-0)
scripts/ltp_suite (+151/-0)
scripts/meminfo_resource (+58/-0)
scripts/module_resource (+72/-0)
scripts/network_check (+66/-0)
scripts/network_test (+25/-0)
scripts/package_resource (+119/-0)
scripts/phoronix_filter (+148/-0)
scripts/phoronix_suite (+307/-0)
scripts/qa_regression_suite (+171/-0)
scripts/resolution_test (+88/-0)
scripts/run_compiz_check (+27/-0)
scripts/run_templates (+142/-0)
scripts/sleep_test (+440/-0)
scripts/suspend_test (+611/-0)
scripts/udev_resource (+554/-0)
scripts/uname_resource (+38/-0)
scripts/xrandr_cycle (+86/-0)
setup.cfg (+27/-0)
setup.py (+161/-0)
test (+179/-0)
Conflict adding file .bzr-builddeb.  Moved existing file to .bzr-builddeb.moved.
Conflict adding file COPYING.  Moved existing file to COPYING.moved.
Conflict adding file README.  Moved existing file to README.moved.
Conflict adding file apport.  Moved existing file to apport.moved.
Conflict adding file backend.  Moved existing file to backend.moved.
Conflict adding file bin.  Moved existing file to bin.moved.
Conflict adding file checkbox.  Moved existing file to checkbox.moved.
Conflict adding file checkbox_cli.  Moved existing file to checkbox_cli.moved.
Conflict adding file checkbox_gtk.  Moved existing file to checkbox_gtk.moved.
Conflict adding file checkbox_urwid.  Moved existing file to checkbox_urwid.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 gtk.  Moved existing file to gtk.moved.
Conflict adding file icons.  Moved existing file to icons.moved.
Conflict adding file install.  Moved existing file to install.moved.
Conflict adding file jobs.  Moved existing file to jobs.moved.
Conflict adding file man.  Moved existing file to man.moved.
Conflict adding file patches.  Moved existing file to patches.moved.
Conflict adding file plugins.  Moved existing file to plugins.moved.
Conflict adding file po.  Moved existing file to po.moved.
Conflict adding file report.  Moved existing file to report.moved.
Conflict adding file run.  Moved existing file to run.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.
Conflict adding file test.  Moved existing file to test.moved.
To merge this branch: bzr merge lp:~udienz/ubuntu/natty/checkbox/checkbox.fix.514401
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Ubuntu Sponsors Pending
Matthias Klose Pending
Sebastien Bacher Pending
Review via email: mp+44473@code.launchpad.net

This proposal supersedes a proposal from 2010-12-16.

Description of the change

Solved
 * LP: #514401
   Translations are not loaded for the test descriptions in Checkbox
 * LP: #525454
   translation line 338: "Screen" should be "The screen"

To post a comment you must log in.

Unmerged revisions

21. By Mahyuddin Susanto

* Fixed several strings appear in English although translated (LP: #514401)
  + jobs/fingerprint.txt.in
  + jobs/media.txt.in
  + jobs/monitor.txt.in
  + jobs/sleep.txt.in
  + po/checkbox.pot
* Fixed grammar (LP: #525454)
  + jobs/fingerprint.txt.in
* Removing directory produced from building
  - build

20. By Matthias Klose

Hack to work around internals of ConfigParser in python2.7. LP: #689140.

19. By Marc Tardif

New upstream release (LP: #638333):
* Fixed verification of SSL validity (LP: #625076)
* Improved audio test questions.

18. By Marc Tardif

New upstream release (LP: #617583):
* Fixed sleep_test to check the connection if using network-manager.
* Fixed reporting bugs against alsa-base and xorg (LP: #607214)
* Fixed apport dialog no longer appearing (LP: #607217)
* Reduced data file size for the desktop image.
* Updated report to be more pretty.

17. By Marc Tardif

New upstream release (LP: #597295):
* Added support for urwid interface.
* Added sound check test.
* Added document viewer test.
* Added update-manager and nautilus tests.
* Added resolution tests.
* Added sleep tests.

16. By Marc Tardif

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

15. By Marc Tardif

New upstream release (LP: #548800):
* Added cpu_scaling_test script.
* Fixed hard drive detection (LP: #549714)
* Fixed backend to handle empty messages (LP: #536645)
* Fixed parsing of package resource (LP: #539691)
* Fixed malformed xml report (LP: #485445)
* Fixed running root manual tests as normal user (LP: #383559)
* Fixed writing apport files only after submitting (LP: #530380)
* Fixed audio test instructions (LP: #529205)
* Fixed gathering chassis information (LP: #537435)
* Fixed detection of disks in kvm (LP: #552998)
* Fixed udev_resource script to be more resilient (LP: #552999)
* Fixed filter_packages script to use new resources.

14. By Mathias Gug

[ Marc Tardif ]
New upstream release (LP: #532882):
* Introduced job_prompt plugin to treat all jobs (suites, tests, etc.) as composites.
* Replaced the registry and resource scripts and centralized job iteration.
* Replaced dependency on dbus by using sudo/gksu/kdesudo instead.
* Replaced mktemp with mkdtemp for security purposes.
* Fixed strings in fingerprint and modem tests (LP: #457759)
* Fixed client side validation of Launchpad form (LP: #438671)
* Added device information to tags when reporting bugs with apport.
* Added shorthands for blacklist-file and whitelist-file.
* Added support for apport default configuration (LP: #465447)
* Added support for scrolled options list (LP: #411526)
* Added support for tests generated by suites to run as root.
* Added support for requirements in attachments.
* Added support for armv7l processor
* Added Autotest integration
* Added LTP integration
* Added Phoronix integration
* Added qa-regression-testing integration

13. By Marc Tardif

Added support for apport default configuration (LP: #465447)

12. By Marc Tardif

* Fixed translation of suites and tests files (LP: #456115)
* Fixed checking the status of command registries (LP: #457502)
* Fixed selecting suites in the command line (LP: #457559)
* Fixed reporting of bugs to contain test description (LP: #427932)
* Fixed execute permissions on scripts (LP: #459606)
* Renamed processors_info plugin to singular because processor
  information is reported as a single structure with a count attribute
* Updated translation files.

Preview Diff

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

Subscribers

People subscribed via source and target branches