Ticket #534: tahoe cp unicode support.darcspatch

File tahoe cp unicode support.darcspatch, 15.2 KB (added by zooko, at 2009-06-09T19:53:07Z)
Line 
1Mon Apr 27 07:52:03 MDT 2009  francois@ctrlaltdel.ch
2  * cli: tahoe cp unicode support
3
4New patches:
5
6[cli: tahoe cp unicode support
7francois@ctrlaltdel.ch**20090427135203
8 Ignore-this: cd26cdd0753625d1c1252cffd976abd6
9] {
10hunk ./src/allmydata/scripts/cli.py 179
11     def parseArgs(self, *args):
12         if len(args) < 2:
13             raise usage.UsageError("cp requires at least two arguments")
14-        self.sources = args[:-1]
15-        self.destination = args[-1]
16+        self.sources = map(argv_to_unicode, args[:-1])
17+        self.destination = argv_to_unicode(args[-1])
18 
19 class RmOptions(VDriveOptions):
20     def parseArgs(self, where):
21hunk ./src/allmydata/scripts/cli.py 184
22-        self.where = where
23+        self.where = argv_to_unicode(where)
24 
25     def getSynopsis(self):
26         return "%s rm VDRIVE_FILE" % (os.path.basename(sys.argv[0]),)
27hunk ./src/allmydata/scripts/tahoe_cp.py 7
28 import simplejson
29 from cStringIO import StringIO
30 from twisted.python.failure import Failure
31+import sys
32 from allmydata.scripts.common import get_alias, escape_path, DefaultAliasMarker
33 from allmydata.scripts.common_http import do_http
34 from allmydata import uri
35hunk ./src/allmydata/scripts/tahoe_cp.py 11
36+from twisted.python import usage
37+from allmydata.util.stringutils import fs_to_unicode, unicode_to_fs, unicode_to_url
38+from allmydata.util.assertutil import precondition
39 
40 def ascii_or_none(s):
41     if s is None:
42hunk ./src/allmydata/scripts/tahoe_cp.py 76
43 
44 class LocalFileSource:
45     def __init__(self, pathname):
46+        precondition(isinstance(pathname, unicode), pathname)
47         self.pathname = pathname
48 
49     def need_to_copy_bytes(self):
50hunk ./src/allmydata/scripts/tahoe_cp.py 87
51 
52 class LocalFileTarget:
53     def __init__(self, pathname):
54+        precondition(isinstance(pathname, unicode), pathname)
55         self.pathname = pathname
56     def put_file(self, inf):
57         outf = open(self.pathname, "wb")
58hunk ./src/allmydata/scripts/tahoe_cp.py 100
59 
60 class LocalMissingTarget:
61     def __init__(self, pathname):
62+        precondition(isinstance(pathname, unicode), pathname)
63         self.pathname = pathname
64 
65     def put_file(self, inf):
66hunk ./src/allmydata/scripts/tahoe_cp.py 114
67 
68 class LocalDirectorySource:
69     def __init__(self, progressfunc, pathname):
70+        precondition(isinstance(pathname, unicode), pathname)
71+
72         self.progressfunc = progressfunc
73         self.pathname = pathname
74         self.children = None
75hunk ./src/allmydata/scripts/tahoe_cp.py 124
76         if self.children is not None:
77             return
78         self.children = {}
79-        children = os.listdir(self.pathname)
80+        children = os.listdir(unicode_to_fs(self.pathname))
81         for i,n in enumerate(children):
82hunk ./src/allmydata/scripts/tahoe_cp.py 126
83+            n = fs_to_unicode(n)
84             self.progressfunc("examining %d of %d" % (i, len(children)))
85             pn = os.path.join(self.pathname, n)
86             if os.path.isdir(pn):
87hunk ./src/allmydata/scripts/tahoe_cp.py 142
88 
89 class LocalDirectoryTarget:
90     def __init__(self, progressfunc, pathname):
91+        precondition(isinstance(pathname, unicode), pathname)
92+
93         self.progressfunc = progressfunc
94         self.pathname = pathname
95         self.children = None
96hunk ./src/allmydata/scripts/tahoe_cp.py 152
97         if self.children is not None:
98             return
99         self.children = {}
100-        children = os.listdir(self.pathname)
101+        children = os.listdir(unicode_to_fs(self.pathname))
102         for i,n in enumerate(children):
103hunk ./src/allmydata/scripts/tahoe_cp.py 154
104+            n = fs_to_unicode(n)
105             self.progressfunc("examining %d of %d" % (i, len(children)))
106             pn = os.path.join(self.pathname, n)
107             if os.path.isdir(pn):
108hunk ./src/allmydata/scripts/tahoe_cp.py 176
109         return LocalDirectoryTarget(self.progressfunc, pathname)
110 
111     def put_file(self, name, inf):
112+        precondition(isinstance(name, unicode), name)
113         pathname = os.path.join(self.pathname, name)
114hunk ./src/allmydata/scripts/tahoe_cp.py 178
115-        outf = open(pathname, "wb")
116+        outf = open(unicode_to_fs(pathname), "wb")
117         while True:
118             data = inf.read(32768)
119             if not data:
120hunk ./src/allmydata/scripts/tahoe_cp.py 367
121                 if self.writecap:
122                     url = self.nodeurl + "/".join(["uri",
123                                                    urllib.quote(self.writecap),
124-                                                   urllib.quote(name.encode('utf-8'))])
125+                                                   urllib.quote(unicode_to_url(name))])
126                 self.children[name] = TahoeFileTarget(self.nodeurl, mutable,
127                                                       writecap, readcap, url)
128             else:
129hunk ./src/allmydata/test/test_cli.py 798
130     def test_unicode_filename(self):
131         self.basedir = "cli/Cp/unicode_filename"
132         self.set_up_grid()
133+        d = self.do_cli("create-alias", "tahoe")
134+
135+        # Use unicode strings when calling os functions
136+        if sys.getfilesystemencoding() == "ANSI_X3.4-1968":
137+            fn1 = os.path.join(self.basedir, u"Artonwall")
138+        else:
139+            fn1 = os.path.join(self.basedir, u"Ärtonwall")
140 
141hunk ./src/allmydata/test/test_cli.py 806
142-        fn1 = os.path.join(self.basedir, "Ärtonwall")
143         DATA1 = "unicode file content"
144         open(fn1, "wb").write(DATA1)
145hunk ./src/allmydata/test/test_cli.py 808
146+        d.addCallback(lambda res: self.do_cli("cp", fn1.encode('utf-8'), "tahoe:Ärtonwall"))
147+
148+        d.addCallback(lambda res: self.do_cli("get", "tahoe:Ärtonwall"))
149+        d.addCallback(lambda (rc,out,err): self.failUnlessEqual(out, DATA1))
150+
151 
152hunk ./src/allmydata/test/test_cli.py 814
153-        fn2 = os.path.join(self.basedir, "Metallica")
154+        fn2 = os.path.join(self.basedir, u"Metallica")
155         DATA2 = "non-unicode file content"
156         open(fn2, "wb").write(DATA2)
157 
158hunk ./src/allmydata/test/test_cli.py 821
159         # Bug #534
160         # Assure that uploading a file whose name contains unicode character doesn't
161         # prevent further uploads in the same directory
162-        d = self.do_cli("create-alias", "tahoe")
163-        d.addCallback(lambda res: self.do_cli("cp", fn1, "tahoe:"))
164-        d.addCallback(lambda res: self.do_cli("cp", fn2, "tahoe:"))
165-
166-        d.addCallback(lambda res: self.do_cli("get", "tahoe:Ärtonwall"))
167-        d.addCallback(lambda (rc,out,err): self.failUnlessEqual(out, DATA1))
168+        d.addCallback(lambda res: self.do_cli("cp", fn2.encode('utf-8'), "tahoe:"))
169 
170         d.addCallback(lambda res: self.do_cli("get", "tahoe:Metallica"))
171         d.addCallback(lambda (rc,out,err): self.failUnlessEqual(out, DATA2))
172hunk ./src/allmydata/test/test_cli.py 826
173 
174+        d.addCallback(lambda res: self.do_cli("ls", "tahoe:"))
175+
176         return d
177     test_unicode_filename.todo = "This behavior is not yet supported, although it does happen to work (for reasons that are ill-understood) on many platforms.  See issue ticket #534."
178 
179}
180
181Context:
182
183[test_cli.Backup: increase timeout massively, it takes 1200s on zandr's ARM linkstation
184warner@lothar.com**20090609052801] 
185[tests: double the timeouts on some tests which time-out on Francois's box
186zooko@zooko.com**20090609021753
187 Ignore-this: b2727b04402f24a9b9123d2f84068106
188] 
189[tests: bump up timeouts so that the tests can finish before timeout on Francois's little arm box
190zooko@zooko.com**20090608225557
191 Ignore-this: fb83698338b2f12546cd3e1dcb896d34
192] 
193[tests: increase timeouts on some other tests that timed-out on Francois's arm box
194zooko@zooko.com**20090605143437
195 Ignore-this: 2903cc20d914fc074c8d7a6c47740ba6
196] 
197[tests: bump up the timeout on a bunch of tests that took longer than the default timeout (120s) on François Lenny-armv5tel
198zooko@zooko.com**20090605031444
199 Ignore-this: 84d67849b1f8edc88bf7001e31b5f7f3
200] 
201[backup: remove the --no-backupdb command, the handling of "can't import sqlite", and the related tests, and change an error message to more correctly indicate failure to load the database from disk rather than failure to import sqlite module
202zooko@zooko.com**20090604173131
203 Ignore-this: 8200a9fdfc49243c280ecd1d0c44fa19
204 Fixes #728.
205] 
206[more refactoring: move get_all_serverids() and get_nickname_for_serverid() from Client to storage_broker
207warner@lothar.com**20090602030750] 
208[more storage_broker refactoring: downloader gets a broker instead of a client,
209warner@lothar.com**20090602022511
210 use Client.get_storage_broker() accessor instead of direct attribute access.
211] 
212[test_runner.py: remove test_client_no_noise: the issue in question is
213warner@lothar.com**20090601225007
214 ticketed in http://divmod.org/trac/ticket/2830 and doesn't need a Tahoe-side
215 change, plus this test fails on win32 for unrelated reasons (and test_client
216 is the place to think about the win32 issue).
217] 
218[remove plaintext-hashing code from the helper interface, to close #722
219warner@lothar.com**20090601224916
220 and deny the Helper the ability to mount a partial-information-guessing
221 attack. This will probably break compatibility between new clients and very
222 old (pre-1.0) helpers.
223] 
224[start to factor server-connection-management into a distinct 'StorageServerFarmBroker' object, separate from the client and the introducer. This is the starting point for #467: static server selection
225warner@lothar.com**20090601210604] 
226[mutable: catch and display first error, so code bugs which break all servers get displayed better
227warner@lothar.com**20090601210407] 
228[misc/run-with-pythonpath.py: exec() the child (on unix), to remove the intermediate process
229warner@lothar.com**20090601210137] 
230[setup: require pysqlite >= v2.0.5. if we are running on Python < 2.5
231zooko@zooko.com**20090604154548
232 Ignore-this: cf04f46079821df209d01dad2e24b40b
233] 
234[setup: add pysqlite and sqlite to get_package_versions()
235zooko@zooko.com**20090604153728
236 Ignore-this: a1dea7fabeab2b08fb0d8d462facdb4d
237] 
238[docs: small edit to about.html
239zooko@zooko.com**20090528233422
240 Ignore-this: 1cfbb1f8426ed6d63b2d3952e4464ddc
241] 
242[docs: add links to Tahoe-LAFS for Paranoids and Tahoe-LAFS for Corporates in about.html
243zooko@zooko.com**20090528232717
244 Ignore-this: 7b70baa700d6b6f6e9ceec4132efe5
245] 
246[docs: edit about.html and include network-and-reliance-topology.png (loaded from http://allmydata.org )
247zooko@zooko.com**20090527150916
248 Ignore-this: 44adc61cde8ced8be2f0a7dfc7d95dad
249] 
250[docs: a few more edits to network-and-reliance-topology.svg
251zooko@zooko.com**20090527150458
252 Ignore-this: 2eac8c33fe71be25ff809b399c6193c1
253] 
254[docs: update NEWS, relnotes.txt, CREDITS to mention WUI Style
255zooko@zooko.com**20090526233654
256 Ignore-this: 72d16ec833bc4a22af23d29ea1d5ff8b
257] 
258[docs: update network-and-reliance-topology.svg for beauty and clarity
259zooko@zooko.com**20090527031123
260 Ignore-this: 5510914849771900ac29b4312470d84
261] 
262[Modify markup of Tahoe web pages to be more amenable to styling; some minor changes of wording.
263Kevin Reid <kpreid@mac.com>**20090526232545
264 Ignore-this: 8845937f0df6c7ddc07abe3211428a6f
265] 
266[Tweak wording in directory page: not-read-only is "modifiable", mention creating a directory _in this directory_.
267Kevin Reid <kpreid@mac.com>**20090526232414
268 Ignore-this: f006ec52ba2051802e025a60bcface56
269] 
270[Comment on duplication of code/markup found during styling project.
271Kevin Reid <kpreid@mac.com>**20090503203442
272 Ignore-this: a4b7f9f0ab57d2c03be9ba761be8d854
273] 
274[Add CSS styles to spiff up the Tahoe WUI's appearance, particularly the welcome page and directories.
275Kevin Reid <kpreid@mac.com>**20090503203142
276 Ignore-this: 5c50af241c1a958b5180ef2b6a49f626
277] 
278[Link all Tahoe web pages to the /tahoe_css stylesheet which already exists.
279Kevin Reid <kpreid@mac.com>**20090503202533
280 Ignore-this: 2ea8d14d3168b9502cf39d5ea3f2f2a8
281] 
282[Fix broken link from Provisioning to Reliability page.
283Kevin Reid <kpreid@mac.com>**20090501191050
284 Ignore-this: 56dc1a5e659b70cc02dc4df7b5d518cd
285] 
286[docs: network-and-reliance-topology.svg: nicer server icons, mv out of the "specifications" subdir
287zooko@zooko.com**20090526165842
288 Ignore-this: 8f47ab3a0ab782c1f0d46e10bcaebe5b
289] 
290[accounting-overview.txt: more edits
291warner@lothar.com**20090523190359] 
292[accounting-overview.txt: small edits
293warner@lothar.com**20090523184011] 
294[_auto_deps.py: require foolscap-0.4.1, which adds an important fix for py2.4
295warner@lothar.com**20090523011103] 
296[immutable/encode.py: tolerate immediate _remove_shareholder by copying the
297warner@lothar.com**20090522184424
298 landlord list before iterating over it. This can probably only happen in unit
299 tests, but cleaning it up makes certain test failures easier to analyze.
300] 
301[switch to using RemoteException instead of 'wrapped' RemoteReferences. Should fix #653, the rref-EQ problem
302warner@lothar.com**20090522004632] 
303[switch all foolscap imports to use foolscap.api or foolscap.logging
304warner@lothar.com**20090522003823] 
305[_auto_deps.py: bump our foolscap dependency to 0.4.0, since I'm about to start using its new features
306warner@lothar.com**20090522002100] 
307[test_runner.py: fix minor typo
308warner@lothar.com**20090520033620] 
309[docs: update network-and-reliance-topology.svg
310zooko@zooko.com**20090526163105
311 Ignore-this: 2b864b4ed8743d4a15dfbb7eff3fa561
312] 
313[setup: fix bug (wrong import) in error message, as noticed by pyflakes
314zooko@zooko.com**20090519195642
315 Ignore-this: f1b9f8c00b46c1b5f2f20e5fc424f341
316] 
317[setup: fix trivial bug in recent patch to test base64.py at startup
318zooko@zooko.com**20090519195129
319 Ignore-this: f6be038f74b53ca69e7109fe34adfbc
320] 
321[setup: make Tahoe exit at startup with a useful error message if the base64.py module is buggy (fixes part of #710)
322zooko@zooko.com**20090519194555
323 Ignore-this: aa4d398235ddca8d417d61c9688e154
324] 
325[test_introducer.py: add a test for the python2.4.0/2.4.1 bug in base64.b32decode
326warner@lothar.com**20090519034101] 
327[immutable WriteBucketProxy: use pipeline to speed up uploads by overlapping roundtrips, for #392
328warner@lothar.com**20090518234422] 
329[util/pipeline.py: new utility class to manage size-limited work pipelines, for #392
330warner@lothar.com**20090518234326] 
331[docs: add a diagram that I'm about to show to the Boulder Linux Users Group: network-and-reliance-topology.svg
332zooko@zooko.com**20090514232059
333 Ignore-this: 2420c0a7c254c9f0f2349d9130490d33
334] 
335[tests: mark test_runner as coded in utf-8 instead of ascii
336zooko@zooko.com**20090507223151
337 Ignore-this: ccf1ba9e5a9b53602701a36f9fdb545e
338] 
339[tests: raise timeout on test_runner.RunNode.test_introducer from 120s to 240s, since it hit the 120s time-out on François Lenny-armv5tel
340zooko@zooko.com**20090507215012
341 Ignore-this: ba18fe6832ba255d4971e8f623ed7da5
342] 
343[setup: fix comment in setup.py
344zooko@zooko.com**20090507215003
345 Ignore-this: c46ef664630d52733138ef7fbc551c1c
346] 
347[docs: how_to_make_a_tahoe_release.txt: a couple of small edits
348zooko@zooko.com**20090507214932
349 Ignore-this: ae92aa835ad369f4b9e6e49d681957a3
350] 
351[.darcs-boringfile: also ignore .gitignore
352warner@allmydata.com**20090415210550
353 Ignore-this: d29db314a1e506f6240859559436b4c3
354] 
355[.darcs-boringfile: ignore .git, I'm starting to play around with it
356warner@allmydata.com**20090415205929
357 Ignore-this: 89234453516483c9586cd6e1351e88b5
358] 
359[fix quicktest: stop using setuptools, add misc/run-with-pythonpath.py, to make it run faster
360warner@lothar.com**20090414201400] 
361[TAG allmydata-tahoe-1.4.1
362zooko@zooko.com**20090414025636
363 Ignore-this: de78fc32364c83e9f4e26b5abcfdea4a
364] 
365Patch bundle hash:
3666d069c7520dcb013c4be5b945101a28ea4d4f7c2