Ticket #534: tahoe backup unicode support.darcspatch

File tahoe backup unicode support.darcspatch, 14.7 KB (added by zooko, at 2009-06-09T19:53:48Z)
Line 
1Tue Jun  9 13:40:33 MDT 2009  francois@ctrlaltdel.ch zooko@zooko.com
2  * cli: tahoe backup unicode support (re-recorded by Zooko to avoid conflicts in test_cli.py)
3
4New patches:
5
6[cli: tahoe backup unicode support (re-recorded by Zooko to avoid conflicts in test_cli.py)
7francois@ctrlaltdel.ch zooko@zooko.com**20090609194033
8 Ignore-this: 6a402b1d76671b024fe848d50a6b7989
9] {
10hunk ./src/allmydata/scripts/cli.py 223
11         self['exclude'] = set()
12 
13     def parseArgs(self, localdir, topath):
14-        self.from_dir = localdir
15-        self.to_dir = topath
16+        self.from_dir = argv_to_unicode(localdir)
17+        self.to_dir = argv_to_unicode(topath)
18 
19     def getSynopsis(Self):
20         return "%s backup FROM ALIAS:TO" % os.path.basename(sys.argv[0])
21hunk ./src/allmydata/scripts/tahoe_backup.py 7
22 import urllib
23 import simplejson
24 import datetime
25+import sys
26 from allmydata.scripts.common import get_alias, escape_path, DEFAULT_ALIAS
27 from allmydata.scripts.common_http import do_http
28 from allmydata import uri
29hunk ./src/allmydata/scripts/tahoe_backup.py 13
30 from allmydata.util import time_format
31 from allmydata.scripts import backupdb
32+from allmydata.util.stringutils import fs_to_unicode, unicode_to_fs, unicode_to_stdout
33+from allmydata.util.assertutil import precondition
34+from twisted.python import usage
35 
36 class HTTPError(Exception):
37     pass
38hunk ./src/allmydata/scripts/tahoe_backup.py 247
39 
40     def verboseprint(self, msg):
41         if self.verbosity >= 2:
42-            print >>self.options.stdout, msg
43+            print >>self.options.stdout, unicode_to_stdout(msg)
44 
45     def process(self, localpath, olddircap):
46hunk ./src/allmydata/scripts/tahoe_backup.py 250
47+        precondition(isinstance(localpath, unicode), localpath)
48         # returns newdircap
49 
50         self.verboseprint("processing %s, olddircap %s" % (localpath, olddircap))
51hunk ./src/allmydata/scripts/tahoe_backup.py 259
52             olddircontents = self.readdir(olddircap)
53 
54         newdircontents = {} # childname -> (type, rocap, metadata)
55-        for child in self.options.filter_listdir(os.listdir(localpath)):
56+        for child in self.options.filter_listdir(os.listdir(unicode_to_fs(localpath))):
57+            child = fs_to_unicode(child)
58             childpath = os.path.join(localpath, child)
59             if os.path.isdir(childpath):
60                 metadata = get_local_metadata(childpath)
61hunk ./src/allmydata/scripts/tahoe_backup.py 346
62         return contents
63 
64     def upload(self, childpath):
65+        precondition(isinstance(childpath, unicode), childpath)
66+
67         #self.verboseprint("uploading %s.." % childpath)
68         metadata = get_local_metadata(childpath)
69 
70hunk ./src/allmydata/scripts/tahoe_backup.py 356
71 
72         if must_upload:
73             self.verboseprint("uploading %s.." % childpath)
74-            infileobj = open(os.path.expanduser(childpath), "rb")
75+            infileobj = open(unicode_to_fs(os.path.expanduser(childpath)), "rb")
76             url = self.options['node-url'] + "uri"
77             resp = do_http("PUT", url, infileobj)
78             if resp.status not in (200, 201):
79hunk ./src/allmydata/test/test_cli.py 874
80         self.writeto("parent/subdir/bar.txt", "bar\n" * 1000)
81         self.writeto("parent/blah.txt", "blah")
82 
83-        def do_backup(verbose=False):
84+        def do_backup(use_backupdb=True, verbose=False):
85             cmd = ["backup"]
86             if verbose:
87                 cmd.append("--verbose")
88hunk ./src/allmydata/test/test_cli.py 896
89             self.failUnlessEqual(err, "")
90             self.failUnlessEqual(rc, 0)
91             fu, fr, dc, dr = self.count_output(out)
92-            # foo.txt, bar.txt, blah.txt
93-            self.failUnlessEqual(fu, 3)
94+            # foo.txt, bar.txt, blah.txt, ärtonwall.txt
95+            self.failUnlessEqual(fu, 4)
96             self.failUnlessEqual(fr, 0)
97             # empty, home, home/parent, home/parent/subdir
98             self.failUnlessEqual(dc, 4)
99hunk ./src/allmydata/test/test_cli.py 946
100             self.failUnlessEqual(rc, 0)
101             if have_bdb:
102                 fu, fr, dc, dr = self.count_output(out)
103-                # foo.txt, bar.txt, blah.txt
104+                # foo.txt, bar.txt, blah.txt, ärtonwall.txt
105                 self.failUnlessEqual(fu, 0)
106hunk ./src/allmydata/test/test_cli.py 948
107-                self.failUnlessEqual(fr, 3)
108+                self.failUnlessEqual(fr, 4)
109                 # empty, home, home/parent, home/parent/subdir
110                 self.failUnlessEqual(dc, 0)
111                 self.failUnlessEqual(dr, 4)
112hunk ./src/allmydata/test/test_cli.py 976
113                 self.failUnlessEqual(rc, 0)
114                 fu, fr, dc, dr = self.count_output(out)
115                 fchecked, dchecked, dread = self.count_output2(out)
116-                self.failUnlessEqual(fchecked, 3)
117+                self.failUnlessEqual(fchecked, 4)
118                 self.failUnlessEqual(fu, 0)
119hunk ./src/allmydata/test/test_cli.py 978
120-                self.failUnlessEqual(fr, 3)
121+                self.failUnlessEqual(fr, 4)
122                 # TODO: backupdb doesn't do dirs yet; when it does, this will
123                 # change to dchecked=4, and maybe dread=0
124                 self.failUnlessEqual(dchecked, 0)
125hunk ./src/allmydata/test/test_cli.py 1024
126                 fu, fr, dc, dr = self.count_output(out)
127                 # new foo.txt, surprise file, subfile, empty
128                 self.failUnlessEqual(fu, 4)
129-                # old bar.txt
130-                self.failUnlessEqual(fr, 1)
131+                # old bar.txt, ärtonwall.txt
132+                self.failUnlessEqual(fr, 2)
133                 # home, parent, subdir, blah.txt, surprisedir
134                 self.failUnlessEqual(dc, 5)
135                 self.failUnlessEqual(dr, 0)
136hunk ./src/allmydata/test/test_cli.py 1056
137             self.failUnlessEqual(out, "foo")
138         d.addCallback(_check8)
139 
140+        d.addCallback(self.stall, 1.1)
141+        d.addCallback(lambda res: do_backup(use_backupdb=False))
142+        def _check9((rc, out, err)):
143+            # --no-backupdb means re-upload everything. We still get to
144+            # re-use the directories, since nothing changed.
145+            self.failUnlessEqual(err, "")
146+            self.failUnlessEqual(rc, 0)
147+            fu, fr, dc, dr = self.count_output(out)
148+            self.failUnlessEqual(fu, 5)
149+            self.failUnlessEqual(fr, 0)
150+            self.failUnlessEqual(dc, 0)
151+            self.failUnlessEqual(dr, 5)
152+        d.addCallback(_check9)
153+
154         return d
155 
156     # on our old dapper buildslave, this test takes a long time (usually
157}
158
159Context:
160
161[test_cli.Backup: increase timeout massively, it takes 1200s on zandr's ARM linkstation
162warner@lothar.com**20090609052801] 
163[tests: double the timeouts on some tests which time-out on Francois's box
164zooko@zooko.com**20090609021753
165 Ignore-this: b2727b04402f24a9b9123d2f84068106
166] 
167[tests: bump up timeouts so that the tests can finish before timeout on Francois's little arm box
168zooko@zooko.com**20090608225557
169 Ignore-this: fb83698338b2f12546cd3e1dcb896d34
170] 
171[tests: increase timeouts on some other tests that timed-out on Francois's arm box
172zooko@zooko.com**20090605143437
173 Ignore-this: 2903cc20d914fc074c8d7a6c47740ba6
174] 
175[tests: bump up the timeout on a bunch of tests that took longer than the default timeout (120s) on François Lenny-armv5tel
176zooko@zooko.com**20090605031444
177 Ignore-this: 84d67849b1f8edc88bf7001e31b5f7f3
178] 
179[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
180zooko@zooko.com**20090604173131
181 Ignore-this: 8200a9fdfc49243c280ecd1d0c44fa19
182 Fixes #728.
183] 
184[more refactoring: move get_all_serverids() and get_nickname_for_serverid() from Client to storage_broker
185warner@lothar.com**20090602030750] 
186[more storage_broker refactoring: downloader gets a broker instead of a client,
187warner@lothar.com**20090602022511
188 use Client.get_storage_broker() accessor instead of direct attribute access.
189] 
190[test_runner.py: remove test_client_no_noise: the issue in question is
191warner@lothar.com**20090601225007
192 ticketed in http://divmod.org/trac/ticket/2830 and doesn't need a Tahoe-side
193 change, plus this test fails on win32 for unrelated reasons (and test_client
194 is the place to think about the win32 issue).
195] 
196[remove plaintext-hashing code from the helper interface, to close #722
197warner@lothar.com**20090601224916
198 and deny the Helper the ability to mount a partial-information-guessing
199 attack. This will probably break compatibility between new clients and very
200 old (pre-1.0) helpers.
201] 
202[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
203warner@lothar.com**20090601210604] 
204[mutable: catch and display first error, so code bugs which break all servers get displayed better
205warner@lothar.com**20090601210407] 
206[misc/run-with-pythonpath.py: exec() the child (on unix), to remove the intermediate process
207warner@lothar.com**20090601210137] 
208[setup: require pysqlite >= v2.0.5. if we are running on Python < 2.5
209zooko@zooko.com**20090604154548
210 Ignore-this: cf04f46079821df209d01dad2e24b40b
211] 
212[setup: add pysqlite and sqlite to get_package_versions()
213zooko@zooko.com**20090604153728
214 Ignore-this: a1dea7fabeab2b08fb0d8d462facdb4d
215] 
216[docs: small edit to about.html
217zooko@zooko.com**20090528233422
218 Ignore-this: 1cfbb1f8426ed6d63b2d3952e4464ddc
219] 
220[docs: add links to Tahoe-LAFS for Paranoids and Tahoe-LAFS for Corporates in about.html
221zooko@zooko.com**20090528232717
222 Ignore-this: 7b70baa700d6b6f6e9ceec4132efe5
223] 
224[docs: edit about.html and include network-and-reliance-topology.png (loaded from http://allmydata.org )
225zooko@zooko.com**20090527150916
226 Ignore-this: 44adc61cde8ced8be2f0a7dfc7d95dad
227] 
228[docs: a few more edits to network-and-reliance-topology.svg
229zooko@zooko.com**20090527150458
230 Ignore-this: 2eac8c33fe71be25ff809b399c6193c1
231] 
232[docs: update NEWS, relnotes.txt, CREDITS to mention WUI Style
233zooko@zooko.com**20090526233654
234 Ignore-this: 72d16ec833bc4a22af23d29ea1d5ff8b
235] 
236[docs: update network-and-reliance-topology.svg for beauty and clarity
237zooko@zooko.com**20090527031123
238 Ignore-this: 5510914849771900ac29b4312470d84
239] 
240[Modify markup of Tahoe web pages to be more amenable to styling; some minor changes of wording.
241Kevin Reid <kpreid@mac.com>**20090526232545
242 Ignore-this: 8845937f0df6c7ddc07abe3211428a6f
243] 
244[Tweak wording in directory page: not-read-only is "modifiable", mention creating a directory _in this directory_.
245Kevin Reid <kpreid@mac.com>**20090526232414
246 Ignore-this: f006ec52ba2051802e025a60bcface56
247] 
248[Comment on duplication of code/markup found during styling project.
249Kevin Reid <kpreid@mac.com>**20090503203442
250 Ignore-this: a4b7f9f0ab57d2c03be9ba761be8d854
251] 
252[Add CSS styles to spiff up the Tahoe WUI's appearance, particularly the welcome page and directories.
253Kevin Reid <kpreid@mac.com>**20090503203142
254 Ignore-this: 5c50af241c1a958b5180ef2b6a49f626
255] 
256[Link all Tahoe web pages to the /tahoe_css stylesheet which already exists.
257Kevin Reid <kpreid@mac.com>**20090503202533
258 Ignore-this: 2ea8d14d3168b9502cf39d5ea3f2f2a8
259] 
260[Fix broken link from Provisioning to Reliability page.
261Kevin Reid <kpreid@mac.com>**20090501191050
262 Ignore-this: 56dc1a5e659b70cc02dc4df7b5d518cd
263] 
264[docs: network-and-reliance-topology.svg: nicer server icons, mv out of the "specifications" subdir
265zooko@zooko.com**20090526165842
266 Ignore-this: 8f47ab3a0ab782c1f0d46e10bcaebe5b
267] 
268[accounting-overview.txt: more edits
269warner@lothar.com**20090523190359] 
270[accounting-overview.txt: small edits
271warner@lothar.com**20090523184011] 
272[_auto_deps.py: require foolscap-0.4.1, which adds an important fix for py2.4
273warner@lothar.com**20090523011103] 
274[immutable/encode.py: tolerate immediate _remove_shareholder by copying the
275warner@lothar.com**20090522184424
276 landlord list before iterating over it. This can probably only happen in unit
277 tests, but cleaning it up makes certain test failures easier to analyze.
278] 
279[switch to using RemoteException instead of 'wrapped' RemoteReferences. Should fix #653, the rref-EQ problem
280warner@lothar.com**20090522004632] 
281[switch all foolscap imports to use foolscap.api or foolscap.logging
282warner@lothar.com**20090522003823] 
283[_auto_deps.py: bump our foolscap dependency to 0.4.0, since I'm about to start using its new features
284warner@lothar.com**20090522002100] 
285[test_runner.py: fix minor typo
286warner@lothar.com**20090520033620] 
287[docs: update network-and-reliance-topology.svg
288zooko@zooko.com**20090526163105
289 Ignore-this: 2b864b4ed8743d4a15dfbb7eff3fa561
290] 
291[setup: fix bug (wrong import) in error message, as noticed by pyflakes
292zooko@zooko.com**20090519195642
293 Ignore-this: f1b9f8c00b46c1b5f2f20e5fc424f341
294] 
295[setup: fix trivial bug in recent patch to test base64.py at startup
296zooko@zooko.com**20090519195129
297 Ignore-this: f6be038f74b53ca69e7109fe34adfbc
298] 
299[setup: make Tahoe exit at startup with a useful error message if the base64.py module is buggy (fixes part of #710)
300zooko@zooko.com**20090519194555
301 Ignore-this: aa4d398235ddca8d417d61c9688e154
302] 
303[test_introducer.py: add a test for the python2.4.0/2.4.1 bug in base64.b32decode
304warner@lothar.com**20090519034101] 
305[immutable WriteBucketProxy: use pipeline to speed up uploads by overlapping roundtrips, for #392
306warner@lothar.com**20090518234422] 
307[util/pipeline.py: new utility class to manage size-limited work pipelines, for #392
308warner@lothar.com**20090518234326] 
309[docs: add a diagram that I'm about to show to the Boulder Linux Users Group: network-and-reliance-topology.svg
310zooko@zooko.com**20090514232059
311 Ignore-this: 2420c0a7c254c9f0f2349d9130490d33
312] 
313[tests: mark test_runner as coded in utf-8 instead of ascii
314zooko@zooko.com**20090507223151
315 Ignore-this: ccf1ba9e5a9b53602701a36f9fdb545e
316] 
317[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
318zooko@zooko.com**20090507215012
319 Ignore-this: ba18fe6832ba255d4971e8f623ed7da5
320] 
321[setup: fix comment in setup.py
322zooko@zooko.com**20090507215003
323 Ignore-this: c46ef664630d52733138ef7fbc551c1c
324] 
325[docs: how_to_make_a_tahoe_release.txt: a couple of small edits
326zooko@zooko.com**20090507214932
327 Ignore-this: ae92aa835ad369f4b9e6e49d681957a3
328] 
329[.darcs-boringfile: also ignore .gitignore
330warner@allmydata.com**20090415210550
331 Ignore-this: d29db314a1e506f6240859559436b4c3
332] 
333[.darcs-boringfile: ignore .git, I'm starting to play around with it
334warner@allmydata.com**20090415205929
335 Ignore-this: 89234453516483c9586cd6e1351e88b5
336] 
337[fix quicktest: stop using setuptools, add misc/run-with-pythonpath.py, to make it run faster
338warner@lothar.com**20090414201400] 
339[TAG allmydata-tahoe-1.4.1
340zooko@zooko.com**20090414025636
341 Ignore-this: de78fc32364c83e9f4e26b5abcfdea4a
342] 
343Patch bundle hash:
344144a96e4197394dd73b86915aa09bb8cf1f5894d