[pkg-eucalyptus-commits] [euca2ools] 13/41: Appease pylint (round 1)
Charles Plessy
plessy at alioth.debian.org
Sat Oct 12 03:24:13 UTC 2013
This is an automated email from the git hooks/post-receive script.
plessy pushed a commit to branch master
in repository euca2ools.
commit 0955966ab1599cae4d2745363f1a5a1dd9c24d44
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Thu Jul 11 16:25:48 2013 -0700
Appease pylint (round 1)
---
euca2ools/__init__.py | 1 +
euca2ools/commands/__init__.py | 13 +++--
euca2ools/commands/argtypes.py | 16 +++---
euca2ools/commands/autoscaling/__init__.py | 12 ++--
euca2ools/commands/autoscaling/argtypes.py | 2 -
.../autoscaling/createlaunchconfiguration.py | 6 +-
.../autoscaling/describeautoscalinggroups.py | 8 +--
.../autoscaling/describeautoscalinginstances.py | 15 +++--
.../autoscaling/describelaunchconfigurations.py | 8 +--
euca2ools/commands/autoscaling/describepolicies.py | 8 +--
.../autoscaling/describescalingactivities.py | 12 ++--
.../autoscaling/describescheduledactions.py | 16 +++---
euca2ools/commands/autoscaling/describetags.py | 2 +-
.../terminateinstanceinautoscalinggroup.py | 10 ++--
euca2ools/commands/bundle/__init__.py | 2 +
euca2ools/commands/bundle/bundle.py | 1 +
euca2ools/commands/bundle/bundleimage.py | 2 +
euca2ools/commands/bundle/deletebundle.py | 5 +-
euca2ools/commands/bundle/downloadbundle.py | 3 +
euca2ools/commands/bundle/imagecreator.py | 24 ++++----
euca2ools/commands/bundle/unbundle.py | 1 +
euca2ools/commands/bundle/uploadbundle.py | 1 +
.../commands/elasticloadbalancing/__init__.py | 2 +-
.../elasticloadbalancing/configurehealthcheck.py | 1 +
.../elasticloadbalancing/describeloadbalancers.py | 10 ++--
euca2ools/commands/euare/__init__.py | 5 +-
euca2ools/commands/euare/deletegroup.py | 4 ++
euca2ools/commands/euare/deleteuser.py | 7 +++
euca2ools/commands/euare/removeuserfromgroup.py | 8 +--
euca2ools/commands/euca/__init__.py | 59 ++++++++++----------
euca2ools/commands/euca/associateaddress.py | 1 +
euca2ools/commands/euca/bundleinstance.py | 3 +-
euca2ools/commands/euca/createvolume.py | 1 +
euca2ools/commands/euca/describeimages.py | 20 ++++---
.../commands/euca/describeinstanceattribute.py | 1 -
euca2ools/commands/euca/describesnapshots.py | 1 +
euca2ools/commands/euca/disassociateaddress.py | 1 +
euca2ools/commands/euca/modgroup.py | 29 +++++-----
euca2ools/commands/euca/modifyimageattribute.py | 1 +
.../commands/euca/modifyinstancetypeattribute.py | 1 +
euca2ools/commands/euca/modifysnapshotattribute.py | 1 +
euca2ools/commands/euca/registerimage.py | 1 +
euca2ools/commands/euca/releaseaddress.py | 1 +
euca2ools/commands/euca/runinstances.py | 12 ++--
euca2ools/commands/eustore/installimage.py | 22 ++++----
euca2ools/commands/monitoring/__init__.py | 2 +-
.../commands/monitoring/describealarmhistory.py | 2 +-
.../commands/monitoring/getmetricstatistics.py | 3 +-
euca2ools/commands/monitoring/listmetrics.py | 2 +-
euca2ools/commands/monitoring/putmetricalarm.py | 2 +-
euca2ools/commands/walrus/__init__.py | 9 +--
euca2ools/commands/walrus/createbucket.py | 2 +-
euca2ools/commands/walrus/deleteobject.py | 1 +
euca2ools/commands/walrus/listbucket.py | 13 +++--
euca2ools/commands/walrus/putobject.py | 2 +
euca2ools/nc/auth.py | 7 ++-
euca2ools/util.py | 4 +-
57 files changed, 232 insertions(+), 177 deletions(-)
diff --git a/euca2ools/__init__.py b/euca2ools/__init__.py
index 7d81efb..3fc85f1 100644
--- a/euca2ools/__init__.py
+++ b/euca2ools/__init__.py
@@ -32,6 +32,7 @@ if '__file__' in globals():
# Check if this is a git repo; maybe we can get more precise version info
try:
repo_path = os.path.join(os.path.dirname(__file__), '..')
+ # noinspection PyUnresolvedReferences
git = subprocess.Popen(['git', 'describe'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env={'GIT_DIR': os.path.join(repo_path, '.git')})
diff --git a/euca2ools/commands/__init__.py b/euca2ools/commands/__init__.py
index 87f7851..939c958 100644
--- a/euca2ools/commands/__init__.py
+++ b/euca2ools/commands/__init__.py
@@ -33,9 +33,9 @@ import sys
class Euca2ools(object):
- '''
+ """
A class with attributes and methods that define the entire euca2ools suite
- '''
+ """
CONFIG_PATHS = ('/etc/euca2ools/euca2ools.ini',
'/etc/euca2ools/conf.d/*.ini',
@@ -44,6 +44,7 @@ class Euca2ools(object):
def __init__(self):
self.__user_agent = None
+ # noinspection PyBroadException
@staticmethod
def format_version():
version_lines = ['euca2ools {0} (Sparta)'.format(__version__)]
@@ -76,9 +77,9 @@ class Euca2ools(object):
impl = platform.python_implementation()
if impl == 'PyPy':
impl_version = '{0}.{1}.{2}'.format(
- sys.pypy_version_info.major,
- sys.pypy_version_info.minor,
- sys.pypy_version_info.micro)
+ sys.pypy_version_info.major,
+ sys.pypy_version_info.minor,
+ sys.pypy_version_info.micro)
if sys.pypy_version_info.releaselevel != 'final':
impl_version += sys.pypy_version_info.releaselevel
else:
@@ -99,7 +100,7 @@ class Euca2ools(object):
user_agent_bits.append('({0})'.format('; '.join(tokens)))
user_agent_bits.append('requestbuilder/{0}'.format(
- requestbuilder.__version__))
+ requestbuilder.__version__))
user_agent_bits.append('requests/{0}'.format(requests.__version__))
self.__user_agent = ' '.join(user_agent_bits)
return self.__user_agent
diff --git a/euca2ools/commands/argtypes.py b/euca2ools/commands/argtypes.py
index ba518b4..1a4eb58 100644
--- a/euca2ools/commands/argtypes.py
+++ b/euca2ools/commands/argtypes.py
@@ -45,9 +45,9 @@ def manifest_block_device_mappings(mappings_as_str):
def ec2_block_device_mapping(map_as_str):
- '''
+ """
Parse a block device mapping from an image registration command line.
- '''
+ """
try:
(device, mapping) = map_as_str.split('=')
except ValueError:
@@ -121,11 +121,11 @@ def filesize(size):
def vpc_interface(iface_as_str):
- '''
+ """
Nine-part VPC network interface definition:
[INTERFACE]:INDEX:[SUBNET]:[DESCRIPTION]:[PRIV_IP]:[GROUP1,GROUP2,...]:
[true|false]:[SEC_IP_COUNT|:SEC_IP1,SEC_IP2,...]
- '''
+ """
if len(iface_as_str) == 0:
raise argparse.ArgumentTypeError(
@@ -238,14 +238,14 @@ def b64encoded_file_contents(filename):
def binary_tag_def(tag_str):
- '''
+ """
Parse a tag definition from the command line. Return a dict that depends
on the format of the string given:
- 'key=value': {'Key': key, 'Value': value}
- 'key=': {'Key': key, 'Value': EMPTY}
- 'key': {'Key': key, 'Value': EMPTY}
- '''
+ """
if '=' in tag_str:
(key, val) = tag_str.split('=', 1)
return {'Key': key, 'Value': val or EMPTY}
@@ -254,14 +254,14 @@ def binary_tag_def(tag_str):
def ternary_tag_def(tag_str):
- '''
+ """
Parse a tag definition from the command line. Return a dict that depends
on the format of the string given:
- 'key=value': {'Key': key, 'Value': value}
- 'key=': {'Key': key, 'Value': EMPTY}
- 'key': {'Key': key}
- '''
+ """
if '=' in tag_str:
(key, val) = tag_str.split('=', 1)
return {'Key': key, 'Value': val or EMPTY}
diff --git a/euca2ools/commands/autoscaling/__init__.py b/euca2ools/commands/autoscaling/__init__.py
index 51e1dfc..0b31d8c 100644
--- a/euca2ools/commands/autoscaling/__init__.py
+++ b/euca2ools/commands/autoscaling/__init__.py
@@ -25,7 +25,7 @@
from euca2ools.commands import Euca2ools
from euca2ools.exceptions import AWSError
-from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
+from requestbuilder import Arg, MutuallyExclusiveArgList
import requestbuilder.auth
import requestbuilder.service
import requestbuilder.request
@@ -40,11 +40,11 @@ class AutoScaling(requestbuilder.service.BaseService):
URL_ENVVAR = 'AWS_AUTO_SCALING_URL'
ARGS = [MutuallyExclusiveArgList(
- Arg('--region', dest='userregion', metavar='USER at REGION',
- help='''name of the region and/or user in config files to
- use to connect to the service'''),
- Arg('-U', '--url', metavar='URL',
- help='auto-scaling service endpoint URL'))]
+ Arg('--region', dest='userregion', metavar='USER at REGION',
+ help='''name of the region and/or user in config files to
+ use to connect to the service'''),
+ Arg('-U', '--url', metavar='URL',
+ help='auto-scaling service endpoint URL'))]
def handle_http_error(self, response):
raise AWSError(response)
diff --git a/euca2ools/commands/autoscaling/argtypes.py b/euca2ools/commands/autoscaling/argtypes.py
index 8b0f3e4..7129ade 100644
--- a/euca2ools/commands/autoscaling/argtypes.py
+++ b/euca2ools/commands/autoscaling/argtypes.py
@@ -23,7 +23,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
from argparse import ArgumentTypeError
@@ -76,4 +75,3 @@ def autoscaling_tag_def(tag_str):
raise ArgumentTypeError(
"tag '{0}' must contain a 'k=' segment with a non-empty value")
return tag_dict
-
diff --git a/euca2ools/commands/autoscaling/createlaunchconfiguration.py b/euca2ools/commands/autoscaling/createlaunchconfiguration.py
index 70b5ab0..4696567 100644
--- a/euca2ools/commands/autoscaling/createlaunchconfiguration.py
+++ b/euca2ools/commands/autoscaling/createlaunchconfiguration.py
@@ -24,10 +24,11 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import base64
+import os.path
+
from euca2ools.commands.argtypes import (delimited_list,
- ec2_block_device_mapping)
+ ec2_block_device_mapping)
from euca2ools.commands.autoscaling import AutoScalingRequest
-import os.path
from requestbuilder import Arg, MutuallyExclusiveArgList
from requestbuilder.exceptions import ArgumentError
@@ -83,6 +84,7 @@ class CreateLaunchConfiguration(AutoScalingRequest):
help='''file containing user data to make available to
instances'''))]
+ # noinspection PyExceptionInherit
def configure(self):
AutoScalingRequest.configure(self)
if self.args.get('user_data'):
diff --git a/euca2ools/commands/autoscaling/describeautoscalinggroups.py b/euca2ools/commands/autoscaling/describeautoscalinggroups.py
index c08ca0c..e82fd54 100644
--- a/euca2ools/commands/autoscaling/describeautoscalinggroups.py
+++ b/euca2ools/commands/autoscaling/describeautoscalinggroups.py
@@ -53,10 +53,10 @@ class DescribeAutoScalingGroups(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
lines = []
for group in result.get('AutoScalingGroups', []):
- bits = ['AUTO-SCALING-GROUP']
- bits.append(group.get('AutoScalingGroupName'))
- bits.append(group.get('LaunchConfigurationName'))
- bits.append(','.join(group.get('AvailabilityZones')))
+ bits = ['AUTO-SCALING-GROUP',
+ group.get('AutoScalingGroupName'),
+ group.get('LaunchConfigurationName'),
+ ','.join(group.get('AvailabilityZones'))]
if self.args['show_long']:
bits.append(group.get('CreatedTime'))
balancers = group.get('LoadBalancerNames')
diff --git a/euca2ools/commands/autoscaling/describeautoscalinginstances.py b/euca2ools/commands/autoscaling/describeautoscalinginstances.py
index a1d860b..964c326 100644
--- a/euca2ools/commands/autoscaling/describeautoscalinginstances.py
+++ b/euca2ools/commands/autoscaling/describeautoscalinginstances.py
@@ -51,11 +51,10 @@ class DescribeAutoScalingInstances(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
for instance in result.get('AutoScalingInstances', []):
- bits = ['INSTANCE']
- bits.append(instance.get('InstanceId'))
- bits.append(instance.get('AutoScalingGroupName'))
- bits.append(instance.get('AvailabilityZone'))
- bits.append(instance.get('LifecycleState'))
- bits.append(instance.get('HealthStatus'))
- bits.append(instance.get('LaunchConfigurationName'))
- print self.tabify(bits)
+ print self.tabify(('INSTANCE',
+ instance.get('InstanceId'),
+ instance.get('AutoScalingGroupName'),
+ instance.get('AvailabilityZone'),
+ instance.get('LifecycleState'),
+ instance.get('HealthStatus'),
+ instance.get('LaunchConfigurationName')))
diff --git a/euca2ools/commands/autoscaling/describelaunchconfigurations.py b/euca2ools/commands/autoscaling/describelaunchconfigurations.py
index 2753519..cb0a75e 100644
--- a/euca2ools/commands/autoscaling/describelaunchconfigurations.py
+++ b/euca2ools/commands/autoscaling/describelaunchconfigurations.py
@@ -51,10 +51,10 @@ class DescribeLaunchConfigurations(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
for config in result.get('LaunchConfigurations', []):
- bits = ['LAUNCH-CONFIG']
- bits.append(config.get('LaunchConfigurationName'))
- bits.append(config.get('ImageId'))
- bits.append(config.get('InstanceType'))
+ bits = ['LAUNCH-CONFIG',
+ config.get('LaunchConfigurationName'),
+ config.get('ImageId'),
+ config.get('InstanceType')]
if self.args['show_long']:
bits.append(config.get('KeyName'))
bits.append(config.get('KernelId'))
diff --git a/euca2ools/commands/autoscaling/describepolicies.py b/euca2ools/commands/autoscaling/describepolicies.py
index 1d2404e..8dd0637 100644
--- a/euca2ools/commands/autoscaling/describepolicies.py
+++ b/euca2ools/commands/autoscaling/describepolicies.py
@@ -51,10 +51,10 @@ class DescribePolicies(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
for policy in result.get('ScalingPolicies', []):
- bits = ['SCALING-POLICY']
- bits.append(policy.get('AutoScalingGroupName'))
- bits.append(policy.get('PolicyName'))
- bits.append(policy.get('ScalingAdjustment'))
+ bits = ['SCALING-POLICY',
+ policy.get('AutoScalingGroupName'),
+ policy.get('PolicyName'),
+ policy.get('ScalingAdjustment')]
if self.args['show_long']:
bits.append(policy.get('MinAdjustmentStep'))
bits.append(policy.get('AdjustmentType'))
diff --git a/euca2ools/commands/autoscaling/describescalingactivities.py b/euca2ools/commands/autoscaling/describescalingactivities.py
index 216657b..d430f84 100644
--- a/euca2ools/commands/autoscaling/describescalingactivities.py
+++ b/euca2ools/commands/autoscaling/describescalingactivities.py
@@ -52,12 +52,12 @@ class DescribeScalingActivities(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
for activity in result.get('Activities', []):
- bits = ['ACTIVITY']
- bits.append(activity.get('ActivityId'))
- bits.append(activity.get('EndTime'))
- bits.append(activity.get('AutoScalingGroupName'))
- bits.append(activity.get('StatusCode'))
- bits.append(activity.get('StatusMessage'))
+ bits = ['ACTIVITY',
+ activity.get('ActivityId'),
+ activity.get('EndTime'),
+ activity.get('AutoScalingGroupName'),
+ activity.get('StatusCode'),
+ activity.get('StatusMessage')]
if self.args['show_long']:
bits.append(activity.get('Cause'))
bits.append(activity.get('Progress'))
diff --git a/euca2ools/commands/autoscaling/describescheduledactions.py b/euca2ools/commands/autoscaling/describescheduledactions.py
index 662f42f..861d7b3 100644
--- a/euca2ools/commands/autoscaling/describescheduledactions.py
+++ b/euca2ools/commands/autoscaling/describescheduledactions.py
@@ -60,14 +60,14 @@ class DescribeScheduledActions(AutoScalingRequest, TabifyingMixin):
def print_result(self, result):
for action in result.get('ScheduledUpdateGroupActions', []):
- bits = ['UPDATE-GROUP-ACTION']
- bits.append(action.get('AutoScalingGroupName'))
- bits.append(action.get('ScheduledActionName'))
- bits.append(action.get('StartTime'))
- bits.append(action.get('Recurrence'))
- bits.append(action.get('MinSize'))
- bits.append(action.get('MaxSize'))
- bits.append(action.get('DesiredCapacity'))
+ bits = ['UPDATE-GROUP-ACTION',
+ action.get('AutoScalingGroupName'),
+ action.get('ScheduledActionName'),
+ action.get('StartTime'),
+ action.get('Recurrence'),
+ action.get('MinSize'),
+ action.get('MaxSize'),
+ action.get('DesiredCapacity')]
if self.args['show_long']:
bits.append(action.get('ScheduledActionARN'))
print self.tabify(bits)
diff --git a/euca2ools/commands/autoscaling/describetags.py b/euca2ools/commands/autoscaling/describetags.py
index 992fad6..71a096b 100644
--- a/euca2ools/commands/autoscaling/describetags.py
+++ b/euca2ools/commands/autoscaling/describetags.py
@@ -32,7 +32,7 @@ from requestbuilder.response import PaginatedResponse
class DescribeTags(AutoScalingRequest, TabifyingMixin):
DESCRIPTION = 'Describe auto-scaling tags'
- ARGS = [Arg('--filter', dest='Filters.member',type=autoscaling_filter_def,
+ ARGS = [Arg('--filter', dest='Filters.member', type=autoscaling_filter_def,
metavar='NAME=VALUE,...', action='append',
help='restrict results to those that meet criteria')]
LIST_TAGS = ['Tags']
diff --git a/euca2ools/commands/autoscaling/terminateinstanceinautoscalinggroup.py b/euca2ools/commands/autoscaling/terminateinstanceinautoscalinggroup.py
index 6a6d5bd..06c4eae 100644
--- a/euca2ools/commands/autoscaling/terminateinstanceinautoscalinggroup.py
+++ b/euca2ools/commands/autoscaling/terminateinstanceinautoscalinggroup.py
@@ -52,11 +52,11 @@ class TerminateInstanceInAutoScalingGroup(AutoScalingRequest,
def print_result(self, result):
activity = result['Activity']
- bits = ['INSTANCE']
- bits.append(activity.get('ActivityId'))
- bits.append(activity.get('EndTime'))
- bits.append(activity.get('StatusCode'))
- bits.append(activity.get('Cause'))
+ bits = ['INSTANCE',
+ activity.get('ActivityId'),
+ activity.get('EndTime'),
+ activity.get('StatusCode'),
+ activity.get('Cause')]
if self.args['show_long']:
bits.append(activity.get('StatusMessage'))
bits.append(activity.get('Progress'))
diff --git a/euca2ools/commands/bundle/__init__.py b/euca2ools/commands/bundle/__init__.py
index 8be6886..2bcfb0b 100644
--- a/euca2ools/commands/bundle/__init__.py
+++ b/euca2ools/commands/bundle/__init__.py
@@ -71,6 +71,7 @@ class BundleCreator(BaseCommand, FileTransferProgressBarMixin):
help='comma-separated list of product codes'),
Arg('--batch', action='store_true', help=argparse.SUPPRESS)]
+ # noinspection PyExceptionInherit
def configure(self):
BaseCommand.configure(self)
set_userregion(self.config, self.args.get('userregion'))
@@ -102,6 +103,7 @@ class BundleCreator(BaseCommand, FileTransferProgressBarMixin):
"directory".format(self.args['destination']))
+# noinspection PyExceptionInherit
def add_bundle_creds(args, config):
# User's X.509 certificate (user-level in config)
if not args.get('cert'):
diff --git a/euca2ools/commands/bundle/bundle.py b/euca2ools/commands/bundle/bundle.py
index 4573f27..e1033ce 100644
--- a/euca2ools/commands/bundle/bundle.py
+++ b/euca2ools/commands/bundle/bundle.py
@@ -78,6 +78,7 @@ class Bundle(object):
partdir = os.path.dirname(manifest_filename)
new_bundle = cls()
with open(manifest_filename) as manifest_file:
+ # noinspection PyUnresolvedReferences
manifest = lxml.objectify.parse(manifest_file).getroot()
new_bundle.digest = manifest.image.digest.text
new_bundle.digest_algorithm = manifest.image.digest.get('algorithm')
diff --git a/euca2ools/commands/bundle/bundleimage.py b/euca2ools/commands/bundle/bundleimage.py
index 9525e70..bf01fc0 100644
--- a/euca2ools/commands/bundle/bundleimage.py
+++ b/euca2ools/commands/bundle/bundleimage.py
@@ -48,6 +48,7 @@ class BundleImage(BundleCreator):
default='machine', help=argparse.SUPPRESS),
Arg('--progressbar-label', help=argparse.SUPPRESS)]
+ # noinspection PyExceptionInherit
def configure(self):
BundleCreator.configure(self)
@@ -100,6 +101,7 @@ class BundleImage(BundleCreator):
print 'Wrote', part_filename
print 'Wrote manifest', result[1] # manifest
+ # noinspection PyUnresolvedReferences
def generate_manifest_xml(self, bundle):
manifest = lxml.objectify.Element('manifest')
diff --git a/euca2ools/commands/bundle/deletebundle.py b/euca2ools/commands/bundle/deletebundle.py
index 2a17401..abb9ba4 100644
--- a/euca2ools/commands/bundle/deletebundle.py
+++ b/euca2ools/commands/bundle/deletebundle.py
@@ -44,7 +44,8 @@ class DeleteBundle(WalrusRequest):
ARGS = [Arg('-b', '--bucket', dest='bucket', metavar='BUCKET[/PREFIX]',
required=True,
help='location of the bundle to delete (required)'),
- MutuallyExclusiveArgList(True,
+ MutuallyExclusiveArgList(
+ True,
Arg('-m', '--manifest', dest='manifest_path',
metavar='MANIFEST', help='''use a local manifest file to
figure out what to delete'''),
@@ -69,6 +70,7 @@ class DeleteBundle(WalrusRequest):
DeleteObject(paths=paths, service=self.service,
config=self.config).main()
+ # noinspection PyExceptionInherit
def _delete_by_local_manifest(self):
manifest_path = self.args.get('manifest_path')
if not os.path.isfile(manifest_path):
@@ -88,6 +90,7 @@ class DeleteBundle(WalrusRequest):
raise
self._delete_manifest_parts(manifest_keys, directory)
+ # noinspection PyExceptionInherit
def _delete_by_prefix(self):
bucket = self.args.get('bucket')
directory = tempfile.mkdtemp()
diff --git a/euca2ools/commands/bundle/downloadbundle.py b/euca2ools/commands/bundle/downloadbundle.py
index 87269f1..c51985c 100644
--- a/euca2ools/commands/bundle/downloadbundle.py
+++ b/euca2ools/commands/bundle/downloadbundle.py
@@ -60,6 +60,7 @@ class DownloadBundle(WalrusRequest):
config=self.config,
show_progress=self.args.get('show_progress', True))
+ # noinspection PyExceptionInherit
def _download_by_local_manifest(self, directory):
manifest_path = self.args.get('manifest_path')
if not os.path.isfile(manifest_path):
@@ -70,6 +71,7 @@ class DownloadBundle(WalrusRequest):
shutil.copy(manifest_path, directory)
self._download_parts([manifest_key], directory)
+ # noinspection PyExceptionInherit
def _download_by_prefix(self, directory):
bucket = self.args.get('bucket')
prefix = self.args.get('prefix')
@@ -95,6 +97,7 @@ class DownloadBundle(WalrusRequest):
.format(",".join(manifest_keys), bucket))
self._download_parts(manifest_keys, directory)
+ # noinspection PyExceptionInherit
def main(self):
bucket = self.args.get('bucket').split('/', 1)[0]
CheckBucket(bucket=bucket, service=self.service,
diff --git a/euca2ools/commands/bundle/imagecreator.py b/euca2ools/commands/bundle/imagecreator.py
index 645d94e..ba3fcf9 100644
--- a/euca2ools/commands/bundle/imagecreator.py
+++ b/euca2ools/commands/bundle/imagecreator.py
@@ -63,8 +63,7 @@ none\t/sys\tsysfs\tdefaults 0 0""",
/dev/sda2\t/mnt\text3\tdefaults\t0 0
/dev/sda3\tswap\tswap\tdefaults\t0 0
proc\t/proc\tproc\tdefaults\t0 0
-devpts\t/dev/pts\tdevpts\tgid=5,mode=620 0 0""",
- )
+devpts\t/dev/pts\tdevpts\tgid=5,mode=620 0 0""")
FSTAB_HEADER_TEMPLATE = """#
#
# /etc/fstab
@@ -294,6 +293,7 @@ class VolumeSync(object):
self.mount()
return self
+ # noinspection PyUnusedLocal
def __exit__(self, exc_type, exc_value, traceback):
self.unmount()
@@ -330,8 +330,8 @@ class ImageCreator(object):
raise ValueError("must supply a prefix.")
if not self.volume:
raise ValueError("must supply a volume.")
- if not (os.path.exists(self.destination) or \
- os.path.isdir(self.destination)):
+ if not (os.path.exists(self.destination) or
+ os.path.isdir(self.destination)):
raise ValueError("'{0}' is not a directory or does not exist."
.format(self.destination))
@@ -396,28 +396,28 @@ class ImageCreator(object):
os.remove(devnode)
os.rmdir(directory)
- def _make_filesystem(self, type='ext3', uuid=None, label=None):
+ def _make_filesystem(self, fstype='ext3', uuid=None, label=None):
"""Format our raw image.
- :param type: (optional) Filesystem type, one of ext3, ext4, xfs, btrfs.
+ :param fstype: (optional) Filesystem type, one of ext3, ext4, xfs, btrfs.
:param uuid: (optional) UUID of the filesystem.
:param label: (optional) Label of the filesystem.
"""
- mkfs_cmd = 'mkfs.{0}'.format(type)
+ mkfs_cmd = 'mkfs.{0}'.format(fstype)
tunefs = None
- if type.startswith('ext'):
+ if fstype.startswith('ext'):
mkfs = [mkfs_cmd, '-F', self.image]
if uuid:
tunefs = ['tune2fs', '-U', uuid, self.image]
- elif type == 'xfs':
+ elif fstype == 'xfs':
mkfs = [mkfs_cmd, self.image]
tunefs = ['xfs_admin', '-U', uuid, self.image]
- elif type == 'btrfs':
+ elif fstype == 'btrfs':
mkfs = [mkfs_cmd, self.image]
if uuid:
raise Exception("btrfs with uuid not supported")
else:
- raise Exception("unsupported fs {0}".format(type))
+ raise Exception("unsupported fs {0}".format(fstype))
if label:
mkfs.extend(['-L', label])
@@ -438,6 +438,6 @@ def _generate_fstab_content(arch=platform.machine()):
if arch in FSTAB_BODY_TEMPLATE:
return "\n".join([FSTAB_HEADER_TEMPLATE.format(
time.strftime(FSTAB_TIME_FORMAT)),
- FSTAB_BODY_TEMPLATE.get(arch)])
+ FSTAB_BODY_TEMPLATE.get(arch)])
else:
raise Exception("platform architecture {0} not supported".format(arch))
diff --git a/euca2ools/commands/bundle/unbundle.py b/euca2ools/commands/bundle/unbundle.py
index 7e8876a..4c16672 100644
--- a/euca2ools/commands/bundle/unbundle.py
+++ b/euca2ools/commands/bundle/unbundle.py
@@ -54,6 +54,7 @@ class Unbundle(BaseCommand, FileTransferProgressBarMixin):
help='''use encryption keys specified for a user and/or region
in configuration files''')]
+ # noinspection PyExceptionInherit
def configure(self):
BaseCommand.configure(self)
set_userregion(self.config, self.args.get('userregion'))
diff --git a/euca2ools/commands/bundle/uploadbundle.py b/euca2ools/commands/bundle/uploadbundle.py
index c413300..ef23a7b 100644
--- a/euca2ools/commands/bundle/uploadbundle.py
+++ b/euca2ools/commands/bundle/uploadbundle.py
@@ -85,6 +85,7 @@ class UploadBundle(WalrusRequest, FileTransferProgressBarMixin):
# proactive about it.
with open(self.args['manifest']) as manifest_file:
+ # noinspection PyUnresolvedReferences
manifest = lxml.objectify.parse(manifest_file).getroot()
# Now we actually upload stuff
diff --git a/euca2ools/commands/elasticloadbalancing/__init__.py b/euca2ools/commands/elasticloadbalancing/__init__.py
index db76b4e..21c07ac 100644
--- a/euca2ools/commands/elasticloadbalancing/__init__.py
+++ b/euca2ools/commands/elasticloadbalancing/__init__.py
@@ -25,7 +25,7 @@
from euca2ools.commands import Euca2ools
from euca2ools.exceptions import AWSError
-from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
+from requestbuilder import Arg, MutuallyExclusiveArgList
import requestbuilder.auth
import requestbuilder.service
import requestbuilder.request
diff --git a/euca2ools/commands/elasticloadbalancing/configurehealthcheck.py b/euca2ools/commands/elasticloadbalancing/configurehealthcheck.py
index 0da55ec..4b57b03 100644
--- a/euca2ools/commands/elasticloadbalancing/configurehealthcheck.py
+++ b/euca2ools/commands/elasticloadbalancing/configurehealthcheck.py
@@ -52,6 +52,7 @@ class ConfigureHealthCheck(ELBRequest, TabifyingMixin):
help='''number of consecutive failed health checks that will
mark instances as Unhealthy (required)''')]
+ # noinspection PyExceptionInherit
def configure(self):
ELBRequest.configure(self)
target = self.args['HealthCheck.Target']
diff --git a/euca2ools/commands/elasticloadbalancing/describeloadbalancers.py b/euca2ools/commands/elasticloadbalancing/describeloadbalancers.py
index 534de83..877ffdc 100644
--- a/euca2ools/commands/elasticloadbalancing/describeloadbalancers.py
+++ b/euca2ools/commands/elasticloadbalancing/describeloadbalancers.py
@@ -42,9 +42,9 @@ class DescribeLoadBalancers(ELBRequest, TabifyingMixin):
def print_result(self, result):
for desc in result.get('LoadBalancerDescriptions', []):
- bits = ['LOAD_BALANCER']
- bits.append(desc.get('LoadBalancerName'))
- bits.append(desc.get('DNSName'))
+ bits = ['LOAD_BALANCER',
+ desc.get('LoadBalancerName'),
+ desc.get('DNSName')]
if self.args['show_long']:
bits.append(desc.get('CanonicalHostedZoneName'))
bits.append(desc.get('CanonicalHostedZoneNameID'))
@@ -86,8 +86,8 @@ class DescribeLoadBalancers(ELBRequest, TabifyingMixin):
listener_str_bits.append(name + '=' +
listener[xmlname])
if listenerdesc.get('PolicyNames'):
- listener_str_bits.append('{' +
- ','.join(listenerdesc['PolicyNames']) + '}')
+ listener_str_bits.append(
+ '{' + ','.join(listenerdesc['PolicyNames']) + '}')
listeners.append('{' + ','.join(listener_str_bits) + '}')
if len(listeners) > 0:
bits.append(','.join(listeners))
diff --git a/euca2ools/commands/euare/__init__.py b/euca2ools/commands/euare/__init__.py
index ac008b0..338f556 100644
--- a/euca2ools/commands/euare/__init__.py
+++ b/euca2ools/commands/euare/__init__.py
@@ -24,13 +24,14 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import argparse
+import sys
+
from euca2ools.commands import Euca2ools
from euca2ools.exceptions import AWSError
-from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
+from requestbuilder import Arg, MutuallyExclusiveArgList
import requestbuilder.auth
import requestbuilder.request
import requestbuilder.service
-import sys
class Euare(requestbuilder.service.BaseService):
diff --git a/euca2ools/commands/euare/deletegroup.py b/euca2ools/commands/euare/deletegroup.py
index 6fca76c..203af7c 100644
--- a/euca2ools/commands/euare/deletegroup.py
+++ b/euca2ools/commands/euare/deletegroup.py
@@ -58,6 +58,10 @@ class DeleteGroup(EuareRequest):
GroupName=self.args['GroupName'],
DelegateAccount=self.params['DelegateAccount'])
policies = req.main().get('PolicyNames', [])
+ else:
+ # Just in case
+ members = []
+ policies = []
if self.args['pretend']:
return {'members': [member['Arn'] for member in members],
'policies': policies}
diff --git a/euca2ools/commands/euare/deleteuser.py b/euca2ools/commands/euare/deleteuser.py
index 1ffa9c5..55cc581 100644
--- a/euca2ools/commands/euare/deleteuser.py
+++ b/euca2ools/commands/euare/deleteuser.py
@@ -92,6 +92,13 @@ class DeleteUser(EuareRequest):
else:
# Something else went wrong; not our problem
raise
+ else:
+ # Just in case
+ keys = []
+ policies = []
+ certs = []
+ groups = []
+ has_login_profile = False
if self.args['pretend']:
return {'keys': keys, 'policies': policies,
'certificates': certs, 'groups': groups,
diff --git a/euca2ools/commands/euare/removeuserfromgroup.py b/euca2ools/commands/euare/removeuserfromgroup.py
index ce6a76b..4c31caf 100644
--- a/euca2ools/commands/euare/removeuserfromgroup.py
+++ b/euca2ools/commands/euare/removeuserfromgroup.py
@@ -39,7 +39,7 @@ class RemoveUserFromGroup(EuareRequest):
def main(self):
for user in self.args['user_names']:
self.params['UserName'] = user
- response = self.send()
- # The response doesn't actually contain anything of interest, so just
- # return whatever
- return response
+ self.send()
+ # The response doesn't actually contain anything of interest, so don't
+ # bother returning anything
+ return None
diff --git a/euca2ools/commands/euca/__init__.py b/euca2ools/commands/euca/__init__.py
index 53d239f..d4ba10a 100644
--- a/euca2ools/commands/euca/__init__.py
+++ b/euca2ools/commands/euca/__init__.py
@@ -35,7 +35,6 @@ from requestbuilder.mixins import TabifyingMixin
from requestbuilder.request import AWSQueryRequest
from requestbuilder.service import BaseService
from requestbuilder.util import set_userregion
-import requests
import shlex
from string import Template
import sys
@@ -136,12 +135,12 @@ class Eucalyptus(BaseService):
NAME = 'ec2'
DESCRIPTION = 'Eucalyptus compute cloud service'
API_VERSION = '2013-02-01'
- AUTH_CLASS = EC2CompatibleQuerySigV2Auth
+ AUTH_CLASS = EC2CompatibleQuerySigV2Auth
REGION_ENVVAR = 'EUCA_REGION'
URL_ENVVAR = 'EC2_URL'
ARGS = [Arg('--config', dest='shell_configfile', metavar='CFGFILE',
- default='', route_to=(SERVICE, AUTH), help=argparse.SUPPRESS),
+ default='', route_to=(SERVICE, AUTH), help=argparse.SUPPRESS),
MutuallyExclusiveArgList(
Arg('--region', dest='userregion', metavar='USER at REGION',
help='''name of the region and/or user in config files to
@@ -252,6 +251,7 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
instance_line.append('monitoring-' +
instance['monitoring'].get('state'))
else:
+ # noinspection PyTypeChecker
instance_line.append(None)
instance_line.append(instance.get('ipAddress'))
instance_line.append(instance.get('privateIpAddress'))
@@ -260,6 +260,7 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
instance_line.append(instance.get('rootDeviceType'))
instance_line.append(instance.get('instanceLifecycle'))
instance_line.append(instance.get('showInstanceRequestId'))
+ # noinspection PyTypeChecker
instance_line.append(None) # Should be the license, but where is it?
instance_line.append(instance.get('placement', {}).get('groupName'))
instance_line.append(instance.get('virtualizationType'))
@@ -290,9 +291,9 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
blockdev.get('ebs', {}).get('iops')))
def print_interface(self, nic):
- nic_info = [nic.get(attr) for attr in ('networkInterfaceId',
- 'subnetId', 'vpcId', 'ownerId', 'status', 'privateIpAddress',
- 'privateDnsName', 'sourceDestCheck')]
+ nic_info = [nic.get(attr) for attr in (
+ 'networkInterfaceId', 'subnetId', 'vpcId', 'ownerId', 'status',
+ 'privateIpAddress', 'privateDnsName', 'sourceDestCheck')]
print self.tabify(['NIC'] + nic_info)
if nic.get('attachment'):
attachment_info = [nic['attachment'].get(attr) for attr in (
@@ -360,27 +361,27 @@ class EucalyptusRequest(AWSQueryRequest, TabifyingMixin):
class _ResourceTypeMap(object):
_prefix_type_map = {
- 'cgw': 'customer-gateway',
- 'dopt': 'dhcp-options',
- 'aki': 'image',
- 'ami': 'image',
- 'ari': 'image',
- 'eki': 'image',
- 'emi': 'image',
- 'eri': 'image',
- 'i': 'instance',
- 'igw': 'internet-gateway',
- 'acl': 'network-acl',
- 'xxx': 'reserved-instances', # reserved instance IDs are UUIDs
- 'rtb': 'route-table',
- 'sg': 'security-group',
- 'snap': 'snapshot',
- 'sir': 'spot-instances-request',
- 'subnet': 'subnet',
- 'vol': 'volume',
- 'vpc': 'vpc',
- 'vpn': 'vpn-connection',
- 'vgw': 'vpn-gateway'}
+ 'cgw': 'customer-gateway',
+ 'dopt': 'dhcp-options',
+ 'aki': 'image',
+ 'ami': 'image',
+ 'ari': 'image',
+ 'eki': 'image',
+ 'emi': 'image',
+ 'eri': 'image',
+ 'i': 'instance',
+ 'igw': 'internet-gateway',
+ 'acl': 'network-acl',
+ 'xxx': 'reserved-instances', # reserved instance IDs are UUIDs
+ 'rtb': 'route-table',
+ 'sg': 'security-group',
+ 'snap': 'snapshot',
+ 'sir': 'spot-instances-request',
+ 'subnet': 'subnet',
+ 'vol': 'volume',
+ 'vpc': 'vpc',
+ 'vpn': 'vpn-connection',
+ 'vgw': 'vpn-gateway'}
def lookup(self, item):
if not isinstance(item, basestring):
@@ -394,6 +395,7 @@ class _ResourceTypeMap(object):
RESOURCE_TYPE_MAP = _ResourceTypeMap()
+
def _find_args_by_parg(arglike, parg):
if isinstance(arglike, Arg):
if parg in arglike.pargs:
@@ -408,6 +410,7 @@ def _find_args_by_parg(arglike, parg):
else:
raise TypeError('Unsearchable type ' + arglike.__class__.__name__)
+
def _parse_shell_configfile(configfile_name):
# Should be able to drop this in 3.2
def sourcehook(filename):
@@ -415,7 +418,7 @@ def _parse_shell_configfile(configfile_name):
filename = Template(filename).safe_substitute(config)
filename = os.path.expandvars(filename)
filename = os.path.expanduser(filename)
- return (filename, open(filename))
+ return filename, open(filename)
config = {}
configfile_name = os.path.expandvars(configfile_name)
diff --git a/euca2ools/commands/euca/associateaddress.py b/euca2ools/commands/euca/associateaddress.py
index f7fbb23..dc18927 100644
--- a/euca2ools/commands/euca/associateaddress.py
+++ b/euca2ools/commands/euca/associateaddress.py
@@ -50,6 +50,7 @@ class AssociateAddress(EucalyptusRequest):
help='''[VPC only] allow the address to be associated even if
it is already associated with another interface''')]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if (self.args.get('PublicIp') is not None and
diff --git a/euca2ools/commands/euca/bundleinstance.py b/euca2ools/commands/euca/bundleinstance.py
index 76e474e..9bb9492 100644
--- a/euca2ools/commands/euca/bundleinstance.py
+++ b/euca2ools/commands/euca/bundleinstance.py
@@ -81,8 +81,9 @@ class BundleInstance(EucalyptusRequest):
my_hmac = hmac.new(self.args['owner_sak'], digestmod=hashlib.sha1)
my_hmac.update(self.params.get('Storage.S3.UploadPolicy'))
self.params['Storage.S3.UploadPolicySignature'] = \
- base64.b64encode(my_hmac.digest())
+ base64.b64encode(my_hmac.digest())
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if not self.args.get('Storage.S3.UploadPolicy'):
diff --git a/euca2ools/commands/euca/createvolume.py b/euca2ools/commands/euca/createvolume.py
index 6df67a0..31f02ee 100644
--- a/euca2ools/commands/euca/createvolume.py
+++ b/euca2ools/commands/euca/createvolume.py
@@ -42,6 +42,7 @@ class CreateVolume(EucalyptusRequest):
Arg('-i', '--iops', dest='Iops', type=int,
help='number of I/O operations per second')]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if not self.args.get('Size') and not self.args.get('SnapshotId'):
diff --git a/euca2ools/commands/euca/describeimages.py b/euca2ools/commands/euca/describeimages.py
index 55df9a4..c6f0323 100644
--- a/euca2ools/commands/euca/describeimages.py
+++ b/euca2ools/commands/euca/describeimages.py
@@ -92,6 +92,7 @@ class DescribeImages(EucalyptusRequest):
help='virtualization type ("paravirtual" or "hvm")')]
LIST_TAGS = ['imagesSet', 'productCodes', 'blockDeviceMapping', 'tagSet']
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if self.args.get('all', False):
@@ -129,15 +130,16 @@ class DescribeImages(EucalyptusRequest):
self.print_image(image)
def print_image(self, image):
- print self.tabify(('IMAGE', image.get('imageId'),
- image.get('imageLocation'),
- image.get('imageOwnerAlias') or image.get('imageOwnerId'),
- image.get('imageState'),
- ('public' if image.get('isPublic') == 'true' else 'private'),
- image.get('architecture'), image.get('imageType'),
- image.get('kernelId'), image.get('ramdiskId'),
- image.get('platform'), image.get('rootDeviceType'),
- image.get('virtualizationType'), image.get('hypervisor')))
+ print self.tabify((
+ 'IMAGE', image.get('imageId'),
+ image.get('imageLocation'),
+ image.get('imageOwnerAlias') or image.get('imageOwnerId'),
+ image.get('imageState'),
+ ('public' if image.get('isPublic') == 'true' else 'private'),
+ image.get('architecture'), image.get('imageType'),
+ image.get('kernelId'), image.get('ramdiskId'),
+ image.get('platform'), image.get('rootDeviceType'),
+ image.get('virtualizationType'), image.get('hypervisor')))
for mapping in image.get('blockDeviceMapping', []):
self.print_blockdevice_mapping(mapping)
for tag in image.get('tagSet', []):
diff --git a/euca2ools/commands/euca/describeinstanceattribute.py b/euca2ools/commands/euca/describeinstanceattribute.py
index 2872fa3..77ee9ee 100644
--- a/euca2ools/commands/euca/describeinstanceattribute.py
+++ b/euca2ools/commands/euca/describeinstanceattribute.py
@@ -26,7 +26,6 @@
import base64
from euca2ools.commands.euca import EucalyptusRequest
from requestbuilder import Arg, MutuallyExclusiveArgList
-from requestbuilder.exceptions import ArgumentError
class DescribeInstanceAttribute(EucalyptusRequest):
diff --git a/euca2ools/commands/euca/describesnapshots.py b/euca2ools/commands/euca/describesnapshots.py
index 45737bc..344872a 100644
--- a/euca2ools/commands/euca/describesnapshots.py
+++ b/euca2ools/commands/euca/describesnapshots.py
@@ -58,6 +58,7 @@ class DescribeSnapshots(EucalyptusRequest):
Filter('volume-size', type=int)]
LIST_TAGS = ['snapshotSet', 'tagSet']
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if self.args.get('all'):
diff --git a/euca2ools/commands/euca/disassociateaddress.py b/euca2ools/commands/euca/disassociateaddress.py
index 6ca6548..4039ffe 100644
--- a/euca2ools/commands/euca/disassociateaddress.py
+++ b/euca2ools/commands/euca/disassociateaddress.py
@@ -36,6 +36,7 @@ class DisassociateAddress(EucalyptusRequest):
metavar='ASSOC',
help="[VPC only] address's association ID (required)")]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if self.args.get('PublicIp'):
diff --git a/euca2ools/commands/euca/modgroup.py b/euca2ools/commands/euca/modgroup.py
index d4e2651..8000124 100644
--- a/euca2ools/commands/euca/modgroup.py
+++ b/euca2ools/commands/euca/modgroup.py
@@ -30,9 +30,9 @@ import sys
class ModifySecurityGroupRequest(EucalyptusRequest):
- '''
+ """
The basis for security group-editing commands
- '''
+ """
ARGS = [Arg('group', metavar='GROUP', route_to=None,
help='name or ID of the security group to modify (required)'),
@@ -45,17 +45,17 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
Arg('-p', '--port-range', dest='port_range', metavar='RANGE',
route_to=None, help='''range of ports (specified as "from-to")
or a single port number (required for tcp and udp)'''),
- # ^ required for tcp and udp
+ # ^ required for tcp and udp
Arg('-t', '--icmp-type-code', dest='icmp_type_code',
metavar='TYPE:CODE', route_to=None,
help='''ICMP type and code (specified as "type:code") (required
for icmp)'''),
- # ^ required for icmp
+ # ^ required for icmp
MutuallyExclusiveArgList(
Arg('-s', '--cidr', metavar='CIDR',
dest='IpPermissions.1.IpRanges.1.CidrIp',
help='''IP range (default: 0.0.0.0/0)'''),
- # ^ default is added by main()
+ # ^ default is added by main()
Arg('-o', dest='target_group', metavar='GROUP', route_to=None,
help='''[Non-VPC only] name of a security group with which
to affect network communication''')),
@@ -64,11 +64,12 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
help='''ID of the account that owns the security group
specified with -o''')]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if (self.args['group'].startswith('sg-') and
- len(self.args['group']) == 11):
+ len(self.args['group']) == 11):
# The check could probably be a little better, but meh. Fix if
# needed.
self.params['GroupId'] = self.args['group']
@@ -89,8 +90,6 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
'IDs, not names')
self.params['IpPermissions.1.Groups.1.GroupName'] = target_group
- from_port = None
- to_port = None
protocol = self.args.get('IpPermissions.1.IpProtocol')
if protocol in ['icmp', '1']:
if self.args.get('port_range'):
@@ -102,7 +101,7 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
if len(types) == 2:
try:
from_port = int(types[0])
- to_port = int(types[1])
+ to_port = int(types[1])
except ValueError:
raise ArgumentError('argument -t/--icmp-type-code: value '
'must have format "1:2"')
@@ -132,7 +131,7 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
if len(ports) == 2:
try:
from_port = int(ports[0])
- to_port = int(ports[1])
+ to_port = int(ports[1])
except ValueError:
raise ArgumentError('argument -p/--port-range: multi-port '
'value must be comprised of integers')
@@ -154,14 +153,14 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
raise ValueError('unrecognized protocol: "{0}"'.format(protocol))
self.params['IpPermissions.1.FromPort'] = from_port
- self.params['IpPermissions.1.ToPort'] = to_port
+ self.params['IpPermissions.1.ToPort'] = to_port
if (not self.args.get('IpPermissions.1.IpRanges.1.GroupName') and
- not self.args.get('IpPermissions.1.IpRanges.1.CidrIp')):
+ not self.args.get('IpPermissions.1.IpRanges.1.CidrIp')):
# Default rule target is the entire Internet
self.params['IpPermissions.1.IpRanges.1.CidrIp'] = '0.0.0.0/0'
if (self.params.get('IpPermissions.1.Groups.1.GroupName') and
- not self.args.get('IpPermissions.1.Groups.1.UserId')):
+ not self.args.get('IpPermissions.1.Groups.1.UserId')):
raise ArgumentError('argument -u is required when -o names a '
'security group by name')
@@ -193,14 +192,16 @@ class ModifySecurityGroupRequest(EucalyptusRequest):
# of Python bug 9334, which prevents argparse from recognizing '-1:-1'
# as an option value and not a (nonexistent) option name.
saved_sys_argv = list(sys.argv)
+
def parse_neg_one_value(opt_name):
if opt_name in sys.argv:
index = sys.argv.index(opt_name)
if (index < len(sys.argv) - 1 and
- sys.argv[index + 1].startswith('-1')):
+ sys.argv[index + 1].startswith('-1')):
opt_val = sys.argv[index + 1]
del sys.argv[index:index + 2]
return opt_val
+
icmp_type_code = (parse_neg_one_value('-t') or
parse_neg_one_value('--icmp-type-code'))
port_range = (parse_neg_one_value('-p') or
diff --git a/euca2ools/commands/euca/modifyimageattribute.py b/euca2ools/commands/euca/modifyimageattribute.py
index 02f36a7..d63089d 100644
--- a/euca2ools/commands/euca/modifyimageattribute.py
+++ b/euca2ools/commands/euca/modifyimageattribute.py
@@ -47,6 +47,7 @@ class ModifyImageAttribute(EucalyptusRequest):
default=[], route_to=None, help='''account to remove launch
permission from, or "all" for all accounts''')]
+ # noinspection PyExceptionInherit
def preprocess(self):
if self.args.get('launch_permission'):
lperm = {}
diff --git a/euca2ools/commands/euca/modifyinstancetypeattribute.py b/euca2ools/commands/euca/modifyinstancetypeattribute.py
index 177ea6c..34f1ae3 100644
--- a/euca2ools/commands/euca/modifyinstancetypeattribute.py
+++ b/euca2ools/commands/euca/modifyinstancetypeattribute.py
@@ -42,6 +42,7 @@ class ModifyInstanceTypeAttribute(EucalyptusRequest, TabifyingMixin):
Arg('--reset', dest='Reset', action='store_true',
help='reset the instance type to its default configuration')]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if (self.args.get('Reset') and
diff --git a/euca2ools/commands/euca/modifysnapshotattribute.py b/euca2ools/commands/euca/modifysnapshotattribute.py
index 1d30e72..d8da7f6 100644
--- a/euca2ools/commands/euca/modifysnapshotattribute.py
+++ b/euca2ools/commands/euca/modifysnapshotattribute.py
@@ -42,6 +42,7 @@ class ModifySnapshotAttribute(EucalyptusRequest):
default=[], route_to=None, help='''account to remove permission
from, or "all" for all accounts''')]
+ # noinspection PyExceptionInherit
def preprocess(self):
if self.args.get('create_volume_permission'):
cvperm = {}
diff --git a/euca2ools/commands/euca/registerimage.py b/euca2ools/commands/euca/registerimage.py
index 18a3584..056246b 100644
--- a/euca2ools/commands/euca/registerimage.py
+++ b/euca2ools/commands/euca/registerimage.py
@@ -61,6 +61,7 @@ class RegisterImage(EucalyptusRequest):
choices=('paravirtual', 'hvm'),
help='[Privileged] virtualization type for the new image')]
+ # noinspection PyExceptionInherit
def preprocess(self):
if self.args.get('ImageLocation'):
# instance-store image
diff --git a/euca2ools/commands/euca/releaseaddress.py b/euca2ools/commands/euca/releaseaddress.py
index 0ca2157..c06baee 100644
--- a/euca2ools/commands/euca/releaseaddress.py
+++ b/euca2ools/commands/euca/releaseaddress.py
@@ -36,6 +36,7 @@ class ReleaseAddress(EucalyptusRequest):
help='''[VPC only] allocation ID for the address to release
(required)''')]
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if (self.args.get('PublicIp') is not None and
diff --git a/euca2ools/commands/euca/runinstances.py b/euca2ools/commands/euca/runinstances.py
index 203f224..28c117f 100644
--- a/euca2ools/commands/euca/runinstances.py
+++ b/euca2ools/commands/euca/runinstances.py
@@ -25,7 +25,7 @@
import base64
from euca2ools.commands.argtypes import (ec2_block_device_mapping,
- vpc_interface)
+ vpc_interface)
from euca2ools.commands.euca import EucalyptusRequest
import os.path
from requestbuilder import Arg, MutuallyExclusiveArgList
@@ -124,9 +124,10 @@ class RunInstances(EucalyptusRequest):
"false"), a number of secondary private IP addresses to create
automatically, and a list of secondary private IP addresses to
assign to the interface, separated by ":", in the form
- ":INDEX:SUBNET:[DESCRIPTION]:[PRIV_IP]:[GROUP1,GROUP2,...]:[true|false]:[SEC_IP_COUNT|:SEC_IP1,SEC_IP2,...]". You cannot specify both of the
- latter two. This option may be used multiple times. Each adds
- another network interface.'''),
+ ":INDEX:SUBNET:[DESCRIPTION]:[PRIV_IP]:[GROUP1,GROUP2,...]:[true
+ |false]:[SEC_IP_COUNT|:SEC_IP1,SEC_IP2,...]". You cannot
+ specify both of the latter two. This option may be used
+ multiple times. Each adds another network interface.'''),
Arg('-p', '--iam-profile', metavar='IPROFILE', route_to=None,
help='''name or ARN of the IAM instance profile to associate
with the new instance(s)'''),
@@ -137,6 +138,7 @@ class RunInstances(EucalyptusRequest):
'blockDeviceMapping', 'productCodes', 'networkInterfaceSet',
'association', 'privateIpAddressesSet']
+ # noinspection PyExceptionInherit
def configure(self):
EucalyptusRequest.configure(self)
if self.args.get('user_data'):
@@ -164,7 +166,7 @@ class RunInstances(EucalyptusRequest):
self.log.info("using default key pair '%s'", default_key_name)
self.params['KeyName'] = default_key_name
-
+ # noinspection PyExceptionInherit
def preprocess(self):
counts = self.args['count'].split('-')
if len(counts) == 1:
diff --git a/euca2ools/commands/eustore/installimage.py b/euca2ools/commands/eustore/installimage.py
index ea02934..c238471 100644
--- a/euca2ools/commands/eustore/installimage.py
+++ b/euca2ools/commands/eustore/installimage.py
@@ -97,6 +97,7 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
help='storage service endpoint URL'),
Arg('-y', '--yes', action='store_true', help=argparse.SUPPRESS)]
+ # noinspection PyExceptionInherit
def configure(self):
EuStoreRequest.configure(self)
set_userregion(self.config, self.args.get('userregion'))
@@ -240,7 +241,8 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
url = urlparse.urljoin(endpoint, image['url'])
self.log.info('downloading image from %s', url)
label = 'Downloading image '.format(os.path.basename(url))
- req = requestbuilder.commands.http.Get(label=label, url=url,
+ req = requestbuilder.commands.http.Get(
+ label=label, url=url,
show_progress=self.args.get('show_progress', False),
dest=workdir, config=self.config)
tarball_path, tarball_size = req.main()
@@ -300,8 +302,8 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
tarball, member, workdir, 'Extracting kernel ')
manifest_loc = self.bundle_and_upload_image(
kernel_image, 'kernel', workdir)
- req = RegisterImage(config=self.config,
- service=self.__eucalyptus,
+ req = RegisterImage(
+ config=self.config, service=self.__eucalyptus,
ImageLocation=manifest_loc, Name=image_name,
Description=self.args.get('description'),
Architecture=self.args.get('architecture'))
@@ -317,8 +319,8 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
tarball, member, workdir, 'Extracting ramdisk')
manifest_loc = self.bundle_and_upload_image(
ramdisk_image, 'ramdisk', workdir)
- req = RegisterImage(config=self.config,
- service=self.__eucalyptus,
+ req = RegisterImage(
+ config=self.config, service=self.__eucalyptus,
ImageLocation=manifest_loc, Name=image_name,
Description=self.args.get('description'),
Architecture=self.args.get('architecture'))
@@ -340,12 +342,12 @@ class InstallImage(EuStoreRequest, FileTransferProgressBarMixin):
bundled_images.append(member.name)
machine_image = self.extract_without_path(
tarball, member, workdir, 'Extracting image ')
- manifest_loc = self.bundle_and_upload_image(machine_image,
- 'machine', workdir, kernel_id=kernel_id,
+ manifest_loc = self.bundle_and_upload_image(
+ machine_image, 'machine', workdir, kernel_id=kernel_id,
ramdisk_id=ramdisk_id)
- req = RegisterImage(config=self.config,
- service=self.__eucalyptus, ImageLocation=manifest_loc,
- Name=image_name,
+ req = RegisterImage(
+ config=self.config, service=self.__eucalyptus,
+ ImageLocation=manifest_loc, Name=image_name,
Description=self.args.get('description'),
Architecture=self.args.get('architecture'))
response = req.main()
diff --git a/euca2ools/commands/monitoring/__init__.py b/euca2ools/commands/monitoring/__init__.py
index 6de9dbf..a7c8707 100644
--- a/euca2ools/commands/monitoring/__init__.py
+++ b/euca2ools/commands/monitoring/__init__.py
@@ -25,7 +25,7 @@
from euca2ools.commands import Euca2ools
from euca2ools.exceptions import AWSError
-from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
+from requestbuilder import Arg, MutuallyExclusiveArgList
import requestbuilder.auth
from requestbuilder.mixins import TabifyingMixin
import requestbuilder.service
diff --git a/euca2ools/commands/monitoring/describealarmhistory.py b/euca2ools/commands/monitoring/describealarmhistory.py
index 7dd6bdc..2772370 100644
--- a/euca2ools/commands/monitoring/describealarmhistory.py
+++ b/euca2ools/commands/monitoring/describealarmhistory.py
@@ -45,7 +45,7 @@ class DescribeAlarmHistory(CloudWatchRequest, TabifyingMixin):
LIST_TAGS = ['AlarmHistoryItems']
def main(self):
- return PaginatedResponse(self, (None,), ('AlarmHistoryItems,'))
+ return PaginatedResponse(self, (None,), ('AlarmHistoryItems',))
def prepare_for_page(self, page):
self.params['NextToken'] = page
diff --git a/euca2ools/commands/monitoring/getmetricstatistics.py b/euca2ools/commands/monitoring/getmetricstatistics.py
index c2d8e1d..fcc5c39 100644
--- a/euca2ools/commands/monitoring/getmetricstatistics.py
+++ b/euca2ools/commands/monitoring/getmetricstatistics.py
@@ -58,6 +58,7 @@ class GetMetricStatistics(CloudWatchRequest, TabifyingMixin):
Arg('--unit', dest='Unit', help='unit the metric is reported in')]
LIST_TAGS = ['Datapoints']
+ # noinspection PyExceptionInherit
def configure(self):
CloudWatchRequest.configure(self)
if self.args.get('period'):
@@ -76,7 +77,7 @@ class GetMetricStatistics(CloudWatchRequest, TabifyingMixin):
if not self.args.get('EndTime'):
self.params['EndTime'] = now.strftime('%Y-%m-%dT%H:%M:%SZ')
- return PaginatedResponse(self, (None,), ('Datapoints,'))
+ return PaginatedResponse(self, (None,), ('Datapoints',))
def prepare_for_page(self, page):
self.params['NextToken'] = page
diff --git a/euca2ools/commands/monitoring/listmetrics.py b/euca2ools/commands/monitoring/listmetrics.py
index ac1a4b4..29104dd 100644
--- a/euca2ools/commands/monitoring/listmetrics.py
+++ b/euca2ools/commands/monitoring/listmetrics.py
@@ -44,7 +44,7 @@ class ListMetrics(CloudWatchRequest, TabifyingMixin):
LIST_TAGS = ['Metrics', 'Dimensions']
def main(self):
- return PaginatedResponse(self, (None,), ('Metrics,'))
+ return PaginatedResponse(self, (None,), ('Metrics',))
def prepare_for_page(self, page):
self.params['NextToken'] = page
diff --git a/euca2ools/commands/monitoring/putmetricalarm.py b/euca2ools/commands/monitoring/putmetricalarm.py
index be52e06..1dc5c65 100644
--- a/euca2ools/commands/monitoring/putmetricalarm.py
+++ b/euca2ools/commands/monitoring/putmetricalarm.py
@@ -26,7 +26,7 @@
from euca2ools.commands.argtypes import delimited_list
from euca2ools.commands.monitoring import CloudWatchRequest
from euca2ools.commands.monitoring.argtypes import cloudwatch_dimension
-from requestbuilder import Arg, MutuallyExclusiveArgList
+from requestbuilder import Arg
class PutMetricAlarm(CloudWatchRequest):
diff --git a/euca2ools/commands/walrus/__init__.py b/euca2ools/commands/walrus/__init__.py
index 29550ad..3bfbe8c 100644
--- a/euca2ools/commands/walrus/__init__.py
+++ b/euca2ools/commands/walrus/__init__.py
@@ -23,15 +23,15 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import string
+import urlparse
+
from euca2ools.commands import Euca2ools
from euca2ools.exceptions import AWSError
-from requestbuilder import Arg, MutuallyExclusiveArgList, SERVICE
+from requestbuilder import Arg, MutuallyExclusiveArgList
import requestbuilder.auth
import requestbuilder.request
import requestbuilder.service
-from requestbuilder.xmlparse import parse_aws_xml
-import string
-import urlparse
class Walrus(requestbuilder.service.BaseService):
@@ -81,6 +81,7 @@ class WalrusRequest(requestbuilder.request.BaseRequest):
if isinstance(self.body, file):
self.log.debug('re-seeking body to beginning of file')
# pylint: disable=E1101
+ # noinspection PyUnresolvedReferences
self.body.seek(0)
# pylint: enable=E1101
return self.send()
diff --git a/euca2ools/commands/walrus/createbucket.py b/euca2ools/commands/walrus/createbucket.py
index 0d111b7..a40b045 100644
--- a/euca2ools/commands/walrus/createbucket.py
+++ b/euca2ools/commands/walrus/createbucket.py
@@ -24,7 +24,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from euca2ools.commands.walrus import (WalrusRequest,
- validate_generic_bucket_name)
+ validate_generic_bucket_name)
from requestbuilder import Arg
import xml.etree.ElementTree as ET
diff --git a/euca2ools/commands/walrus/deleteobject.py b/euca2ools/commands/walrus/deleteobject.py
index af5f08a..52b9205 100644
--- a/euca2ools/commands/walrus/deleteobject.py
+++ b/euca2ools/commands/walrus/deleteobject.py
@@ -32,6 +32,7 @@ class DeleteObject(WalrusRequest):
DESCRIPTION = 'Delete objects from the server'
ARGS = [Arg('paths', metavar='BUCKET/KEY', nargs='+', route_to=None)]
+ # noinspection PyExceptionInherit
def configure(self):
WalrusRequest.configure(self)
for path in self.args['paths']:
diff --git a/euca2ools/commands/walrus/listbucket.py b/euca2ools/commands/walrus/listbucket.py
index 39d6608..812193f 100644
--- a/euca2ools/commands/walrus/listbucket.py
+++ b/euca2ools/commands/walrus/listbucket.py
@@ -25,7 +25,7 @@
import argparse
from euca2ools.commands.walrus import (WalrusRequest,
- validate_generic_bucket_name)
+ validate_generic_bucket_name)
from requestbuilder import Arg
from requestbuilder.exceptions import ArgumentError
from requestbuilder.mixins import TabifyingMixin
@@ -39,11 +39,13 @@ class ListBucket(WalrusRequest, TabifyingMixin):
Arg('--max-keys-per-request', dest='max-keys', type=int,
help=argparse.SUPPRESS)]
+ # noinspection PyExceptionInherit
def configure(self):
WalrusRequest.configure(self)
for path in self.args['paths']:
if path.startswith('/'):
- raise ArgumentError(('argument \'{0}\' must not start with '
+ raise ArgumentError((
+ 'argument \'{0}\' must not start with '
'"/"; format is BUCKET[/KEY]').format(path))
bucket = path.split('/', 1)[0]
try:
@@ -59,7 +61,7 @@ class ListBucket(WalrusRequest, TabifyingMixin):
def get_next_page(self, response):
if response.get('IsTruncated') == 'true':
- return (self.path, {'marker': response['Contents'][-1]['Key']})
+ return self.path, {'marker': response['Contents'][-1]['Key']}
def prepare_for_page(self, page):
bucket, __, prefix = page[0].partition('/')
@@ -75,8 +77,9 @@ class ListBucket(WalrusRequest, TabifyingMixin):
del self.params['marker']
def parse_response(self, response):
- response_dict = self.log_and_parse_response(response,
- parse_aws_xml, list_item_tags=('Contents', 'CommonPrefixes'))
+ response_dict = self.log_and_parse_response(
+ response, parse_aws_xml,
+ list_item_tags=('Contents', 'CommonPrefixes'))
return response_dict['ListBucketResult']
def print_result(self, result):
diff --git a/euca2ools/commands/walrus/putobject.py b/euca2ools/commands/walrus/putobject.py
index 4e1f2fc..bbdd0dd 100644
--- a/euca2ools/commands/walrus/putobject.py
+++ b/euca2ools/commands/walrus/putobject.py
@@ -64,6 +64,7 @@ class PutObject(WalrusRequest, FileTransferProgressBarMixin):
self.last_upload_error = None
self._lock = threading.Lock()
+ # noinspection PyExceptionInherit
def configure(self):
WalrusRequest.configure(self)
if (self.args.get('literal_dest', False) and
@@ -74,6 +75,7 @@ class PutObject(WalrusRequest, FileTransferProgressBarMixin):
if self.args['dest'].startswith('/'):
raise ArgumentError('destination must begin with a bucket name')
+ # noinspection PyExceptionInherit
def main(self):
sources = list(self.args['sources'])
label_template = build_progressbar_label_template(sources)
diff --git a/euca2ools/nc/auth.py b/euca2ools/nc/auth.py
index e6cd42c..b62a58b 100644
--- a/euca2ools/nc/auth.py
+++ b/euca2ools/nc/auth.py
@@ -37,7 +37,7 @@ import urllib
class EucaRsaV2Auth(BaseAuth):
- '''Provides authentication for inter-component requests'''
+ """Provides authentication for inter-component requests"""
ARGS = [Arg('--cert', metavar='FILE', help='''file containing the X.509
certificate to use when signing requests'''),
@@ -47,6 +47,7 @@ class EucaRsaV2Auth(BaseAuth):
help='run this command as if signed by a specific access key'),
Arg('--euca-auth', action='store_true', help=argparse.SUPPRESS)]
+ # noinspection PyExceptionInherit
def configure(self):
BaseAuth.configure(self)
if not self.args.get('spoof_key_id'):
@@ -93,7 +94,7 @@ class EucaRsaV2Auth(BaseAuth):
self.log.debug('certificate fingerprint: %s', cert_fp)
headers_to_sign = self._get_headers_to_sign(request)
- signed_headers = self._get_signed_headers(headers_to_sign)
+ signed_headers = self._get_signed_headers(headers_to_sign)
self.log.debug('SignedHeaders:%s', signed_headers)
canonical_request = self._get_canonical_request(request)
@@ -129,7 +130,7 @@ class EucaRsaV2Auth(BaseAuth):
# 1. request method
method = request.method.upper()
# 2. CanonicalURI
- c_uri = self._get_canonical_uri(request)
+ c_uri = self._get_canonical_uri(request)
# 3. CanonicalQueryString
c_querystr = self._get_canonical_querystr(request)
# 4. CanonicalHeaders
diff --git a/euca2ools/util.py b/euca2ools/util.py
index 8eb51ba..887b657 100644
--- a/euca2ools/util.py
+++ b/euca2ools/util.py
@@ -42,12 +42,12 @@ def build_progressbar_label_template(fnames):
# pylint: disable=W0622
def mkdtemp_for_large_files(suffix='', prefix='tmp', dir=None):
- '''
+ """
Like tempfile.mkdtemp, but using /var/tmp as a last resort instead of /tmp.
This is meant for utilities that create large files, as /tmp is often a
ramdisk.
- '''
+ """
if dir is None:
dir = (os.getenv('TMPDIR') or os.getenv('TEMP') or os.getenv('TMP') or
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-eucalyptus/euca2ools.git
More information about the pkg-eucalyptus-commits
mailing list