Ticket #1303: bin-tahoe-runner-support.darcs.patch

File bin-tahoe-runner-support.darcs.patch, 18.1 KB (added by davidsarah, at 2011-01-13T04:24:01Z)

Add support to bin/tahoe for invoking a runner command prefixed with @, with the Tahoe libraries on the PYTHONPATH. This is documented in 'tahoe debug --help'.

Line 
11 patch for repository davidsarah@dev.allmydata.org:/home/darcs/tahoe/trunk:
2
3Thu Jan 13 02:54:21 GMT Standard Time 2011  david-sarah@jacaranda.org
4  * Add support to bin/tahoe for invoking a runner command prefixed with @, with the Tahoe libraries on the PYTHONPATH. This is documented in 'tahoe debug --help'.
5
6New patches:
7
8[Add support to bin/tahoe for invoking a runner command prefixed with @, with the Tahoe libraries on the PYTHONPATH. This is documented in 'tahoe debug --help'.
9david-sarah@jacaranda.org**20110113025421
10 Ignore-this: 138b35ef88f2c48ae2b135ed99348542
11] {
12hunk ./bin/tahoe-script.template 17
13 whoami = '''\
14 I am a "bin%stahoe" executable who is only for the convenience of running
15 Tahoe from its source distribution -- I work only when invoked as the "tahoe"
16-script that lives in the "bin/" subdirectory of a Tahoe source code
17-distribution, and only if you have already run "make".
18+script that lives in the "bin" subdirectory of a Tahoe source code
19+distribution, and only if you have already run "python setup.py build".
20 ''' % (os.path.sep,)
21 
22 # look for Tahoe.home .
23hunk ./bin/tahoe-script.template 68
24     def mangle(s):
25         return str(re.sub(ur'[^\x20-\x7F]', lambda m: u'\x7F%x;' % (ord(m.group(0)),), s))
26 
27-    argv = [mangle(argv_unicode[i]) for i in xrange(1, argc.value)]
28+    argv = [mangle(argv_unicode[i]) for i in xrange(0, argc.value)]
29 
30hunk ./bin/tahoe-script.template 70
31-    # Skip option arguments to the Python interpreter.
32-    while len(argv) > 0:
33-        arg = argv[0]
34-        if not arg.startswith(u"-") or arg == u"-":
35-            break
36-        argv = argv[1:]
37-        if arg == u'-m' or arg == u'-c':
38-            break
39+    # Take only the suffix with the same number of arguments as sys.argv.
40+    # This accounts for anything that can cause initial arguments to be stripped,
41+    # for example, the Python interpreter or any options passed to it, or runner
42+    # scripts such as 'coverage run'. It works even if there are no such arguments,
43+    # as in the case of a frozen executable created by bb-freeze or similar.
44 
45hunk ./bin/tahoe-script.template 76
46-    script = os.path.join(base, "support", "Scripts", "tahoe.pyscript")
47+    argv = argv[-len(sys.argv):]
48 
49     # On Windows, the script is not directly executable and must be run via python.
50hunk ./bin/tahoe-script.template 79
51-    args = [sys.executable, script] + argv[1:]
52+    prefix = [sys.executable]
53+    script = os.path.join(base, "support", "Scripts", "tahoe.pyscript")
54+    args = argv[1:]
55 else:
56hunk ./bin/tahoe-script.template 83
57-    script = os.path.join(base, "support", "bin", "tahoe")
58-
59     # On non-Windows, invoke the script directly, so that 'top' for example shows 'tahoe'.
60hunk ./bin/tahoe-script.template 84
61-    args = [script] + sys.argv[1:]
62+    prefix = []
63+    script = os.path.join(base, "support", "bin", "tahoe")
64+    args = sys.argv[1:]
65 
66hunk ./bin/tahoe-script.template 88
67-try:
68-    res = subprocess.call(args, env=os.environ)
69-except (OSError, IOError), le:
70-    if le.args[0] == errno.ENOENT:
71-        print whoami
72-        print '''\
73+if not os.path.exists(script):
74+    print whoami
75+    print '''\
76 I just tried to run and could not find my brother at
77 "%s". To run Tahoe when it is installed, please execute my
78 brother, who gets installed into the appropriate place for executables
79hunk ./bin/tahoe-script.template 94
80-when you run "make install" (perhaps as "%s").
81+when you run "python setup.py install" (perhaps as "%s").
82 ''' % (script, perhaps_installed_tahoe)
83hunk ./bin/tahoe-script.template 96
84-        raise
85+    sys.exit(1)
86+
87+# Support indirection via another "runner" script (e.g. coverage).
88+# For example: bin/tahoe @RUNNER RUNNER_ARGS @tahoe TAHOE_ARGS
89+
90+if len(args) >= 1 and args[0].startswith('@'):
91+    command = [args[0][1:]] + [(script if a == '@tahoe' else a) for a in args[1:]]
92+else:
93+    command = prefix + [script] + args
94+
95+try:
96+    res = subprocess.call(command, env=os.environ)
97 except Exception, le:
98     print whoami
99     print '''\
100hunk ./bin/tahoe-script.template 117
101     raise
102 else:
103     sys.exit(res)
104-
105hunk ./src/allmydata/scripts/debug.py 809
106 
107 Please run e.g. 'tahoe debug dump-share --help' for more details on each
108 subcommand.
109-"""
110+
111+Another debugging feature is that bin%stahoe allows executing an arbitrary
112+"runner" command (typically an installed Python script, such as 'coverage'),
113+with the Tahoe libraries on the PYTHONPATH. The runner command name is
114+prefixed with '@', and any occurrences of '@tahoe' in its arguments are
115+replaced by the full path to the tahoe script.
116+
117+For example, if 'coverage' is installed and on the PATH, you can use:
118+
119+    bin%stahoe @coverage run --branch @tahoe debug trial
120+
121+to get branch coverage for the Tahoe test suite. Or, to run python with
122+the -3 option that warns about Python 3 incompatibilities:
123+
124+    bin%stahoe @python -3 @tahoe command [options]
125+""" % (os.sep, os.sep, os.sep)
126         return t
127 
128 subDispatch = {
129hunk ./src/allmydata/windows/fixups.py 180
130         return re.sub(ur'\x7F[0-9a-fA-F]*\;', lambda m: unichr(int(m.group(0)[1:-1], 16)), s)
131 
132     try:
133-        argv = [unmangle(argv_unicode[i]).encode('utf-8') for i in xrange(1, argc.value)]
134+        argv = [unmangle(argv_unicode[i]).encode('utf-8') for i in xrange(0, argc.value)]
135     except Exception, e:
136         _complain("%s:  could not unmangle Unicode arguments.\n%r"
137hunk ./src/allmydata/windows/fixups.py 183
138-                  % (sys.argv[0], [argv_unicode[i] for i in xrange(1, argc.value)]))
139+                  % (sys.argv[0], [argv_unicode[i] for i in xrange(0, argc.value)]))
140         raise
141 
142hunk ./src/allmydata/windows/fixups.py 186
143-    # Skip option arguments to the Python interpreter.
144-    while len(argv) > 0:
145-        arg = argv[0]
146-        if not arg.startswith(u"-") or arg == u"-":
147-            if arg.endswith('.pyscript'):
148-                argv[0] = arg[:-9]
149-            break
150-        argv = argv[1:]
151-        if arg == u'-m':
152-            # sys.argv[0] should really be the absolute path of the module source, but never mind
153-            break
154-        if arg == u'-c':
155-            argv[0] = u'-c'
156-            break
157+    # Take only the suffix with the same number of arguments as sys.argv.
158+    # This accounts for anything that can cause initial arguments to be stripped,
159+    # for example, the Python interpreter or any options passed to it, or runner
160+    # scripts such as 'coverage run'. It works even if there are no such arguments,
161+    # as in the case of a frozen executable created by bb-freeze or similar.
162 
163hunk ./src/allmydata/windows/fixups.py 192
164-    sys.argv = argv
165+    sys.argv = argv[-len(sys.argv):]
166}
167
168Context:
169
170[bin/tahoe-script.template: improve the error message if we end up running under Python 3. refs #1302
171david-sarah@jacaranda.org**20110112211628
172 Ignore-this: ee78f8e4bbd197e620cb0cc6b995ac46
173]
174[Makefile: Fix uploading of tarballs on trunk builds.
175david-sarah@jacaranda.org**20110109065851
176 Ignore-this: 864b06e39103f46dbb6ccb74e1e333d3
177]
178[docs/frontends/CLI.rst: fix the rst syntax to be as actually intended :-)
179david-sarah@jacaranda.org**20110109014057
180 Ignore-this: c11331670ba89d8601ba3782ffc4f32c
181]
182[docs/frontends/CLI.rst: really fix rst syntax error this time.
183david-sarah@jacaranda.org**20110109013914
184 Ignore-this: 59550154c9ab41488ddfdee8938d7bda
185]
186[docs/frontends/CLI.rst: fix rst syntax error.
187david-sarah@jacaranda.org**20110109010943
188 Ignore-this: 427444f5572115059c75fa1bd8371d51
189]
190[docs/frontends/CLI.rst: discuss commandline/output quoting issues and wildcards. refs #1135
191david-sarah@jacaranda.org**20110109010119
192 Ignore-this: 533938d89be878b404a8540aebdf68ad
193]
194[setup.py: add Python 2.7 trove classifier.
195david-sarah@jacaranda.org**20110108211212
196 Ignore-this: b479c0a1adf9b7a2d1fdc54abc6582e6
197]
198[docs/FTP-and-SFTP.rst: document issue in ref #1297. Remove known issue #1045 which is fixed. Also some cosmetic changes.
199david-sarah@jacaranda.org**20110108061038
200 Ignore-this: 8d9aa2e33f1054545f7bed47bf0e647d
201]
202[misc/build_helpers/show-tool-versions.py: remove attempts to show stdout.encoding and stderr.encoding that always printed None due to redirection. Also remove code to show os.path.supports_unicode_filenames which is not useful. refs #1251
203david-sarah@jacaranda.org**20110103015144
204 Ignore-this: 45e11431f7e2e0cebcb58e1841485cf8
205]
206[NEWS: 'top' for node processes, WUI formatting, removal of GUI apps, documentation updates, foolscap dependency. refs #174, #1219, #1225
207david-sarah@jacaranda.org**20110106005727
208 Ignore-this: f61ac58b4d10e635feb6f7391b1b48fe
209]
210[Makefile: update 'clean' target for files in bin/
211david-sarah@jacaranda.org**20110103052738
212 Ignore-this: 2bdbc4a50e13e508b66d0f65718c79b2
213]
214[docs: update performance.rst to describe the difference between already-uploaded and not-already-uploaded, to parameterize segment size, and to use "~A" to mean "approximately A"
215zooko@zooko.com**20110104065455
216 Ignore-this: 8df0d79a062ee19854c0211bd202f606
217]
218[bin/tahoe-script.template: On non-Windows, invoke support/bin/tahoe directly as a script (rather than via python), so that 'top' for example will show it as 'tahoe'. On Windows, simplify some code that set argv[0], which is never used. fixes #174
219david-sarah@jacaranda.org**20101127232650
220 Ignore-this: 42a86f3eecfdc1ea7b76a7cc68626898
221]
222[test_runner: avoid unnecessary use of non-ASCII.
223david-sarah@jacaranda.org**20110101100101
224 Ignore-this: e2ff40dce6bb3b021306f2913d4e75df
225]
226[docs/quickstart.html: fix redundant, badly nested tag. refs #1284
227david-sarah@jacaranda.org**20110102175159
228 Ignore-this: 2ae9cc0b47d2e87b9eb64a0f517c4eef
229]
230[docs/quickstart.html: information about 'troublesome dependencies' and 'verified systems' de-emphasized by smaller italic font. Re-wrap so that the HTML source is readable (just about) as text. Minor wording tweaks. Improve organization by adding 'Windows Caveats' subsection. fixes #1284
231david-sarah@jacaranda.org**20110102174212
232 Ignore-this: e9dc57983974478200856651c5318fee
233]
234[NEWS: update entry for removal of Mac and Windows apps. refs #1282
235david-sarah@jacaranda.org**20101226042245
236 Ignore-this: c8099bc6e8235718d042c9a13c1e2425
237]
238[Move dependency imports from windows/depends.py (which has gone away) into src/allmydata/windows/tahoesvc.py. Also fix a pyflakes warning, and change the service display name from 'Allmydata Tahoe Node' to 'Tahoe-LAFS node'. refs #1282
239david-sarah@jacaranda.org**20101226042100
240 Ignore-this: ee45f324934e1251380206dbee6346d0
241]
242[Remove unmaintained Windows GUI app, except for windows/tahoesvc.py which is moved to src/allmydata/windows. refs #1282
243david-sarah@jacaranda.org**20101226040237
244 Ignore-this: cae37b6622a7dd5940acc7d3e6a98b90
245]
246[Remove the Makefile targets relating to the Mac GUI app. refs #1282
247david-sarah@jacaranda.org**20101226025859
248 Ignore-this: 75303be783974b41138744ec62b07965
249]
250[NEWS: remove unmaintained Mac GUI app. refs #1282
251david-sarah@jacaranda.org**20101226020858
252 Ignore-this: 40474a07f4a550b48563d35350be7ab5
253]
254[Remove unmaintained Mac GUI app. fixes #1282
255david-sarah@jacaranda.org**20101226020508
256 Ignore-this: b3613bf1abfd284d542bf7c753ec557a
257]
258[Remove src/allmydata/util/find_exe.py which is no longer used. fixes #1150
259david-sarah@jacaranda.org**20101226023206
260 Ignore-this: 7436c9b53bf210aed34a1a973cd9cace
261]
262[status_web_pages_review.darcs.patch
263freestorm77@gmail.com**20110102034214
264 Ignore-this: 29f1ecb36177f10f3f846b3d56b313b2
265 
266 I make some changes on status web pages
267 
268 status.xhtml:
269 - Delete unused webform_css link
270 - Align tables on the left
271 
272 tahoe-css:
273 - Do some minor changes on code synthax
274 - changes table.status-download-events style to look like other tables
275 
276 status.py:
277 - Align table on the left
278 - Changes table header
279 - Add heading tags
280 - Modify google api graph: add image border, calculate height to feet data
281 
282 signed-off-by: zooko@zooko.com
283 fixes #1219
284]
285[test_storage.py: fix a pyflakes unused import warning.
286david-sarah@jacaranda.org**20101231220756
287 Ignore-this: df08231540cb7dff9d2b038e47ab30ee
288]
289[test_storage.py: leave at least 512 MiB free when running test_large_share. refs #1195
290david-sarah@jacaranda.org**20101231203215
291 Ignore-this: b2144c0341c3452b5d4ba219e284ea0e
292]
293[storage: use fileutil's version of get_disk_stats() and get_available_space(), use mockery/fakery in tests, enable large share test on platforms with sparse files and if > 4 GiB of disk space is currently available
294zooko@zooko.com**20100910173629
295 Ignore-this: 1304f1164c661de6d5304f993eb9b27b
296]
297[fileutil: copy in the get_disk_stats() and get_available_space() functions from storage/server.py
298zooko@zooko.com**20100910173520
299 Ignore-this: 8b15569715f710f4fc5092f7ca109253
300]
301[Update foolscap version requirement to 0.6.0, to address http://foolscap.lothar.com/trac/ticket/167
302david-sarah@jacaranda.org**20101231060039
303 Ignore-this: 98d2b8086a1a500b9f4565bca5a3810
304]
305[docs/webapi.rst: typos.
306david-sarah@jacaranda.org**20101230034422
307 Ignore-this: d1f5166d72cc711f7e0d9981eac9105e
308]
309[docs/webapi.rst: capitalization, formatting of section on URL character encoding, and a correction about Internet Explorer.
310david-sarah@jacaranda.org**20101230034049
311 Ignore-this: b3b9819d2fb264b4cdc5c8afd4e8c48d
312]
313[docs: corrections and clarifications.
314david-sarah@jacaranda.org**20101227051056
315 Ignore-this: e33202858c7644c58f3f924b164294b6
316]
317[docs: more formatting cleanups and corrections. Spell webapi and wapi as web-API.
318david-sarah@jacaranda.org**20101227050533
319 Ignore-this: 18b23cbfb780df585d8a722a1ec63e94
320]
321[docs/debian.rst: bring description of building dependencies from source up-to-date, and change hostname from allmydata.com to tahoe-lafs.org.
322david-sarah@jacaranda.org**20101212222912
323 Ignore-this: f38462afc88b4475195610385a28391c
324]
325[docs/architecture.rst: correct rst syntax.
326david-sarah@jacaranda.org**20101212202003
327 Ignore-this: 3fbe12feb28bec6f1c63aedbc79aad21
328]
329[docs/architecture.rst: formatting.
330david-sarah@jacaranda.org**20101212201719
331 Ignore-this: 305fa5dfc2939355eaf6d0d2161eb1ff
332]
333[docs: linkification, wording improvements.
334david-sarah@jacaranda.org**20101212201234
335 Ignore-this: 4e67287f527a8bc728cfbd93255d2aae
336]
337[docs: formatting.
338david-sarah@jacaranda.org**20101212201115
339 Ignore-this: 2e0ed394ac7726651d3a4f2c4b0d3798
340]
341[docs/configuration.rst: more formatting tweaks; which -> that.
342david-sarah@jacaranda.org**20101212195522
343 Ignore-this: a7becb7021854ca5a90edd892b36fdd7
344]
345[docs/configuration.rst: more changes to formatting.
346david-sarah@jacaranda.org**20101212194511
347 Ignore-this: 491aac33e5f5268d224359f1447d10be
348]
349[docs/configuration.rst: changes to formatting (mainly putting commands and filenames in monospace).
350david-sarah@jacaranda.org**20101212181828
351 Ignore-this: 8a1480e2d5f43bee678476424615b50f
352]
353[scripts/backupdb.py: more accurate comment about path field.
354david-sarah@jacaranda.org**20101212170320
355 Ignore-this: 50e47a2228a85207bbcd188a78a0d4e6
356]
357[scripts/cli.py: fix missing 'put' in usage example for 'tahoe put'.
358david-sarah@jacaranda.org**20101212170207
359 Ignore-this: 2cbadf066fff611fc03d3c0ff97ce6ec
360]
361[docs/frontends/CLI.rst: changes to formatting (mainly putting commands and filenames in monospace), and to command syntax to reflect that DIRCAP/... is accepted. Clarify the syntax of 'tahoe put' and other minor corrections. Tahoe -> Tahoe-LAFS.
362david-sarah@jacaranda.org**20101212165800
363 Ignore-this: a123ef6b564aa8624d1e79c97068ea12
364]
365[docs/frontends/CLI.rst: Unicode arguments to 'tahoe' work on Windows as of v1.7.1.
366david-sarah@jacaranda.org**20101212063740
367 Ignore-this: 3977a99dfa86ac33a44171deaf43aaab
368]
369[docs/known_issues.rst: fix title and linkify another URL. refs #1225
370david-sarah@jacaranda.org**20101212062817
371 Ignore-this: cc91287f7fb51c23440b3d2fe79c449c
372]
373[docs/known_issues.rst: fix an external link. refs #1225
374david-sarah@jacaranda.org**20101212062435
375 Ignore-this: b8cbf12f353131756c358965c48060ec
376]
377[Fix a link from uri.rst to dirnodes.rst. refs #1225
378david-sarah@jacaranda.org**20101212054502
379 Ignore-this: af6205299f5c9a33229cab259c00f9d5
380]
381[Fix a link from webapi.rst to FTP-and-SFTP.rst. refs #1225
382david-sarah@jacaranda.org**20101212053435
383 Ignore-this: 2b9f88678c3447ea860d6b61e8799858
384]
385[More specific hyperlink to architecture.rst from helper.rst. refs #1225
386david-sarah@jacaranda.org**20101212052607
387 Ignore-this: 50424c768fca481252fabf58424852dc
388]
389[Update hyperlinks between docs, and linkify some external references. refs #1225
390david-sarah@jacaranda.org**20101212051459
391 Ignore-this: cd43a4c3d3de1f832abfa88d5fc4ace1
392]
393[docs/specifications/dirnodes.rst: fix references to mutable.rst. refs #1225
394david-sarah@jacaranda.org**20101212012720
395 Ignore-this: 6819b4b4e06e947ee48b365e840db37d
396]
397[docs/specifications/mutable.rst: correct the magic string for v1 mutable containers. refs #1225
398david-sarah@jacaranda.org**20101212011400
399 Ignore-this: 99a5fcdd40cef83dbb08f323f6cdaaca
400]
401[Move .txt files in docs/frontends and docs/specifications to .rst. refs #1225
402david-sarah@jacaranda.org**20101212010251
403 Ignore-this: 8796d35d928370f7dc6ad2dafdc1c0fe
404]
405[Convert docs/frontends and docs/specifications to reStructuredText format (not including file moves).
406david-sarah@jacaranda.org**20101212004632
407 Ignore-this: e3ceb2d832d73875abe48624ddbb5622
408]
409[scripts/cli.py: remove the disclaimer in the help for 'tahoe cp' that it does not handle non-ASCII filenames well. (At least, we intend to handle them.)
410david-sarah@jacaranda.org**20101130002145
411 Ignore-this: 94c003efaa20b9eb4a83503d79844ca
412]
413[relnotes.txt: fifth -> sixth labor-of-love release
414zooko@zooko.com**20101129045647
415 Ignore-this: 21c245015268b38916e3a138d256c09d
416]
417[Makefile: BB_BRANCH is set to the empty string for trunk, not the string 'trunk'.
418david-sarah@jacaranda.org**20101128233512
419 Ignore-this: 5a7ef8eb10475636d21b91e25b56c369
420]
421[relnotes.txt: eleventh -> twelfth release.
422david-sarah@jacaranda.org**20101128223321
423 Ignore-this: 1e26410156a665271c1170803dea2c0d
424]
425[relnotes.tst: point to known_issues.rst, not known_issues.txt.
426david-sarah@jacaranda.org**20101128222918
427 Ignore-this: 60194eb4544cac446fe4f60b3e34b887
428]
429[quickstart.html: fix link to point to allmydata-tahoe-1.8.1.zip.
430david-sarah@jacaranda.org**20101128221728
431 Ignore-this: 7b3ee86f8256aa12f5d862f689f3ee29
432]
433[TAG allmydata-tahoe-1.8.1
434david-sarah@jacaranda.org**20101128212336
435 Ignore-this: 9c18bdeaef4822f590d2a0d879e00621
436]
437Patch bundle hash:
438889c9913784be31b30f166fc1f4c9db07c41c697