Skip to content

Commit

Permalink
Cleanup various inconsistencies
Browse files Browse the repository at this point in the history
- > 80 character lines
- mixed use of ' and " (only use " now)
- some minor grammar errors
  • Loading branch information
phobologic committed Jun 18, 2016
1 parent 1b683f8 commit 5456567
Show file tree
Hide file tree
Showing 38 changed files with 517 additions and 504 deletions.
2 changes: 1 addition & 1 deletion scripts/stacker
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from stacker.commands import Stacker

if __name__ == '__main__':
if __name__ == "__main__":
stacker = Stacker()
args = stacker.parse_args()
stacker.configure(args)
Expand Down
34 changes: 17 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
from setuptools import setup, find_packages
import glob

VERSION = '0.6.3'
VERSION = "0.6.3"

src_dir = os.path.dirname(__file__)

install_requires = [
'troposphere>=1.2.2',
'boto>=2.25.0',
'botocore>=1.3.15',
'PyYAML>=3.11',
'awacs>=0.5.3',
"troposphere>=1.2.2",
"boto>=2.25.0",
"botocore>=1.3.15",
"PyYAML>=3.11",
"awacs>=0.5.3",
]

tests_require = [
'nose>=1.0',
'mock==1.0.1',
'stacker_blueprints',
"nose>=1.0",
"mock==1.0.1",
"stacker_blueprints",
]


Expand All @@ -27,19 +27,19 @@ def read(filename):
return fd.read()


if __name__ == '__main__':
if __name__ == "__main__":
setup(
name='stacker',
name="stacker",
version=VERSION,
author='Michael Barrett',
author_email='[email protected]',
author="Michael Barrett",
author_email="[email protected]",
license="New BSD license",
url="https://github.com/remind101/stacker",
description='Opinionated AWS CloudFormation Stack manager',
long_description=read('README.rst'),
description="Opinionated AWS CloudFormation Stack manager",
long_description=read("README.rst"),
packages=find_packages(),
scripts=glob.glob(os.path.join(src_dir, 'scripts', '*')),
scripts=glob.glob(os.path.join(src_dir, "scripts", "*")),
install_requires=install_requires,
tests_require=tests_require,
test_suite='nose.collector',
test_suite="nose.collector",
)
2 changes: 1 addition & 1 deletion stacker/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.3'
__version__ = "0.6.3"
10 changes: 5 additions & 5 deletions stacker/actions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ def __init__(self, context, provider=None):
@property
def s3_conn(self):
"""The boto s3 connection object used for communication with S3."""
if not hasattr(self, '_s3_conn'):
if not hasattr(self, "_s3_conn"):
self._s3_conn = boto.connect_s3()
return self._s3_conn

@property
def cfn_bucket(self):
"""The cloudformation bucket where templates will be stored."""
if not getattr(self, '_cfn_bucket', None):
if not getattr(self, "_cfn_bucket", None):
try:
self._cfn_bucket = self.s3_conn.get_bucket(self.bucket_name)
except boto.exception.S3ResponseError, e:
if e.error_code == 'NoSuchBucket':
if e.error_code == "NoSuchBucket":
logger.debug("Creating bucket %s.", self.bucket_name)
self._cfn_bucket = self.s3_conn.create_bucket(
self.bucket_name)
elif e.error_code == 'AccessDenied':
elif e.error_code == "AccessDenied":
logger.exception("Access denied for bucket %s.",
self.bucket_name)
raise
Expand Down Expand Up @@ -117,7 +117,7 @@ def pre_run(self, *args, **kwargs):
pass

def run(self, *args, **kwargs):
raise NotImplementedError('Subclass must implement "run" method')
raise NotImplementedError("Subclass must implement \"run\" method")

def post_run(self, *args, **kwargs):
pass
Expand Down
26 changes: 13 additions & 13 deletions stacker/actions/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,27 @@ def resolve_parameters(parameters, blueprint, context, provider):
blueprint.name, k)
continue
value = v
if isinstance(value, basestring) and '::' in value:
if isinstance(value, basestring) and "::" in value:
# Get from the Output(s) of another stack(s) in the stack_map
v_list = []
values = value.split(',')
values = value.split(",")
for v in values:
v = v.strip()
stack_name, output = v.split('::')
stack_name, output = v.split("::")
stack_fqn = context.get_fqn(stack_name)
try:
v_list.append(
provider.get_output(stack_fqn, output))
except KeyError:
raise exceptions.OutputDoesNotExist(stack_fqn, v)
value = ','.join(v_list)
value = ",".join(v_list)
if value is None:
logger.debug("Got None value for parameter %s, not submitting it "
"to cloudformation, default value should be used.",
k)
continue
if isinstance(value, bool):
logger.debug("Converting parameter %s boolean '%s' to string.",
logger.debug("Converting parameter %s boolean \"%s\" to string.",
k, value)
value = str(value).lower()
params[k] = value
Expand Down Expand Up @@ -168,7 +168,7 @@ def build_parameters(self, stack, provider_stack=None):
def _build_stack_tags(self, stack):
"""Builds a common set of tags to attach to a stack"""
tags = {
'stacker_namespace': self.context.namespace,
"stacker_namespace": self.context.namespace,
}
return tags

Expand Down Expand Up @@ -266,8 +266,8 @@ def _handle_missing_parameters(self, params, required_params,
def _generate_plan(self, tail=False):
plan_kwargs = {}
if tail:
plan_kwargs['watch_func'] = self.provider.tail_stack
plan = Plan(description='Create/Update stacks', **plan_kwargs)
plan_kwargs["watch_func"] = self.provider.tail_stack
plan = Plan(description="Create/Update stacks", **plan_kwargs)
stacks = self.context.get_stacks_dict()
dependencies = self._get_dependencies()
for stack_name in self.get_stack_execution_order(dependencies):
Expand All @@ -286,9 +286,9 @@ def _get_dependencies(self):

def pre_run(self, outline=False, *args, **kwargs):
"""Any steps that need to be taken prior to running the action."""
pre_build = self.context.config.get('pre_build')
pre_build = self.context.config.get("pre_build")
if not outline and pre_build:
util.handle_hooks('pre_build', pre_build, self.provider.region,
util.handle_hooks("pre_build", pre_build, self.provider.region,
self.context)

def run(self, outline=False, tail=False, dump=False, *args, **kwargs):
Expand All @@ -300,7 +300,7 @@ def run(self, outline=False, tail=False, dump=False, *args, **kwargs):
plan = self._generate_plan(tail=tail)
if not outline and not dump:
plan.outline(logging.DEBUG)
logger.info("Launching stacks: %s", ', '.join(plan.keys()))
logger.info("Launching stacks: %s", ", ".join(plan.keys()))
plan.execute()
else:
if outline:
Expand All @@ -310,7 +310,7 @@ def run(self, outline=False, tail=False, dump=False, *args, **kwargs):

def post_run(self, outline=False, *args, **kwargs):
"""Any steps that need to be taken after running the action."""
post_build = self.context.config.get('post_build')
post_build = self.context.config.get("post_build")
if not outline and post_build:
util.handle_hooks('post_build', post_build, self.provider.region,
util.handle_hooks("post_build", post_build, self.provider.region,
self.context)
18 changes: 9 additions & 9 deletions stacker/actions/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def _get_dependencies(self, stacks_dict):
def _generate_plan(self, tail=False):
plan_kwargs = {}
if tail:
plan_kwargs['watch_func'] = self.provider.tail_stack
plan = Plan(description='Destroy stacks', **plan_kwargs)
plan_kwargs["watch_func"] = self.provider.tail_stack
plan = Plan(description="Destroy stacks", **plan_kwargs)
stacks_dict = self.context.get_stacks_dict()
dependencies = self._get_dependencies(stacks_dict)
for stack_name in self.get_stack_execution_order(dependencies):
Expand All @@ -69,7 +69,7 @@ def _destroy_stack(self, stack, **kwargs):
# Once the stack has been destroyed, it doesn't exist. If the
# status of the step was SUBMITTED, we know we just deleted it,
# otherwise it should be skipped
if kwargs.get('status', None) == SUBMITTED:
if kwargs.get("status", None) == SUBMITTED:
return DestroyedStatus
else:
return StackDoesNotExistStatus()
Expand All @@ -90,9 +90,9 @@ def _destroy_stack(self, stack, **kwargs):

def pre_run(self, outline=False, *args, **kwargs):
"""Any steps that need to be taken prior to running the action."""
pre_destroy = self.context.config.get('pre_destroy')
pre_destroy = self.context.config.get("pre_destroy")
if not outline and pre_destroy:
util.handle_hooks('pre_destroy', pre_destroy, self.provider.region,
util.handle_hooks("pre_destroy", pre_destroy, self.provider.region,
self.context)

def run(self, force, tail=False, *args, **kwargs):
Expand All @@ -104,12 +104,12 @@ def run(self, force, tail=False, *args, **kwargs):
debug_plan.outline(logging.DEBUG)
plan.execute()
else:
plan.outline(message='To execute this plan, run with "--force" '
'flag.')
plan.outline(message="To execute this plan, run with \"--force\" "
"flag.")

def post_run(self, outline=False, *args, **kwargs):
"""Any steps that need to be taken after running the action."""
post_destroy = self.context.config.get('post_destroy')
post_destroy = self.context.config.get("post_destroy")
if not outline and post_destroy:
util.handle_hooks('post_destroy', post_destroy,
util.handle_hooks("post_destroy", post_destroy,
self.provider.region, self.context)
16 changes: 8 additions & 8 deletions stacker/actions/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ def diff_dictionaries(old_dict, new_dict):
output = []
for key in added_set:
changes += 1
output.append(['+', key, new_dict[key]])
output.append(["+", key, new_dict[key]])

for key in removed_set:
changes += 1
output.append(['-', key, old_dict[key]])
output.append(["-", key, old_dict[key]])

for key in common_set:
if str(old_dict[key]) != str(new_dict[key]):
changes += 1
output.append(['-', key, old_dict[key]])
output.append(['+', key, new_dict[key]])
output.append(["-", key, old_dict[key]])
output.append(["+", key, new_dict[key]])
else:
output.append([' ', key, new_dict[key]])
output.append([" ", key, new_dict[key]])

return [changes, output]

Expand All @@ -68,7 +68,7 @@ class Action(build.Action):
"""

def _diff_parameters(self, old_params, new_params):
"""Compares the old vs. new parameters and prints a 'diff'
"""Compares the old vs. new parameters and prints a "diff"
If there are no changes, we print nothing.
Expand Down Expand Up @@ -165,7 +165,7 @@ def _diff_stack(self, stack, **kwargs):
return COMPLETE

def _generate_plan(self):
plan = Plan(description='Diff stacks')
plan = Plan(description="Diff stacks")
stacks = self.context.get_stacks_dict()
dependencies = self._get_dependencies()
for stack_name in self.get_stack_execution_order(dependencies):
Expand All @@ -180,7 +180,7 @@ def run(self, *args, **kwargs):
plan = self._generate_plan()
debug_plan = self._generate_plan()
debug_plan.outline(logging.DEBUG)
logger.info("Diffing stacks: %s", ', '.join(plan.keys()))
logger.info("Diffing stacks: %s", ", ".join(plan.keys()))
plan.execute()

"""Don't ever do anything for pre_run or post_run"""
Expand Down
34 changes: 17 additions & 17 deletions stacker/blueprints/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def get_local_parameters(parameter_def, parameters):
value = parameters[param]
except KeyError:
try:
value = attrs['default']
value = attrs["default"]
except KeyError:
raise MissingLocalParameterException(param)

_type = attrs.get('type')
_type = attrs.get("type")
if _type:
try:
value = _type(value)
Expand All @@ -54,16 +54,16 @@ def get_local_parameters(parameter_def, parameters):
return local

PARAMETER_PROPERTIES = {
'default': 'Default',
'description': 'Description',
'no_echo': 'NoEcho',
'allowed_values': 'AllowedValues',
'allowed_pattern': 'AllowedPattern',
'max_length': 'MaxLength',
'min_length': 'MinLength',
'max_value': 'MaxValue',
'min_value': 'MinValue',
'constraint_description': 'ConstraintDescription'
"default": "Default",
"description": "Description",
"no_echo": "NoEcho",
"allowed_values": "AllowedValues",
"allowed_pattern": "AllowedPattern",
"max_length": "MaxLength",
"min_length": "MinLength",
"max_value": "MaxValue",
"min_value": "MinValue",
"constraint_description": "ConstraintDescription"
}


Expand All @@ -79,7 +79,7 @@ def build_parameter(name, properties):
Returns:
:class:`troposphere.Parameter`: The created parameter object.
"""
p = Parameter(name, Type=properties.get('type'))
p = Parameter(name, Type=properties.get("type"))
for name, attr in PARAMETER_PROPERTIES.items():
if name in properties:
setattr(p, attr, properties[name])
Expand Down Expand Up @@ -115,12 +115,12 @@ def required_parameters(self):
"""Returns all template parameters that do not have a default value."""
required = []
for k, v in self.parameters.items():
if not hasattr(v, 'Default'):
if not hasattr(v, "Default"):
required.append((k, v))
return required

def get_local_parameters(self):
local_parameters = getattr(self, 'LOCAL_PARAMETERS', {})
local_parameters = getattr(self, "LOCAL_PARAMETERS", {})
return get_local_parameters(local_parameters, self.context.parameters)

def _get_parameters(self):
Expand All @@ -137,8 +137,8 @@ def _get_parameters(self):
are dicts containing key/values for various parameter
properties.
"""
return getattr(self, 'CF_PARAMETERS',
getattr(self, 'PARAMETERS', {}))
return getattr(self, "CF_PARAMETERS",
getattr(self, "PARAMETERS", {}))

def setup_parameters(self):
t = self.template
Expand Down
6 changes: 3 additions & 3 deletions stacker/commands/stacker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class Stacker(BaseCommand):

name = 'stacker'
name = "stacker"
subcommands = (Build, Destroy, Info, Diff)

def configure(self, options, **kwargs):
Expand All @@ -31,5 +31,5 @@ def configure(self, options, **kwargs):
options.context.load_config(options.config.read())

def add_arguments(self, parser):
parser.add_argument('--version', action='version',
version='%%(prog)s %s' % (__version__,))
parser.add_argument("--version", action="version",
version="%%(prog)s %s" % (__version__,))
Loading

0 comments on commit 5456567

Please sign in to comment.