← Back to team overview

txawsteam team mailing list archive

[Merge] lp:~oubiwann/txaws/413741-pep8-cleanup into lp:txaws

 

Duncan McGreggor has proposed merging lp:~oubiwann/txaws/413741-pep8-cleanup into lp:txaws.

Requested reviews:
    txAWS Team (txawsteam)

I'd like to merge this small fix-up branch to trunk. Could I get some reviews? 

Thanks!

d
-- 
https://code.launchpad.net/~oubiwann/txaws/413741-pep8-cleanup/+merge/10204
Your team txAWS Team is subscribed to branch lp:txaws.
=== modified file 'bin/aws-status'
--- bin/aws-status	2009-04-26 08:32:36 +0000
+++ bin/aws-status	2009-08-15 03:28:45 +0000
@@ -1,8 +1,9 @@
 #!/usr/bin/env python
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 import sys
 from txaws.client.gui.gtk import main
+
+
 sys.exit(main(sys.argv))
 

=== modified file 'txaws/client/gui/gtk.py'
--- txaws/client/gui/gtk.py	2009-05-08 13:18:59 +0000
+++ txaws/client/gui/gtk.py	2009-08-15 03:28:45 +0000
@@ -1,18 +1,19 @@
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 """A GTK client for working with aws."""
 
 from __future__ import absolute_import
 
-__all__ = ['main']
-
 import gnomekeyring
 import gobject
 import gtk
 
 from txaws.credentials import AWSCredentials
 
+
+__all__ = ['main']
+
+
 class AWSStatusIcon(gtk.StatusIcon):
     """A status icon shown when instances are running."""
 
@@ -49,7 +50,8 @@
         self.manager = gtk.UIManager()
         self.manager.insert_action_group(ag, 0)
         self.manager.add_ui_from_string(menu)
-        self.menu = self.manager.get_widget('/Menubar/Menu/Stop instances').props.parent
+        self.menu = self.manager.get_widget(
+            '/Menubar/Menu/Stop instances').props.parent
         self.connect('popup-menu', self.on_popup_menu)
 
     def create_client(self, creds):
@@ -79,7 +81,8 @@
             return AWSCredentials(access_key=key_id, secret_key=secret_key)
 
     def show_a_password_dialog(self):
-        self.password_dialog = gtk.Dialog("Enter your AWS credentals", None, gtk.DIALOG_MODAL,
+        self.password_dialog = gtk.Dialog(
+            "Enter your AWS credentals", None, gtk.DIALOG_MODAL,
             (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
             gtk.STOCK_CANCEL,
             gtk.RESPONSE_REJECT))
@@ -109,7 +112,8 @@
             # credentials.
             return
         self.probing = True
-        self.client.describe_instances().addCallbacks(self.showhide, self.describe_error)
+        d = self.client.describe_instances()
+        d.addCallbacks(self.showhide, self.describe_error)
 
     def on_popup_menu(self, status, button, time):
         self.menu.popup(None, None, None, button, time)

=== modified file 'txaws/credentials.py'
--- txaws/credentials.py	2009-04-27 08:53:11 +0000
+++ txaws/credentials.py	2009-08-15 03:28:45 +0000
@@ -1,14 +1,15 @@
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 """Credentials for accessing AWS services."""
 
-__all__ = ['AWSCredentials']
-
 import os
 
 from txaws.util import *
 
+
+__all__ = ['AWSCredentials']
+
+
 class AWSCredentials(object):
 
     def __init__(self, access_key=None, secret_key=None):

=== modified file 'txaws/ec2/client.py'
--- txaws/ec2/client.py	2009-04-28 11:52:57 +0000
+++ txaws/ec2/client.py	2009-08-15 03:28:45 +0000
@@ -1,10 +1,6 @@
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 """EC2 client support."""
-
-__all__ = ['EC2Client']
-
 from base64 import b64encode
 from urllib import quote
 
@@ -14,13 +10,15 @@
 from txaws.util import iso8601time, XML
 
 
+__all__ = ['EC2Client']
+
+
 class Instance(object):
     """An Amazon EC2 Instance.
 
-    :attrib instanceId: The instance ID of this instance.
-    :attrib instanceState: The state of this instance.
+    @attrib instanceId: The instance ID of this instance.
+    @attrib instanceState: The state of this instance.
     """
-
     def __init__(self, instanceId, instanceState):
         self.instanceId = instanceId
         self.instanceState = instanceState
@@ -34,7 +32,7 @@
     def __init__(self, creds=None, query_factory=None):
         """Create an EC2Client.
 
-        :param creds: Explicit credentials to use. If None, credentials are
+        @param creds: Explicit credentials to use. If None, credentials are
             inferred as per txaws.credentials.AWSCredentials.
         """
         if creds is None:
@@ -67,8 +65,8 @@
     def terminate_instances(self, *instance_ids):
         """Terminate some instances.
         
-        :param instance_ids: The ids of the instances to terminate.
-        :return: A deferred which on success gives an iterable of
+        @param instance_ids: The ids of the instances to terminate.
+        @return: A deferred which on success gives an iterable of
             (id, old-state, new-state) tuples.
         """
         instanceset = {}

=== modified file 'txaws/ec2/tests/test_client.py'
--- txaws/ec2/tests/test_client.py	2009-04-28 11:52:57 +0000
+++ txaws/ec2/tests/test_client.py	2009-08-15 03:28:45 +0000
@@ -1,6 +1,5 @@
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 import os
 
 from twisted.internet.defer import succeed
@@ -9,6 +8,7 @@
 from txaws.ec2 import client
 from txaws.tests import TXAWSTestCase
 
+
 sample_describe_instances_result = """<?xml version="1.0"?>
 <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/";>
     <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId>
@@ -49,6 +49,7 @@
 </DescribeInstancesResponse>
 """
 
+
 sample_terminate_instances_result = """<?xml version="1.0"?>
 <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/";>
   <instancesSet>

=== modified file 'txaws/storage/client.py'
--- txaws/storage/client.py	2009-04-27 08:53:11 +0000
+++ txaws/storage/client.py	2009-08-15 03:28:45 +0000
@@ -6,8 +6,6 @@
 Various API-incompatible changes are planned in order to expose missing
 functionality in this wrapper.
 """
-
-
 from hashlib import md5
 from base64 import b64encode
 
@@ -64,7 +62,8 @@
 
         if self.creds is not None:
             signature = self.getSignature(headers)
-            headers['Authorization'] = 'AWS %s:%s' % (self.creds.access_key, signature)
+            headers['Authorization'] = 'AWS %s:%s' % (
+                self.creds.access_key, signature)
 
         return headers
 
@@ -73,7 +72,8 @@
 
     def getCanonicalizedAmzHeaders(self, headers):
         result = ''
-        headers = [(name.lower(), value) for name, value in headers.iteritems() if name.lower().startswith('x-amz-')]
+        headers = [(name.lower(), value) for name, value in headers.iteritems()
+            if name.lower().startswith('x-amz-')]
         headers.sort()
         return ''.join('%s:%s\n' % (name, value) for name, value in headers)
 
@@ -87,7 +87,9 @@
         return self.creds.sign(text)
 
     def submit(self):
-        return self.getPage(url=self.getURI(), method=self.verb, postdata=self.data, headers=self.getHeaders())
+        return self.getPage(
+            url=self.getURI(), method=self.verb, postdata=self.data,
+            headers=self.getHeaders())
 
     def getPage(self, *a, **kw):
         return getPage(*a, **kw)
@@ -95,6 +97,7 @@
 
 NS = '{http://s3.amazonaws.com/doc/2006-03-01/}'
 
+
 class S3(object):
     rootURI = 'https://s3.amazonaws.com/'
     requestFactory = S3Request
@@ -117,8 +120,11 @@
         """
         root = XML(response)
         for bucket in root.find(NS + 'Buckets'):
-            yield {'name': bucket.findtext(NS + 'Name'),
-                   'created': Time.fromISO8601TimeAndDate(bucket.findtext(NS + 'CreationDate'))}
+            timeText = bucket.findtext(NS + 'CreationDate')
+            yield {
+                'name': bucket.findtext(NS + 'Name'),
+                'created': Time.fromISO8601TimeAndDate(timeText),
+                }
 
     def listBuckets(self):
         """
@@ -127,7 +133,9 @@
         Returns a list of all the buckets owned by the authenticated sender of
         the request.
         """
-        return self.makeRequest('GET').submit().addCallback(self._parseBucketList)
+        d = self.makeRequest('GET').submit()
+        d.addCallback(self._parseBucketList)
+        return d
 
     def createBucket(self, bucket):
         """
@@ -143,13 +151,15 @@
         """
         return self.makeRequest('DELETE', bucket).submit()
 
-    def putObject(self, bucket, objectName, data, contentType=None, metadata={}):
+    def putObject(self, bucket, objectName, data, contentType=None,
+                  metadata={}):
         """
         Put an object in a bucket.
 
         Any existing object of the same name will be replaced.
         """
-        return self.makeRequest('PUT', bucket, objectName, data, contentType, metadata).submit()
+        return self.makeRequest(
+            'PUT', bucket, objectName, data, contentType, metadata).submit()
 
     def getObject(self, bucket, objectName):
         """

=== modified file 'txaws/storage/test/test_client.py'
--- txaws/storage/test/test_client.py	2009-04-26 08:32:36 +0000
+++ txaws/storage/test/test_client.py	2009-08-15 03:28:45 +0000
@@ -8,6 +8,7 @@
 from txaws.tests import TXAWSTestCase
 from txaws.storage.client import S3, S3Request, calculateMD5
 
+
 class StubbedS3Request(S3Request):
     def getPage(self, url, method, postdata, headers):
         self.getPageArgs = (url, method, postdata, headers)
@@ -25,9 +26,13 @@
         DATA = 'objectData'
         DIGEST = 'zhdB6gwvocWv/ourYUWMxA=='
 
-        request = S3Request('PUT', 'somebucket', 'object/name/here', DATA, contentType='text/plain', metadata={'foo': 'bar'})
+        request = S3Request(
+            'PUT', 'somebucket', 'object/name/here', DATA, 
+            contentType='text/plain', metadata={'foo': 'bar'})
         self.assertEqual(request.verb, 'PUT')
-        self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket/object/name/here')
+        self.assertEqual(
+            request.getURI(),
+            'https://s3.amazonaws.com/somebucket/object/name/here')
         headers = request.getHeaders()
         self.assertNotEqual(headers.pop('Date'), '')
         self.assertEqual(headers,
@@ -45,7 +50,8 @@
 
         request = S3Request('GET', 'somebucket')
         self.assertEqual(request.verb, 'GET')
-        self.assertEqual(request.getURI(), 'https://s3.amazonaws.com/somebucket')
+        self.assertEqual(
+            request.getURI(), 'https://s3.amazonaws.com/somebucket')
         headers = request.getHeaders()
         self.assertNotEqual(headers.pop('Date'), '')
         self.assertEqual(headers,
@@ -75,7 +81,9 @@
         req.date = 'Wed, 28 Mar 2007 01:29:59 +0000'
 
         headers = req.getHeaders()
-        self.assertEqual(headers['Authorization'], 'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=')
+        self.assertEqual(
+            headers['Authorization'],
+            'AWS 0PN5J17HBGZHT7JJ3X82:jF7L3z/FTV47vagZzhKupJ9oNig=')
 
 
 class InertRequest(S3Request):
@@ -140,7 +148,8 @@
 
     def setUp(self):
         TXAWSTestCase.setUp(self)
-        self.creds = AWSCredentials(access_key='accessKey', secret_key='secretKey')
+        self.creds = AWSCredentials(
+            access_key='accessKey', secret_key='secretKey')
         self.s3 = TestableS3(creds=self.creds)
 
     def test_makeRequest(self):
@@ -167,11 +176,14 @@
         self.assertEqual(req.objectName, None)
 
         def _checkResult(buckets):
-            self.assertEqual(list(buckets),
-                             [{'name': u'quotes',
-                               'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 45, 9))},
-                              {'name': u'samples',
-                               'created': Time.fromDatetime(datetime(2006, 2, 3, 16, 41, 58))}])
+            self.assertEqual(
+                list(buckets),
+                [{'name': u'quotes',
+                  'created': Time.fromDatetime(
+                    datetime(2006, 2, 3, 16, 45, 9))},
+                 {'name': u'samples',
+                  'created': Time.fromDatetime(
+                    datetime(2006, 2, 3, 16, 41, 58))}])
         return d.addCallback(_checkResult)
 
     def test_createBucket(self):
@@ -191,7 +203,8 @@
         self.assertEqual(req.objectName, None)
 
     def test_putObject(self):
-        self.s3.putObject('foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'})
+        self.s3.putObject(
+            'foobucket', 'foo', 'data', 'text/plain', {'foo': 'bar'})
         req = self.s3._lastRequest
         self.assertTrue(req.submitted)
         self.assertEqual(req.verb, 'PUT')

=== modified file 'txaws/tests/__init__.py'
--- txaws/tests/__init__.py	2009-04-27 08:53:11 +0000
+++ txaws/tests/__init__.py	2009-08-15 03:28:45 +0000
@@ -2,6 +2,7 @@
 
 from twisted.trial.unittest import TestCase
 
+
 class TXAWSTestCase(TestCase):
     """Support for isolation of txaws tests."""
 

=== modified file 'txaws/tests/test_credentials.py'
--- txaws/tests/test_credentials.py	2009-04-27 14:15:48 +0000
+++ txaws/tests/test_credentials.py	2009-08-15 03:28:45 +0000
@@ -1,6 +1,5 @@
 # Copyright (C) 2009 Robert Collins <robertc@xxxxxxxxxxxxxxxxx>
 # Licenced under the txaws licence available at /LICENSE in the txaws source.
-
 import os
 
 from twisted.trial.unittest import TestCase

=== modified file 'txaws/tests/test_util.py'
--- txaws/tests/test_util.py	2009-04-27 08:53:11 +0000
+++ txaws/tests/test_util.py	2009-08-15 03:28:45 +0000
@@ -2,6 +2,7 @@
 
 from txaws.util import *
 
+
 class MiscellaneousTests(TestCase):
 
     def test_hmac_sha1(self):

=== modified file 'txaws/util.py'
--- txaws/util.py	2009-04-27 08:53:11 +0000
+++ txaws/util.py	2009-08-15 03:28:45 +0000
@@ -3,19 +3,21 @@
 New things in this module should be of relevance to more than one of amazon's
 services.
 """
-
-__all__ = ['hmac_sha1', 'iso8601time']
-
 from base64 import b64encode
 from hashlib import sha1
 import hmac
 import time
+
 # Import XML from somwhere; here in one place to prevent duplication.
 try:
     from xml.etree.ElementTree import XML
 except ImportError:
     from elementtree.ElementTree import XML
 
+
+__all__ = ['hmac_sha1', 'iso8601time']
+
+
 def hmac_sha1(secret, data):
     digest = hmac.new(secret, data, sha1).digest()
     return b64encode(digest)


Follow ups