Fixed pep8 failures in all tools/ scripts

Change-Id: Ie6e77a4d45210122746b544a1aa8da563833e395
Partially-Implements: blueprint enable-flake8
This commit is contained in:
Borne Mace 2015-07-07 08:22:25 -07:00
parent 75e01a2fb2
commit 42c2419353
3 changed files with 35 additions and 27 deletions

View File

@ -3,7 +3,8 @@
# TODO(SamYaple): Allow image pushing
# TODO(SamYaple): Single image building w/ optional parent building
# TODO(SamYaple): Build only missing images
#TODO(SamYaple): Execute the source install script that will pull down and create tarball
# TODO(SamYaple): Execute the source install script that will pull
# down and create tarball
# TODO(SamYaple): Improve logging instead of printing to stdout
from __future__ import print_function
@ -21,7 +22,9 @@ import traceback
import docker
class WorkerThread(Thread):
def __init__(self, queue, cache, rm):
self.queue = queue
self.nocache = not cache
@ -51,7 +54,7 @@ class WorkerThread(Thread):
return
# Pull the latest image for the base distro only
pull = True if image['parent'] == None else False
pull = True if image['parent'] is None else False
image['logs'] = str()
for response in self.dc.build(path=image['path'],
@ -71,6 +74,7 @@ class WorkerThread(Thread):
image['status'] = "built"
print(image['logs'], '\nProcessed:', image['name'])
def argParser():
parser = argparse.ArgumentParser(description='Kolla build script')
parser.add_argument('-n', '--namespace',
@ -103,7 +107,9 @@ def argParser():
default=8)
return vars(parser.parse_args())
class KollaWorker():
def __init__(self, args):
self.kolla_dir = os.path.join(sys.path[0], '..')
self.images_dir = os.path.join(self.kolla_dir, 'docker')
@ -145,7 +151,7 @@ class KollaWorker():
processed_images = list()
for image in images_to_process:
if image['parent'] == None:
if image['parent'] is None:
self.tiers[-1].append(image)
processed_images.append(image)
if len(self.tiers) > 1:
@ -157,7 +163,8 @@ class KollaWorker():
# TODO(SamYaple): Improve error handling in this section
if not processed_images:
print('Could not find parent image from some images. Aborting', file=sys.stderr)
print('Could not find parent image from some images. Aborting',
file=sys.stderr)
for image in images_to_process:
print(image['name'], image['parent'], file=sys.stderr)
sys.exit()
@ -180,7 +187,8 @@ class KollaWorker():
print("===========================")
for image in self.images:
if image['status'] != "built":
print(image['name'], "\r\t\t\t Failed with status:", image['status'])
print(image['name'], "\r\t\t\t Failed with status:",
image['status'])
def buildImageList(self):
self.images = list()
@ -188,7 +196,8 @@ class KollaWorker():
# Walk all of the Dockerfiles and replace the %%KOLLA%% variables
for path in self.docker_build_paths:
with open(os.path.join(path, 'Dockerfile')) as f:
content = f.read().replace('%%KOLLA_NAMESPACE%%', self.namespace)
content = f.read().replace('%%KOLLA_NAMESPACE%%',
self.namespace)
content = content.replace('%%KOLLA_PREFIX%%', self.prefix)
content = content.replace('%%KOLLA_TAG%%', self.tag)
with open(os.path.join(path, 'Dockerfile'), 'w') as f:
@ -201,7 +210,7 @@ class KollaWorker():
image['name'] + ':' + self.tag
image['path'] = path
image['parent'] = content.split(' ')[1].split('\n')[0]
if not self.namespace in image['parent']:
if self.namespace not in image['parent']:
image['parent'] = None
self.images.append(image)
@ -224,6 +233,7 @@ class KollaWorker():
return pools
def main():
args = argParser()

View File

@ -1,16 +1,17 @@
#!/usr/bin/python
import os
import sys
import argparse
import json
import logging
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('input', nargs='*')
return p.parse_args()
def main():
args = parse_args()
logging.basicConfig()
@ -19,7 +20,7 @@ def main():
for filename in args.input:
with open(filename) as fd:
try:
data = json.load(fd)
json.load(fd)
except ValueError as error:
res = 1
logging.error('%s failed validation: %s',
@ -29,5 +30,3 @@ def main():
if __name__ == '__main__':
main()

View File

@ -1,16 +1,17 @@
#!/usr/bin/python
import os
import sys
import argparse
import yaml
import logging
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('input', nargs='*')
return p.parse_args()
def main():
args = parse_args()
logging.basicConfig()
@ -19,7 +20,7 @@ def main():
for filename in args.input:
with open(filename) as fd:
try:
data = yaml.load(fd)
yaml.load(fd)
except yaml.error.YAMLError as error:
res = 1
logging.error('%s failed validation: %s',
@ -29,5 +30,3 @@ def main():
if __name__ == '__main__':
main()