PEP 8 W291 whitespace cleanup.

This commit is contained in:
Matt Clay 2017-01-27 15:20:31 -08:00
parent 95789f3949
commit d913f69ba1
166 changed files with 493 additions and 565 deletions

View file

@ -503,24 +503,24 @@ AUTH_PARAM_MAPPING = {
@contextmanager
def stdout_redirector(path_name):
old_stdout = sys.stdout
old_stdout = sys.stdout
fd = open(path_name, 'w')
sys.stdout = fd
try:
yield
finally:
sys.stdout = old_stdout
sys.stdout = old_stdout
def get_stdout(path_name):
full_stdout = ''
last_line = ''
last_line = ''
with open(path_name, 'r') as fd:
for line in fd:
# strip terminal format/color chars
new_line = re.sub(r'\x1b\[.+m', '', line.encode('ascii'))
full_stdout += new_line
if new_line.strip():
# Assuming last line contains the error message
# Assuming last line contains the error message
last_line = new_line.strip().encode('utf-8')
fd.close()
os.remove(path_name)
@ -666,12 +666,12 @@ class ContainerManager(DockerBaseClass):
if self.pull:
pull_output = self.cmd_pull()
result['changed'] = pull_output['changed']
result['changed'] = pull_output['changed']
result['actions'] += pull_output['actions']
if self.build:
build_output = self.cmd_build()
result['changed'] = build_output['changed']
result['changed'] = build_output['changed']
result['actions'] += build_output['actions']
for service in self.project.services:
@ -679,8 +679,8 @@ class ContainerManager(DockerBaseClass):
plan = service.convergence_plan(strategy=converge)
if plan.action != 'noop':
result['changed'] = True
result_action = dict(service=service.name)
result_action[plan.action] = []
result_action = dict(service=service.name)
result_action[plan.action] = []
for container in plan.containers:
result_action[plan.action].append(dict(
id=container.id,
@ -712,17 +712,17 @@ class ContainerManager(DockerBaseClass):
if self.stopped:
stop_output = self.cmd_stop(service_names)
result['changed'] = stop_output['changed']
result['changed'] = stop_output['changed']
result['actions'] += stop_output['actions']
if self.restarted:
restart_output = self.cmd_restart(service_names)
result['changed'] = restart_output['changed']
result['changed'] = restart_output['changed']
result['actions'] += restart_output['actions']
if self.scale:
scale_output = self.cmd_scale()
result['changed'] = scale_output['changed']
result['changed'] = scale_output['changed']
result['actions'] += scale_output['actions']
for service in self.project.services:
@ -791,7 +791,7 @@ class ContainerManager(DockerBaseClass):
if not self.check_mode:
for service in self.project.get_services(self.services, include_deps=False):
if 'image' not in service.options:
continue
continue
self.log('Pulling image for service %s' % service.name)
# store the existing image ID
@ -809,16 +809,16 @@ class ContainerManager(DockerBaseClass):
try:
service.pull(ignore_pull_failures=False)
except Exception as exc:
self.client.fail("Error: pull failed with %s" % str(exc))
self.client.fail("Error: pull failed with %s" % str(exc))
# store the new image ID
new_image_id = ''
new_image_id = ''
try:
image = service.image()
if image and image.get('Id'):
new_image_id = image['Id']
except NoSuchImageError as exc:
self.client.fail("Error: service image lookup failed after pull - %s" % str(exc))
self.client.fail("Error: service image lookup failed after pull - %s" % str(exc))
if new_image_id != old_image_id:
# if a new image was pulled
@ -856,13 +856,13 @@ class ContainerManager(DockerBaseClass):
try:
new_image_id = service.build(pull=True, no_cache=self.nocache)
except Exception as exc:
self.client.fail("Error: build failed with %s" % str(exc))
self.client.fail("Error: build failed with %s" % str(exc))
if new_image_id not in old_image_id:
# if a new image was built
result['changed'] = True
result['actions'].append(dict(
service=service.name,
service=service.name,
built_image=dict(
name=service.image_name,
id=new_image_id
@ -901,7 +901,7 @@ class ContainerManager(DockerBaseClass):
service_res = dict(
service=service.name,
stop=[]
)
)
for container in service.containers(stopped=False):
result['changed'] = True
service_res['stop'].append(dict(
@ -977,7 +977,7 @@ class ContainerManager(DockerBaseClass):
service.scale(int(self.scale[service.name]))
except Exception as exc:
self.client.fail("Error scaling %s - %s" % (service.name, str(exc)))
result['actions'].append(service_res)
result['actions'].append(service_res)
return result