Merge lp:~oubiwann/txaws/413741-pep8-cleanup into lp:~txawsteam/txaws/trunk
- 413741-pep8-cleanup
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~oubiwann/txaws/413741-pep8-cleanup | ||||
Merge into: | lp:~txawsteam/txaws/trunk | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~oubiwann/txaws/413741-pep8-cleanup | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Original txAWS Team | Pending | ||
Review via email: mp+10204@code.launchpad.net |
Commit message
Description of the change
Duncan McGreggor (oubiwann) wrote : | # |
Robert Collins (lifeless) wrote : | # |
review +1
I don't really like this bit though;
#comment
#comment
"""Docstring"""
I find it _much_ easier to read visually as
#comment
#comment
"""Docstring"""
-- comments are not classes or functions :)
Duncan McGreggor (oubiwann) wrote : | # |
On Sun, Aug 16, 2009 at 6:51 PM, Robert
Collins<email address hidden> wrote:
> review +1
>
> I don't really like this bit though;
>
> #comment
> #comment
> """Docstring"""
>
> I find it _much_ easier to read visually as
>
> #comment
> #comment
>
> """Docstring"""
>
> -- comments are not classes or functions :)
Cool -- I have no problem with that :-) I'll put it back.
d
- 7. By Duncan McGreggor <email address hidden>
-
Added new lines between comments, docstrings, and imports at the top of files
(lifeless 1).
Duncan McGreggor (oubiwann) wrote : | # |
Robert's review point has been addressed.
Since there's not a lot of activity in this team, how about we merge with one +1. Once we have more people and contributions, maybe we can bump that up...
Robert Collins (lifeless) wrote : | # |
On Tue, 2009-08-18 at 18:20 +0000, Duncan McGreggor wrote:
> Robert's review point has been addressed.
>
> Since there's not a lot of activity in this team, how about we merge with one +1. Once we have more people and contributions, maybe we can bump that up...
I think 2 review-capable people agreeing is sufficient - that is the
author and a reviewer, or for non team contributions, two team members.
-Rob
Preview Diff
1 | === modified file 'bin/aws-status' | |||
2 | --- bin/aws-status 2009-04-26 08:32:36 +0000 | |||
3 | +++ bin/aws-status 2009-08-15 03:28:45 +0000 | |||
4 | @@ -1,8 +1,9 @@ | |||
5 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
6 | 2 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 2 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
7 | 3 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 3 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
8 | 4 | |||
9 | 5 | import sys | 4 | import sys |
10 | 6 | from txaws.client.gui.gtk import main | 5 | from txaws.client.gui.gtk import main |
11 | 6 | |||
12 | 7 | |||
13 | 7 | sys.exit(main(sys.argv)) | 8 | sys.exit(main(sys.argv)) |
14 | 8 | 9 | ||
15 | 9 | 10 | ||
16 | === modified file 'txaws/client/gui/gtk.py' | |||
17 | --- txaws/client/gui/gtk.py 2009-05-08 13:18:59 +0000 | |||
18 | +++ txaws/client/gui/gtk.py 2009-08-15 03:28:45 +0000 | |||
19 | @@ -1,18 +1,19 @@ | |||
20 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
21 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
22 | 3 | |||
23 | 4 | """A GTK client for working with aws.""" | 3 | """A GTK client for working with aws.""" |
24 | 5 | 4 | ||
25 | 6 | from __future__ import absolute_import | 5 | from __future__ import absolute_import |
26 | 7 | 6 | ||
27 | 8 | __all__ = ['main'] | ||
28 | 9 | |||
29 | 10 | import gnomekeyring | 7 | import gnomekeyring |
30 | 11 | import gobject | 8 | import gobject |
31 | 12 | import gtk | 9 | import gtk |
32 | 13 | 10 | ||
33 | 14 | from txaws.credentials import AWSCredentials | 11 | from txaws.credentials import AWSCredentials |
34 | 15 | 12 | ||
35 | 13 | |||
36 | 14 | __all__ = ['main'] | ||
37 | 15 | |||
38 | 16 | |||
39 | 16 | class AWSStatusIcon(gtk.StatusIcon): | 17 | class AWSStatusIcon(gtk.StatusIcon): |
40 | 17 | """A status icon shown when instances are running.""" | 18 | """A status icon shown when instances are running.""" |
41 | 18 | 19 | ||
42 | @@ -49,7 +50,8 @@ | |||
43 | 49 | self.manager = gtk.UIManager() | 50 | self.manager = gtk.UIManager() |
44 | 50 | self.manager.insert_action_group(ag, 0) | 51 | self.manager.insert_action_group(ag, 0) |
45 | 51 | self.manager.add_ui_from_string(menu) | 52 | self.manager.add_ui_from_string(menu) |
47 | 52 | self.menu = self.manager.get_widget('/Menubar/Menu/Stop instances').props.parent | 53 | self.menu = self.manager.get_widget( |
48 | 54 | '/Menubar/Menu/Stop instances').props.parent | ||
49 | 53 | self.connect('popup-menu', self.on_popup_menu) | 55 | self.connect('popup-menu', self.on_popup_menu) |
50 | 54 | 56 | ||
51 | 55 | def create_client(self, creds): | 57 | def create_client(self, creds): |
52 | @@ -79,7 +81,8 @@ | |||
53 | 79 | return AWSCredentials(access_key=key_id, secret_key=secret_key) | 81 | return AWSCredentials(access_key=key_id, secret_key=secret_key) |
54 | 80 | 82 | ||
55 | 81 | def show_a_password_dialog(self): | 83 | def show_a_password_dialog(self): |
57 | 82 | self.password_dialog = gtk.Dialog("Enter your AWS credentals", None, gtk.DIALOG_MODAL, | 84 | self.password_dialog = gtk.Dialog( |
58 | 85 | "Enter your AWS credentals", None, gtk.DIALOG_MODAL, | ||
59 | 83 | (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, | 86 | (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, |
60 | 84 | gtk.STOCK_CANCEL, | 87 | gtk.STOCK_CANCEL, |
61 | 85 | gtk.RESPONSE_REJECT)) | 88 | gtk.RESPONSE_REJECT)) |
62 | @@ -109,7 +112,8 @@ | |||
63 | 109 | # credentials. | 112 | # credentials. |
64 | 110 | return | 113 | return |
65 | 111 | self.probing = True | 114 | self.probing = True |
67 | 112 | self.client.describe_instances().addCallbacks(self.showhide, self.describe_error) | 115 | d = self.client.describe_instances() |
68 | 116 | d.addCallbacks(self.showhide, self.describe_error) | ||
69 | 113 | 117 | ||
70 | 114 | def on_popup_menu(self, status, button, time): | 118 | def on_popup_menu(self, status, button, time): |
71 | 115 | self.menu.popup(None, None, None, button, time) | 119 | self.menu.popup(None, None, None, button, time) |
72 | 116 | 120 | ||
73 | === modified file 'txaws/credentials.py' | |||
74 | --- txaws/credentials.py 2009-04-27 08:53:11 +0000 | |||
75 | +++ txaws/credentials.py 2009-08-15 03:28:45 +0000 | |||
76 | @@ -1,14 +1,15 @@ | |||
77 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
78 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
79 | 3 | |||
80 | 4 | """Credentials for accessing AWS services.""" | 3 | """Credentials for accessing AWS services.""" |
81 | 5 | 4 | ||
82 | 6 | __all__ = ['AWSCredentials'] | ||
83 | 7 | |||
84 | 8 | import os | 5 | import os |
85 | 9 | 6 | ||
86 | 10 | from txaws.util import * | 7 | from txaws.util import * |
87 | 11 | 8 | ||
88 | 9 | |||
89 | 10 | __all__ = ['AWSCredentials'] | ||
90 | 11 | |||
91 | 12 | |||
92 | 12 | class AWSCredentials(object): | 13 | class AWSCredentials(object): |
93 | 13 | 14 | ||
94 | 14 | def __init__(self, access_key=None, secret_key=None): | 15 | def __init__(self, access_key=None, secret_key=None): |
95 | 15 | 16 | ||
96 | === modified file 'txaws/ec2/client.py' | |||
97 | --- txaws/ec2/client.py 2009-04-28 11:52:57 +0000 | |||
98 | +++ txaws/ec2/client.py 2009-08-15 03:28:45 +0000 | |||
99 | @@ -1,10 +1,6 @@ | |||
100 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
101 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
102 | 3 | |||
103 | 4 | """EC2 client support.""" | 3 | """EC2 client support.""" |
104 | 5 | |||
105 | 6 | __all__ = ['EC2Client'] | ||
106 | 7 | |||
107 | 8 | from base64 import b64encode | 4 | from base64 import b64encode |
108 | 9 | from urllib import quote | 5 | from urllib import quote |
109 | 10 | 6 | ||
110 | @@ -14,13 +10,15 @@ | |||
111 | 14 | from txaws.util import iso8601time, XML | 10 | from txaws.util import iso8601time, XML |
112 | 15 | 11 | ||
113 | 16 | 12 | ||
114 | 13 | __all__ = ['EC2Client'] | ||
115 | 14 | |||
116 | 15 | |||
117 | 17 | class Instance(object): | 16 | class Instance(object): |
118 | 18 | """An Amazon EC2 Instance. | 17 | """An Amazon EC2 Instance. |
119 | 19 | 18 | ||
122 | 20 | :attrib instanceId: The instance ID of this instance. | 19 | @attrib instanceId: The instance ID of this instance. |
123 | 21 | :attrib instanceState: The state of this instance. | 20 | @attrib instanceState: The state of this instance. |
124 | 22 | """ | 21 | """ |
125 | 23 | |||
126 | 24 | def __init__(self, instanceId, instanceState): | 22 | def __init__(self, instanceId, instanceState): |
127 | 25 | self.instanceId = instanceId | 23 | self.instanceId = instanceId |
128 | 26 | self.instanceState = instanceState | 24 | self.instanceState = instanceState |
129 | @@ -34,7 +32,7 @@ | |||
130 | 34 | def __init__(self, creds=None, query_factory=None): | 32 | def __init__(self, creds=None, query_factory=None): |
131 | 35 | """Create an EC2Client. | 33 | """Create an EC2Client. |
132 | 36 | 34 | ||
134 | 37 | :param creds: Explicit credentials to use. If None, credentials are | 35 | @param creds: Explicit credentials to use. If None, credentials are |
135 | 38 | inferred as per txaws.credentials.AWSCredentials. | 36 | inferred as per txaws.credentials.AWSCredentials. |
136 | 39 | """ | 37 | """ |
137 | 40 | if creds is None: | 38 | if creds is None: |
138 | @@ -67,8 +65,8 @@ | |||
139 | 67 | def terminate_instances(self, *instance_ids): | 65 | def terminate_instances(self, *instance_ids): |
140 | 68 | """Terminate some instances. | 66 | """Terminate some instances. |
141 | 69 | 67 | ||
144 | 70 | :param instance_ids: The ids of the instances to terminate. | 68 | @param instance_ids: The ids of the instances to terminate. |
145 | 71 | :return: A deferred which on success gives an iterable of | 69 | @return: A deferred which on success gives an iterable of |
146 | 72 | (id, old-state, new-state) tuples. | 70 | (id, old-state, new-state) tuples. |
147 | 73 | """ | 71 | """ |
148 | 74 | instanceset = {} | 72 | instanceset = {} |
149 | 75 | 73 | ||
150 | === modified file 'txaws/ec2/tests/test_client.py' | |||
151 | --- txaws/ec2/tests/test_client.py 2009-04-28 11:52:57 +0000 | |||
152 | +++ txaws/ec2/tests/test_client.py 2009-08-15 03:28:45 +0000 | |||
153 | @@ -1,6 +1,5 @@ | |||
154 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
155 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
156 | 3 | |||
157 | 4 | import os | 3 | import os |
158 | 5 | 4 | ||
159 | 6 | from twisted.internet.defer import succeed | 5 | from twisted.internet.defer import succeed |
160 | @@ -9,6 +8,7 @@ | |||
161 | 9 | from txaws.ec2 import client | 8 | from txaws.ec2 import client |
162 | 10 | from txaws.tests import TXAWSTestCase | 9 | from txaws.tests import TXAWSTestCase |
163 | 11 | 10 | ||
164 | 11 | |||
165 | 12 | sample_describe_instances_result = """<?xml version="1.0"?> | 12 | sample_describe_instances_result = """<?xml version="1.0"?> |
166 | 13 | <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> | 13 | <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> |
167 | 14 | <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId> | 14 | <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId> |
168 | @@ -49,6 +49,7 @@ | |||
169 | 49 | </DescribeInstancesResponse> | 49 | </DescribeInstancesResponse> |
170 | 50 | """ | 50 | """ |
171 | 51 | 51 | ||
172 | 52 | |||
173 | 52 | sample_terminate_instances_result = """<?xml version="1.0"?> | 53 | sample_terminate_instances_result = """<?xml version="1.0"?> |
174 | 53 | <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> | 54 | <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> |
175 | 54 | <instancesSet> | 55 | <instancesSet> |
176 | 55 | 56 | ||
177 | === modified file 'txaws/storage/client.py' | |||
178 | --- txaws/storage/client.py 2009-04-27 08:53:11 +0000 | |||
179 | +++ txaws/storage/client.py 2009-08-15 03:28:45 +0000 | |||
180 | @@ -6,8 +6,6 @@ | |||
181 | 6 | Various API-incompatible changes are planned in order to expose missing | 6 | Various API-incompatible changes are planned in order to expose missing |
182 | 7 | functionality in this wrapper. | 7 | functionality in this wrapper. |
183 | 8 | """ | 8 | """ |
184 | 9 | |||
185 | 10 | |||
186 | 11 | from hashlib import md5 | 9 | from hashlib import md5 |
187 | 12 | from base64 import b64encode | 10 | from base64 import b64encode |
188 | 13 | 11 | ||
189 | @@ -64,7 +62,8 @@ | |||
190 | 64 | 62 | ||
191 | 65 | if self.creds is not None: | 63 | if self.creds is not None: |
192 | 66 | signature = self.getSignature(headers) | 64 | signature = self.getSignature(headers) |
194 | 67 | headers['Authorization'] = 'AWS %s:%s' % (self.creds.access_key, signature) | 65 | headers['Authorization'] = 'AWS %s:%s' % ( |
195 | 66 | self.creds.access_key, signature) | ||
196 | 68 | 67 | ||
197 | 69 | return headers | 68 | return headers |
198 | 70 | 69 | ||
199 | @@ -73,7 +72,8 @@ | |||
200 | 73 | 72 | ||
201 | 74 | def getCanonicalizedAmzHeaders(self, headers): | 73 | def getCanonicalizedAmzHeaders(self, headers): |
202 | 75 | result = '' | 74 | result = '' |
204 | 76 | headers = [(name.lower(), value) for name, value in headers.iteritems() if name.lower().startswith('x-amz-')] | 75 | headers = [(name.lower(), value) for name, value in headers.iteritems() |
205 | 76 | if name.lower().startswith('x-amz-')] | ||
206 | 77 | headers.sort() | 77 | headers.sort() |
207 | 78 | return ''.join('%s:%s\n' % (name, value) for name, value in headers) | 78 | return ''.join('%s:%s\n' % (name, value) for name, value in headers) |
208 | 79 | 79 | ||
209 | @@ -87,7 +87,9 @@ | |||
210 | 87 | return self.creds.sign(text) | 87 | return self.creds.sign(text) |
211 | 88 | 88 | ||
212 | 89 | def submit(self): | 89 | def submit(self): |
214 | 90 | return self.getPage(url=self.getURI(), method=self.verb, postdata=self.data, headers=self.getHeaders()) | 90 | return self.getPage( |
215 | 91 | url=self.getURI(), method=self.verb, postdata=self.data, | ||
216 | 92 | headers=self.getHeaders()) | ||
217 | 91 | 93 | ||
218 | 92 | def getPage(self, *a, **kw): | 94 | def getPage(self, *a, **kw): |
219 | 93 | return getPage(*a, **kw) | 95 | return getPage(*a, **kw) |
220 | @@ -95,6 +97,7 @@ | |||
221 | 95 | 97 | ||
222 | 96 | NS = '{http://s3.amazonaws.com/doc/2006-03-01/}' | 98 | NS = '{http://s3.amazonaws.com/doc/2006-03-01/}' |
223 | 97 | 99 | ||
224 | 100 | |||
225 | 98 | class S3(object): | 101 | class S3(object): |
226 | 99 | rootURI = 'https://s3.amazonaws.com/' | 102 | rootURI = 'https://s3.amazonaws.com/' |
227 | 100 | requestFactory = S3Request | 103 | requestFactory = S3Request |
228 | @@ -117,8 +120,11 @@ | |||
229 | 117 | """ | 120 | """ |
230 | 118 | root = XML(response) | 121 | root = XML(response) |
231 | 119 | for bucket in root.find(NS + 'Buckets'): | 122 | for bucket in root.find(NS + 'Buckets'): |
234 | 120 | yield {'name': bucket.findtext(NS + 'Name'), | 123 | timeText = bucket.findtext(NS + 'CreationDate') |
235 | 121 | 'created': Time.fromISO8601TimeAndDate(bucket.findtext(NS + 'CreationDate'))} | 124 | yield { |
236 | 125 | 'name': bucket.findtext(NS + 'Name'), | ||
237 | 126 | 'created': Time.fromISO8601TimeAndDate(timeText), | ||
238 | 127 | } | ||
239 | 122 | 128 | ||
240 | 123 | def listBuckets(self): | 129 | def listBuckets(self): |
241 | 124 | """ | 130 | """ |
242 | @@ -127,7 +133,9 @@ | |||
243 | 127 | Returns a list of all the buckets owned by the authenticated sender of | 133 | Returns a list of all the buckets owned by the authenticated sender of |
244 | 128 | the request. | 134 | the request. |
245 | 129 | """ | 135 | """ |
247 | 130 | return self.makeRequest('GET').submit().addCallback(self._parseBucketList) | 136 | d = self.makeRequest('GET').submit() |
248 | 137 | d.addCallback(self._parseBucketList) | ||
249 | 138 | return d | ||
250 | 131 | 139 | ||
251 | 132 | def createBucket(self, bucket): | 140 | def createBucket(self, bucket): |
252 | 133 | """ | 141 | """ |
253 | @@ -143,13 +151,15 @@ | |||
254 | 143 | """ | 151 | """ |
255 | 144 | return self.makeRequest('DELETE', bucket).submit() | 152 | return self.makeRequest('DELETE', bucket).submit() |
256 | 145 | 153 | ||
258 | 146 | def putObject(self, bucket, objectName, data, contentType=None, metadata={}): | 154 | def putObject(self, bucket, objectName, data, contentType=None, |
259 | 155 | metadata={}): | ||
260 | 147 | """ | 156 | """ |
261 | 148 | Put an object in a bucket. | 157 | Put an object in a bucket. |
262 | 149 | 158 | ||
263 | 150 | Any existing object of the same name will be replaced. | 159 | Any existing object of the same name will be replaced. |
264 | 151 | """ | 160 | """ |
266 | 152 | return self.makeRequest('PUT', bucket, objectName, data, contentType, metadata).submit() | 161 | return self.makeRequest( |
267 | 162 | 'PUT', bucket, objectName, data, contentType, metadata).submit() | ||
268 | 153 | 163 | ||
269 | 154 | def getObject(self, bucket, objectName): | 164 | def getObject(self, bucket, objectName): |
270 | 155 | """ | 165 | """ |
271 | 156 | 166 | ||
272 | === modified file 'txaws/storage/test/test_client.py' | |||
273 | --- txaws/storage/test/test_client.py 2009-04-26 08:32:36 +0000 | |||
274 | +++ txaws/storage/test/test_client.py 2009-08-15 03:28:45 +0000 | |||
275 | @@ -8,6 +8,7 @@ | |||
276 | 8 | from txaws.tests import TXAWSTestCase | 8 | from txaws.tests import TXAWSTestCase |
277 | 9 | from txaws.storage.client import S3, S3Request, calculateMD5 | 9 | from txaws.storage.client import S3, S3Request, calculateMD5 |
278 | 10 | 10 | ||
279 | 11 | |||
280 | 11 | class StubbedS3Request(S3Request): | 12 | class StubbedS3Request(S3Request): |
281 | 12 | def getPage(self, url, method, postdata, headers): | 13 | def getPage(self, url, method, postdata, headers): |
282 | 13 | self.getPageArgs = (url, method, postdata, headers) | 14 | self.getPageArgs = (url, method, postdata, headers) |
283 | @@ -25,9 +26,13 @@ | |||
284 | 25 | DATA = 'objectData' | 26 | DATA = 'objectData' |
285 | 26 | DIGEST = 'zhdB6gwvocWv/ourYUWMxA==' | 27 | DIGEST = 'zhdB6gwvocWv/ourYUWMxA==' |
286 | 27 | 28 | ||
288 | 28 | request = S3Request('PUT', 'somebucket', 'object/name/here', DATA, contentType='text/plain', metadata={'foo': 'bar'}) | 29 | request = S3Request( |
289 | 30 | 'PUT', 'somebucket', 'object/name/here', DATA, | ||
290 | 31 | contentType='text/plain', metadata={'foo': 'bar'}) | ||
291 | 29 | self.assertEqual(request.verb, 'PUT') | 32 | self.assertEqual(request.verb, 'PUT') |
293 | 30 | self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket/object/name/here') | 33 | self.assertEqual( |
294 | 34 | request.getURI(), | ||
295 | 35 | 'https://s3.amazonaws.com/somebucket/object/name/here') | ||
296 | 31 | headers = request.getHeaders() | 36 | headers = request.getHeaders() |
297 | 32 | self.assertNotEqual(headers.pop('Date'), '') | 37 | self.assertNotEqual(headers.pop('Date'), '') |
298 | 33 | self.assertEqual(headers, | 38 | self.assertEqual(headers, |
299 | @@ -45,7 +50,8 @@ | |||
300 | 45 | 50 | ||
301 | 46 | request = S3Request('GET', 'somebucket') | 51 | request = S3Request('GET', 'somebucket') |
302 | 47 | self.assertEqual(request.verb, 'GET') | 52 | self.assertEqual(request.verb, 'GET') |
304 | 48 | self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket') | 53 | self.assertEqual( |
305 | 54 | request.getURI(), 'https://s3.amazonaws.com/somebucket') | ||
306 | 49 | headers = request.getHeaders() | 55 | headers = request.getHeaders() |
307 | 50 | self.assertNotEqual(headers.pop('Date'), '') | 56 | self.assertNotEqual(headers.pop('Date'), '') |
308 | 51 | self.assertEqual(headers, | 57 | self.assertEqual(headers, |
309 | @@ -75,7 +81,9 @@ | |||
310 | 75 | req.date = 'Wed, 28 Mar 2007 01:29:59 +0000' | 81 | req.date = 'Wed, 28 Mar 2007 01:29:59 +0000' |
311 | 76 | 82 | ||
312 | 77 | headers = req.getHeaders() | 83 | headers = req.getHeaders() |
314 | 78 | self.assertEqual(headers['Authorization'], 'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=') | 84 | self.assertEqual( |
315 | 85 | headers['Authorization'], | ||
316 | 86 | 'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=') | ||
317 | 79 | 87 | ||
318 | 80 | 88 | ||
319 | 81 | class InertRequest(S3Request): | 89 | class InertRequest(S3Request): |
320 | @@ -140,7 +148,8 @@ | |||
321 | 140 | 148 | ||
322 | 141 | def setUp(self): | 149 | def setUp(self): |
323 | 142 | TXAWSTestCase.setUp(self) | 150 | TXAWSTestCase.setUp(self) |
325 | 143 | self.creds = AWSCredentials(access_key='accessKey', secret_key='secretKey') | 151 | self.creds = AWSCredentials( |
326 | 152 | access_key='accessKey', secret_key='secretKey') | ||
327 | 144 | self.s3 = TestableS3(creds=self.creds) | 153 | self.s3 = TestableS3(creds=self.creds) |
328 | 145 | 154 | ||
329 | 146 | def test_makeRequest(self): | 155 | def test_makeRequest(self): |
330 | @@ -167,11 +176,14 @@ | |||
331 | 167 | self.assertEqual(req.objectName, None) | 176 | self.assertEqual(req.objectName, None) |
332 | 168 | 177 | ||
333 | 169 | def _checkResult(buckets): | 178 | def _checkResult(buckets): |
339 | 170 | self.assertEqual(list(buckets), | 179 | self.assertEqual( |
340 | 171 | [{'name': u'quotes', | 180 | list(buckets), |
341 | 172 | 'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 45, 9))}, | 181 | [{'name': u'quotes', |
342 | 173 | {'name': u'samples', | 182 | 'created': Time.fromDatetime( |
343 | 174 | 'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 41, 58))}]) | 183 | datetime(2006, 2, 3, 16, 45, 9))}, |
344 | 184 | {'name': u'samples', | ||
345 | 185 | 'created': Time.fromDatetime( | ||
346 | 186 | datetime(2006, 2, 3, 16, 41, 58))}]) | ||
347 | 175 | return d.addCallback(_checkResult) | 187 | return d.addCallback(_checkResult) |
348 | 176 | 188 | ||
349 | 177 | def test_createBucket(self): | 189 | def test_createBucket(self): |
350 | @@ -191,7 +203,8 @@ | |||
351 | 191 | self.assertEqual(req.objectName, None) | 203 | self.assertEqual(req.objectName, None) |
352 | 192 | 204 | ||
353 | 193 | def test_putObject(self): | 205 | def test_putObject(self): |
355 | 194 | self.s3.putObject('foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'}) | 206 | self.s3.putObject( |
356 | 207 | 'foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'}) | ||
357 | 195 | req = self.s3._lastRequest | 208 | req = self.s3._lastRequest |
358 | 196 | self.assertTrue(req.submitted) | 209 | self.assertTrue(req.submitted) |
359 | 197 | self.assertEqual(req.verb, 'PUT') | 210 | self.assertEqual(req.verb, 'PUT') |
360 | 198 | 211 | ||
361 | === modified file 'txaws/tests/__init__.py' | |||
362 | --- txaws/tests/__init__.py 2009-04-27 08:53:11 +0000 | |||
363 | +++ txaws/tests/__init__.py 2009-08-15 03:28:45 +0000 | |||
364 | @@ -2,6 +2,7 @@ | |||
365 | 2 | 2 | ||
366 | 3 | from twisted.trial.unittest import TestCase | 3 | from twisted.trial.unittest import TestCase |
367 | 4 | 4 | ||
368 | 5 | |||
369 | 5 | class TXAWSTestCase(TestCase): | 6 | class TXAWSTestCase(TestCase): |
370 | 6 | """Support for isolation of txaws tests.""" | 7 | """Support for isolation of txaws tests.""" |
371 | 7 | 8 | ||
372 | 8 | 9 | ||
373 | === modified file 'txaws/tests/test_credentials.py' | |||
374 | --- txaws/tests/test_credentials.py 2009-04-27 14:15:48 +0000 | |||
375 | +++ txaws/tests/test_credentials.py 2009-08-15 03:28:45 +0000 | |||
376 | @@ -1,6 +1,5 @@ | |||
377 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
378 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
379 | 3 | |||
380 | 4 | import os | 3 | import os |
381 | 5 | 4 | ||
382 | 6 | from twisted.trial.unittest import TestCase | 5 | from twisted.trial.unittest import TestCase |
383 | 7 | 6 | ||
384 | === modified file 'txaws/tests/test_util.py' | |||
385 | --- txaws/tests/test_util.py 2009-04-27 08:53:11 +0000 | |||
386 | +++ txaws/tests/test_util.py 2009-08-15 03:28:45 +0000 | |||
387 | @@ -2,6 +2,7 @@ | |||
388 | 2 | 2 | ||
389 | 3 | from txaws.util import * | 3 | from txaws.util import * |
390 | 4 | 4 | ||
391 | 5 | |||
392 | 5 | class MiscellaneousTests(TestCase): | 6 | class MiscellaneousTests(TestCase): |
393 | 6 | 7 | ||
394 | 7 | def test_hmac_sha1(self): | 8 | def test_hmac_sha1(self): |
395 | 8 | 9 | ||
396 | === modified file 'txaws/util.py' | |||
397 | --- txaws/util.py 2009-04-27 08:53:11 +0000 | |||
398 | +++ txaws/util.py 2009-08-15 03:28:45 +0000 | |||
399 | @@ -3,19 +3,21 @@ | |||
400 | 3 | New things in this module should be of relevance to more than one of amazon's | 3 | New things in this module should be of relevance to more than one of amazon's |
401 | 4 | services. | 4 | services. |
402 | 5 | """ | 5 | """ |
403 | 6 | |||
404 | 7 | __all__ = ['hmac_sha1', 'iso8601time'] | ||
405 | 8 | |||
406 | 9 | from base64 import b64encode | 6 | from base64 import b64encode |
407 | 10 | from hashlib import sha1 | 7 | from hashlib import sha1 |
408 | 11 | import hmac | 8 | import hmac |
409 | 12 | import time | 9 | import time |
410 | 10 | |||
411 | 13 | # Import XML from somwhere; here in one place to prevent duplication. | 11 | # Import XML from somwhere; here in one place to prevent duplication. |
412 | 14 | try: | 12 | try: |
413 | 15 | from xml.etree.ElementTree import XML | 13 | from xml.etree.ElementTree import XML |
414 | 16 | except ImportError: | 14 | except ImportError: |
415 | 17 | from elementtree.ElementTree import XML | 15 | from elementtree.ElementTree import XML |
416 | 18 | 16 | ||
417 | 17 | |||
418 | 18 | __all__ = ['hmac_sha1', 'iso8601time'] | ||
419 | 19 | |||
420 | 20 | |||
421 | 19 | def hmac_sha1(secret, data): | 21 | def hmac_sha1(secret, data): |
422 | 20 | digest = hmac.new(secret, data, sha1).digest() | 22 | digest = hmac.new(secret, data, sha1).digest() |
423 | 21 | return b64encode(digest) | 23 | return b64encode(digest) |
I'd like to merge this small fix-up branch to trunk. Could I get some reviews?
Thanks!
d