From 5e792870f005d18eb8ace131296d0511764afb08 Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Thu, 10 Oct 2013 22:00:08 -0400 Subject: [PATCH] Fix pep8 errors in examples/ --- examples/how_to/create_a_job.py | 2 +- examples/how_to/create_nested_views.py | 6 +++--- examples/how_to/create_views.py | 2 +- examples/how_to/get_config.py | 1 - examples/how_to/get_version_info_from_last_good_build.py | 1 + examples/how_to/query_a_build.py | 4 ++-- examples/how_to/search_artifact_by_regexp.py | 2 +- examples/how_to/search_artifacts.py | 4 ++-- examples/low_level/copy_a_job.py | 3 +-- examples/low_level/create_a_view_low_level.py | 2 +- examples/low_level/example_param_build.py | 8 ++++---- examples/low_level/login_with_auth.py | 2 +- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/examples/how_to/create_a_job.py b/examples/how_to/create_a_job.py index 7758b24..5c7eda6 100644 --- a/examples/how_to/create_a_job.py +++ b/examples/how_to/create_a_job.py @@ -11,7 +11,7 @@ print xml j = J.create_job(jobname=jobName, config=xml) -j2= J[jobName] +j2 = J[jobName] print j # Delete job diff --git a/examples/how_to/create_nested_views.py b/examples/how_to/create_nested_views.py index 224205a..1ce245c 100644 --- a/examples/how_to/create_nested_views.py +++ b/examples/how_to/create_nested_views.py @@ -1,5 +1,5 @@ # This example requires NestedViews plugin to be installed in Jenkins -# You need to have at least one job in your Jenkins to see views +# You need to have at least one job in your Jenkins to see views import logging from pkg_resources import resource_string @@ -22,7 +22,7 @@ j = api.create_job(jobname=jobName, config=xml) logger.info('Attempting to create new nested view') top_view = api.views.create('TopView', Views.NESTED_VIEW) logger.info('top_view is %s' % top_view) -if top_view == None: +if top_view is None: logger.error('View was not created') else: logger.info('View has been created') @@ -30,7 +30,7 @@ else: print 'top_view.views=', top_view.views.keys() logger.info('Attempting to create view inside nested view') sub_view = top_view.views.create('SubView') -if sub_view == None: +if sub_view is None: logger.info('View was not created') else: logger.error('View has been created') diff --git a/examples/how_to/create_views.py b/examples/how_to/create_views.py index 6e8df27..b490089 100644 --- a/examples/how_to/create_views.py +++ b/examples/how_to/create_views.py @@ -14,7 +14,7 @@ api = Jenkins(jenkins_url) logger.info('Attempting to create new view') new_view = api.create_view('SimpleListView') logger.info('new_view is %s' % new_view) -if new_view == None: +if new_view is None: logger.error('View was not created') else: logger.info('View has been created') diff --git a/examples/how_to/get_config.py b/examples/how_to/get_config.py index 7a10394..088dafb 100644 --- a/examples/how_to/get_config.py +++ b/examples/how_to/get_config.py @@ -8,4 +8,3 @@ jobName = 'create_fwrgmkbbzk' config = J[jobName].get_config() print config - diff --git a/examples/how_to/get_version_info_from_last_good_build.py b/examples/how_to/get_version_info_from_last_good_build.py index 433574e..575f2bb 100644 --- a/examples/how_to/get_version_info_from_last_good_build.py +++ b/examples/how_to/get_version_info_from_last_good_build.py @@ -3,6 +3,7 @@ Extract version information from the latest build. """ from jenkinsapi.jenkins import Jenkins + def getSCMInfroFromLatestGoodBuild(url, jobName, username=None, password=None): J = Jenkins(url, username, password) job = J[jobName] diff --git a/examples/how_to/query_a_build.py b/examples/how_to/query_a_build.py index c705e6d..8272517 100644 --- a/examples/how_to/query_a_build.py +++ b/examples/how_to/query_a_build.py @@ -2,7 +2,7 @@ from jenkinsapi.view import View from jenkinsapi.jenkins import Jenkins J = Jenkins('http://localhost:8080') print J.items() -j= J['foo'] +j = J['foo'] j = J.get_job("foo") b = j.get_last_build() print b @@ -29,4 +29,4 @@ EMPTY_JOB_CONFIG = '''\ ''' -new_job = J.create_job(name='foo_job', config=EMPTY_JOB_CONFIG) \ No newline at end of file +new_job = J.create_job(name='foo_job', config=EMPTY_JOB_CONFIG) diff --git a/examples/how_to/search_artifact_by_regexp.py b/examples/how_to/search_artifact_by_regexp.py index 491e4d2..322b541 100644 --- a/examples/how_to/search_artifact_by_regexp.py +++ b/examples/how_to/search_artifact_by_regexp.py @@ -3,6 +3,6 @@ import re jenkinsurl = "http://localhost:8080/jenkins" jobid = "test1" -artifact_regexp = re.compile("test1\.txt") # A file name I want. +artifact_regexp = re.compile("test1\.txt") # A file name I want. result = search_artifact_by_regexp(jenkinsurl, jobid, artifact_regexp) print((repr(result))) diff --git a/examples/how_to/search_artifacts.py b/examples/how_to/search_artifacts.py index 5ad7080..cbf3c9b 100644 --- a/examples/how_to/search_artifacts.py +++ b/examples/how_to/search_artifacts.py @@ -2,6 +2,6 @@ from jenkinsapi.api import search_artifacts jenkinsurl = "http://localhost:8080/jenkins" jobid = "test1" -artifact_ids = [ "test1.txt", "test2.txt" ] # I need a build that contains all of these +artifact_ids = ["test1.txt", "test2.txt"] # I need a build that contains all of these result = search_artifacts(jenkinsurl, jobid, artifact_ids) -print((repr(result ))) +print((repr(result))) diff --git a/examples/low_level/copy_a_job.py b/examples/low_level/copy_a_job.py index 3eef8b6..3ee4299 100644 --- a/examples/low_level/copy_a_job.py +++ b/examples/low_level/copy_a_job.py @@ -11,8 +11,7 @@ J = Jenkins('http://localhost:8080') jobName = random_string() jobName2 = '%s_2' % jobName -url = 'http://localhost:8080/createItem?from=%s&name=%s&mode=copy' % ( - jobName, jobName2) +url = 'http://localhost:8080/createItem?from=%s&name=%s&mode=copy' % (jobName, jobName2) xml = resource_string('examples', 'addjob.xml') j = J.create_job(jobname=jobName, config=xml) diff --git a/examples/low_level/create_a_view_low_level.py b/examples/low_level/create_a_view_low_level.py index 56075e8..606941a 100644 --- a/examples/low_level/create_a_view_low_level.py +++ b/examples/low_level/create_a_view_low_level.py @@ -8,7 +8,7 @@ import json url = 'http://localhost:8080/createView' str_view_name = "blahblah123" -params = {}# {'name': str_view_name} +params = {} # {'name': str_view_name} headers = {'Content-Type': 'application/x-www-form-urlencoded'} data = { "name": str_view_name, diff --git a/examples/low_level/example_param_build.py b/examples/low_level/example_param_build.py index 0177012..987d0f1 100644 --- a/examples/low_level/example_param_build.py +++ b/examples/low_level/example_param_build.py @@ -1,18 +1,18 @@ import json import requests + def foo(): """ A low level example of how JenkinsAPI runs a parameterized build """ - toJson = {'parameter':[{'name':'B', 'value':'xyz'}]} + toJson = {'parameter': [{'name': 'B', 'value': 'xyz'}]} url = 'http://localhost:8080/job/ddd/build' - #url = 'http://localhost:8000' + # url = 'http://localhost:8000' headers = {'Content-Type': 'application/x-www-form-urlencoded'} - form = {'json':json.dumps(toJson)} + form = {'json': json.dumps(toJson)} response = requests.post(url, data=form, headers=headers) print response.text.encode('UTF-8') if __name__ == '__main__': foo() - diff --git a/examples/low_level/login_with_auth.py b/examples/low_level/login_with_auth.py index 189be69..c28f670 100644 --- a/examples/low_level/login_with_auth.py +++ b/examples/low_level/login_with_auth.py @@ -5,7 +5,7 @@ A lower level example of how we login with authentication from jenkinsapi import jenkins -J = jenkins.Jenkins("http://localhost:8080", username = "sal", password = "foobar") +J = jenkins.Jenkins("http://localhost:8080", username="sal", password="foobar") J.poll() print J.items() -- 2.34.1