Skip to content

Commit

Permalink
Fix Python linter errors - Part 1 (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalfishpond authored and matrixik committed Nov 8, 2017
1 parent cf882e2 commit fd5460f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
6 changes: 2 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# coding=utf-8

# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
#
Expand All @@ -14,12 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.





def main():
pass


if __name__ == '__main__':
main()
38 changes: 18 additions & 20 deletions ci.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# coding=utf-8

# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
#
Expand Down Expand Up @@ -172,7 +173,7 @@ def upload_manifest(pipeline, voting, uploaded_files, dirty_modules, files, tags
manifest_dict = print_env(pipeline, voting, to_print=False)
manifest_dict['modules'] = {}
for module in dirty_modules:
manifest_dict['modules'][module] = {'files': []}
manifest_dict['modules'][module] = {'files': []}
for f in files:
if module in f:
if 'init' not in module and 'init' not in f or 'init' in module and 'init' in f:
Expand All @@ -182,7 +183,7 @@ def upload_manifest(pipeline, voting, uploaded_files, dirty_modules, files, tags
for f, url in uploaded_files.iteritems():
if module in f:
if 'init' not in module and 'init' not in f or 'init' in module and 'init' in f:
manifest_dict['modules'][module]['uploaded_log_file'][f] = url
manifest_dict['modules'][module]['uploaded_log_file'][f] = url

manifest_dict['run_logs'] = {}
for f, url in uploaded_files.iteritems():
Expand All @@ -197,7 +198,6 @@ def upload_manifest(pipeline, voting, uploaded_files, dirty_modules, files, tags

def upload_files(log_dir, bucket):
uploaded_files = {}
blob = bucket.blob(log_dir)
for f in os.listdir(log_dir):
file_path = log_dir + f
if os.path.isfile(file_path):
Expand Down Expand Up @@ -347,7 +347,7 @@ def kill(signal, frame):
def run_push(modules):
if os.environ.get('TRAVIS_SECURE_ENV_VARS', None) != "true":
print('No push permissions in this context, skipping!')
print('Not pushing: %r' % modules)
print('Not pushing: {!r}'.format(modules))
return

username = os.environ.get('DOCKER_HUB_USERNAME', None)
Expand Down Expand Up @@ -384,7 +384,7 @@ def kill(signal, frame):
def run_readme(modules):
if os.environ.get('TRAVIS_SECURE_ENV_VARS', None) != "true":
print('No Docker Hub permissions in this context, skipping!')
print('Not updating READMEs: %r' % modules)
print('Not updating READMEs: {!r}'.format(modules))
return

log_dir = BUILD_LOG_DIR
Expand Down Expand Up @@ -438,9 +438,9 @@ def update_docker_compose(modules, pipeline):
try:
with open(CI_COMPOSE_FILE, 'w') as docker_compose:
yaml.dump(compose_dict, docker_compose, default_flow_style=False)
except:
except (RuntimeError, EnvironmentError):
raise FileWriteException(
'Error writing CI dictionary to %s' % CI_COMPOSE_FILE
'Error writing CI dictionary to {}'.format(CI_COMPOSE_FILE)
)


Expand All @@ -449,7 +449,7 @@ def load_yml(yml_path):
with open(yml_path) as compose_file:
compose_dict = yaml.safe_load(compose_file)
return compose_dict
except:
except(RuntimeError, EnvironmentError):
raise FileReadException('Failed to read %s', yml_path)


Expand Down Expand Up @@ -482,11 +482,11 @@ def handle_pull_request(files, modules, tags, pipeline):
cool_test_mapper = {
'smoke': {
METRIC_PIPELINE_MARKER: run_smoke_tests_metrics,
LOG_PIPELINE_MARKER: lambda : print('No smoke tests for logs')
LOG_PIPELINE_MARKER: lambda: print('No smoke tests for logs')
},
'tempest': {
METRIC_PIPELINE_MARKER: run_tempest_tests_metrics,
LOG_PIPELINE_MARKER: lambda : print('No tempest tests for logs')
LOG_PIPELINE_MARKER: lambda: print('No tempest tests for logs')
}
}

Expand All @@ -510,19 +510,17 @@ def pick_modules_for_pipeline(modules, pipeline):
other_modules = [
'storm'
]
print('modules: %s \n pipeline_modules: %s' % (modules, pipeline_modules))
print('modules: {} \n pipeline_modules: {}'.format(modules, pipeline_modules))

# iterate over copy of all modules that are planned for the build
# if one of them does not belong to active pipeline
# remove from current run
for m in modules[::]:
if m not in pipeline_modules:
if m in other_modules:
print('%s is not part of either pipeline, but it will be build anyway' % m)
print('{} is not part of either pipeline, but it will be build anyway'.format(m))
continue
print('Module %s does not belong to %s, skipping' % (
m, pipeline
))
print('Module {} does not belong to {}, skipping'.format(m, pipeline))
modules.remove(m)

return modules
Expand Down Expand Up @@ -768,7 +766,7 @@ def kill(signal, frame):

signal.signal(signal.SIGINT, kill)
time_delta = 0
while(True):
while True:
poll = p.poll()
if poll is None:
if time_delta == 1500:
Expand All @@ -787,7 +785,7 @@ def kill(signal, frame):


def handle_other(files, modules, tags, pipeline):
print('Unsupported event type "%s", nothing to do.' % (
print('Unsupported event type "{}", nothing to do.'.format(
os.environ.get('TRAVIS_EVENT_TYPE')))


Expand All @@ -798,7 +796,7 @@ def print_env(pipeline, voting, to_print=True):
'TRAVIS_PULL_REQUEST': os.environ.get('TRAVIS_PULL_REQUEST'),
'TRAVIS_PULL_REQUEST_SHA': os.environ.get('TRAVIS_PULL_REQUEST_SHA'),
'TRAVIS_PULL_REQUEST_SLUG': os.environ.get('TRAVIS_PULL_REQUEST_SLUG'),
'TRAVIS_SECURE_ENV_VARS': os.environ.get('TRAVIS_SECURE_ENV_VARS'),
'TRAVIS_SECURE_ENV_VARS': os.environ.get('TRAVIS_SECURE_ENV_VARS'),
'TRAVIS_EVENT_TYPE': os.environ.get('TRAVIS_EVENT_TYPE'),
'TRAVIS_BRANCH': os.environ.get('TRAVIS_BRANCH'),
'TRAVIS_PULL_REQUEST_BRANCH': os.environ.get('TRAVIS_PULL_REQUEST_BRANCH'),
Expand All @@ -808,7 +806,7 @@ def print_env(pipeline, voting, to_print=True):
'TRAVIS_JOB_NUMBER': os.environ.get('TRAVIS_JOB_NUMBER'),

'CI_PIPELINE': pipeline,
'CI_VOTING': voting }}
'CI_VOTING': voting}}

if to_print:
print (json.dumps(environ_vars, indent=2))
Expand Down Expand Up @@ -856,7 +854,7 @@ def main():
if voting:
raise
else:
print('%s is not voting, skipping failure' % pipeline)
print('{} is not voting, skipping failure'.format(pipeline))
finally:
output_docker_ps()
output_docker_logs()
Expand Down

0 comments on commit fd5460f

Please sign in to comment.