Ticket #1388: nicely-report-unparseable-versions.darcs.patch

File nicely-report-unparseable-versions.darcs.patch, 10.0 KB (added by davidsarah, at 2011-04-01T20:29:54Z)

allmydata/init.py: Nicer reporting of unparseable version numbers in dependencies. fixes #1388

Line 
11 patch for repository http://tahoe-lafs.org/source/tahoe-lafs/trunk:
2
3Fri Apr  1 21:27:50 BST 2011  david-sarah@jacaranda.org
4  * allmydata/__init__.py: Nicer reporting of unparseable version numbers in dependencies. fixes #1388
5
6New patches:
7
8[allmydata/__init__.py: Nicer reporting of unparseable version numbers in dependencies. fixes #1388
9david-sarah@jacaranda.org**20110401202750
10 Ignore-this: 9c6bd599259d2405e1caadbb3e0d8c7f
11] {
12hunk ./src/allmydata/__init__.py 136
13 
14 
15 from allmydata.util import verlib
16-def normalized_version(verstr):
17-    return verlib.NormalizedVersion(verlib.suggest_normalized_version(verstr))
18+def normalized_version(verstr, what=None):
19+    try:
20+        return verlib.NormalizedVersion(verlib.suggest_normalized_version(verstr))
21+    except (StandardError, verlib.IrrationalVersionError), e:
22+        cls, value, traceback = sys.exc_info()
23+        raise PackagingError, ("could not parse %s due to %s: %s"
24+                               % (what or repr(verstr), cls.__name__, value)), traceback
25 
26 
27 def get_package_versions_and_locations():
28hunk ./src/allmydata/__init__.py 225
29         raise ImportError("could not import %r for requirement %r" % (comment, req))
30     if actual == 'unknown':
31         return
32-    actualver = normalized_version(actual)
33+    actualver = normalized_version(actual, what="actual version %r of %s from %r" % (actual, name, location))
34 
35     for r in reqlist:
36         s = r.split('>=')
37hunk ./src/allmydata/__init__.py 231
38         if len(s) == 2:
39             required = s[1].strip(' ')
40-            if actualver >= normalized_version(required):
41+            if actualver >= normalized_version(required, what="required minimum version %r in %r" % (required, req)):
42                 return  # minimum requirement met
43         else:
44             s = r.split('==')
45hunk ./src/allmydata/__init__.py 237
46             if len(s) == 2:
47                 required = s[1].strip(' ')
48-                if actualver == normalized_version(required):
49+                if actualver == normalized_version(required, what="required exact version %r in %r" % (required, req)):
50                     return  # exact requirement met
51             else:
52                 raise PackagingError("no version info or could not understand requirement %r" % (req,))
53hunk ./src/allmydata/test/test_version.py 23
54 
55         check_requirement("foolscap[secure_connections] >= 0.6.0", {"foolscap": ("0.7.0", "", None)})
56 
57+        try:
58+            check_requirement("foolscap[secure_connections] >= 0.6.0", {"foolscap": ("0.6.1+", "", None)})
59+            # succeeding is ok
60+        except PackagingError, e:
61+            self.failUnlessIn("could not parse", str(e))
62+
63         self.failUnlessRaises(PackagingError, check_requirement,
64                               "foolscap[secure_connections] >= 0.6.0", {"foolscap": ("0.5.1", "", None)})
65         self.failUnlessRaises(PackagingError, check_requirement,
66hunk ./src/allmydata/test/test_version.py 35
67                               "pycrypto == 2.0.1, == 2.1, >= 2.3", {"pycrypto": ("2.2.0", "", None)})
68         self.failUnlessRaises(PackagingError, check_requirement,
69                               "foo >= 1.0", {})
70+        self.failUnlessRaises(PackagingError, check_requirement,
71+                              "foo >= 1.0", {"foo": ("irrational", "", None)})
72 
73         self.failUnlessRaises(ImportError, check_requirement,
74                               "foo >= 1.0", {"foo": (None, None, "foomodule")})
75}
76
77Context:
78
79[update FTP-and-SFTP.rst: the necessary patch is included in Twisted-10.1
80Brian Warner <warner@lothar.com>**20110325232511
81 Ignore-this: d5307faa6900f143193bfbe14e0f01a
82]
83[control.py: remove all uses of s.get_serverid()
84warner@lothar.com**20110227011203
85 Ignore-this: f80a787953bd7fa3d40e828bde00e855
86]
87[web: remove some uses of s.get_serverid(), not all
88warner@lothar.com**20110227011159
89 Ignore-this: a9347d9cf6436537a47edc6efde9f8be
90]
91[immutable/downloader/fetcher.py: remove all get_serverid() calls
92warner@lothar.com**20110227011156
93 Ignore-this: fb5ef018ade1749348b546ec24f7f09a
94]
95[immutable/downloader/fetcher.py: fix diversity bug in server-response handling
96warner@lothar.com**20110227011153
97 Ignore-this: bcd62232c9159371ae8a16ff63d22c1b
98 
99 When blocks terminate (either COMPLETE or CORRUPT/DEAD/BADSEGNUM), the
100 _shares_from_server dict was being popped incorrectly (using shnum as the
101 index instead of serverid). I'm still thinking through the consequences of
102 this bug. It was probably benign and really hard to detect. I think it would
103 cause us to incorrectly believe that we're pulling too many shares from a
104 server, and thus prefer a different server rather than asking for a second
105 share from the first server. The diversity code is intended to spread out the
106 number of shares simultaneously being requested from each server, but with
107 this bug, it might be spreading out the total number of shares requested at
108 all, not just simultaneously. (note that SegmentFetcher is scoped to a single
109 segment, so the effect doesn't last very long).
110]
111[immutable/downloader/share.py: reduce get_serverid(), one left, update ext deps
112warner@lothar.com**20110227011150
113 Ignore-this: d8d56dd8e7b280792b40105e13664554
114 
115 test_download.py: create+check MyShare instances better, make sure they share
116 Server objects, now that finder.py cares
117]
118[immutable/downloader/finder.py: reduce use of get_serverid(), one left
119warner@lothar.com**20110227011146
120 Ignore-this: 5785be173b491ae8a78faf5142892020
121]
122[immutable/offloaded.py: reduce use of get_serverid() a bit more
123warner@lothar.com**20110227011142
124 Ignore-this: b48acc1b2ae1b311da7f3ba4ffba38f
125]
126[immutable/upload.py: reduce use of get_serverid()
127warner@lothar.com**20110227011138
128 Ignore-this: ffdd7ff32bca890782119a6e9f1495f6
129]
130[immutable/checker.py: remove some uses of s.get_serverid(), not all
131warner@lothar.com**20110227011134
132 Ignore-this: e480a37efa9e94e8016d826c492f626e
133]
134[add remaining get_* methods to storage_client.Server, NoNetworkServer, and
135warner@lothar.com**20110227011132
136 Ignore-this: 6078279ddf42b179996a4b53bee8c421
137 MockIServer stubs
138]
139[upload.py: rearrange _make_trackers a bit, no behavior changes
140warner@lothar.com**20110227011128
141 Ignore-this: 296d4819e2af452b107177aef6ebb40f
142]
143[happinessutil.py: finally rename merge_peers to merge_servers
144warner@lothar.com**20110227011124
145 Ignore-this: c8cd381fea1dd888899cb71e4f86de6e
146]
147[test_upload.py: factor out FakeServerTracker
148warner@lothar.com**20110227011120
149 Ignore-this: 6c182cba90e908221099472cc159325b
150]
151[test_upload.py: server-vs-tracker cleanup
152warner@lothar.com**20110227011115
153 Ignore-this: 2915133be1a3ba456e8603885437e03
154]
155[happinessutil.py: server-vs-tracker cleanup
156warner@lothar.com**20110227011111
157 Ignore-this: b856c84033562d7d718cae7cb01085a9
158]
159[upload.py: more tracker-vs-server cleanup
160warner@lothar.com**20110227011107
161 Ignore-this: bb75ed2afef55e47c085b35def2de315
162]
163[upload.py: fix var names to avoid confusion between 'trackers' and 'servers'
164warner@lothar.com**20110227011103
165 Ignore-this: 5d5e3415b7d2732d92f42413c25d205d
166]
167[refactor: s/peer/server/ in immutable/upload, happinessutil.py, test_upload
168warner@lothar.com**20110227011100
169 Ignore-this: 7ea858755cbe5896ac212a925840fe68
170 
171 No behavioral changes, just updating variable/method names and log messages.
172 The effects outside these three files should be minimal: some exception
173 messages changed (to say "server" instead of "peer"), and some internal class
174 names were changed. A few things still use "peer" to minimize external
175 changes, like UploadResults.timings["peer_selection"] and
176 happinessutil.merge_peers, which can be changed later.
177]
178[storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers
179warner@lothar.com**20110227011056
180 Ignore-this: efad933e78179d3d5fdcd6d1ef2b19cc
181]
182[test_client.py, upload.py:: remove KiB/MiB/etc constants, and other dead code
183warner@lothar.com**20110227011051
184 Ignore-this: dc83c5794c2afc4f81e592f689c0dc2d
185]
186[test: increase timeout on a network test because Francois's ARM machine hit that timeout
187zooko@zooko.com**20110317165909
188 Ignore-this: 380c345cdcbd196268ca5b65664ac85b
189 I'm skeptical that the test was proceeding correctly but ran out of time. It seems more likely that it had gotten hung. But if we raise the timeout to an even more extravagant number then we can be even more certain that the test was never going to finish.
190]
191[docs/configuration.rst: add a "Frontend Configuration" section
192Brian Warner <warner@lothar.com>**20110222014323
193 Ignore-this: 657018aa501fe4f0efef9851628444ca
194 
195 this points to docs/frontends/*.rst, which were previously underlinked
196]
197[web/filenode.py: avoid calling req.finish() on closed HTTP connections. Closes #1366
198"Brian Warner <warner@lothar.com>"**20110221061544
199 Ignore-this: 799d4de19933f2309b3c0c19a63bb888
200]
201[Add unit tests for cross_check_pkg_resources_versus_import, and a regression test for ref #1355. This requires a little refactoring to make it testable.
202david-sarah@jacaranda.org**20110221015817
203 Ignore-this: 51d181698f8c20d3aca58b057e9c475a
204]
205[allmydata/__init__.py: .name was used in place of the correct .__name__ when printing an exception. Also, robustify string formatting by using %r instead of %s in some places. fixes #1355.
206david-sarah@jacaranda.org**20110221020125
207 Ignore-this: b0744ed58f161bf188e037bad077fc48
208]
209[Refactor StorageFarmBroker handling of servers
210Brian Warner <warner@lothar.com>**20110221015804
211 Ignore-this: 842144ed92f5717699b8f580eab32a51
212 
213 Pass around IServer instance instead of (peerid, rref) tuple. Replace
214 "descriptor" with "server". Other replacements:
215 
216  get_all_servers -> get_connected_servers/get_known_servers
217  get_servers_for_index -> get_servers_for_psi (now returns IServers)
218 
219 This change still needs to be pushed further down: lots of code is now
220 getting the IServer and then distributing (peerid, rref) internally.
221 Instead, it ought to distribute the IServer internally and delay
222 extracting a serverid or rref until the last moment.
223 
224 no_network.py was updated to retain parallelism.
225]
226[TAG allmydata-tahoe-1.8.2
227warner@lothar.com**20110131020101]
228Patch bundle hash:
2292af046938a9dc2255e0043006fcb854cb9beab15