summaryrefslogtreecommitdiff
path: root/simplejenkinsapi
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-13 08:14:19 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-13 08:14:19 +0100
commit20f507162ccda864957d1aa81d450d369cbdb170 (patch)
tree379021015e6552048f9f6b8d52375c99b163cad3 /simplejenkinsapi
parent7570446bb78459c07ff965bfb0671b6d03469d4c (diff)
downloadjenkinstool-20f507162ccda864957d1aa81d450d369cbdb170.tar.gz
Remove trailing whitespace from lines
Diffstat (limited to 'simplejenkinsapi')
-rw-r--r--simplejenkinsapi/__init__.py6
-rw-r--r--simplejenkinsapi/api.py44
-rw-r--r--simplejenkinsapi/api_tests.py26
-rw-r--r--simplejenkinsapi/jobconfig.py16
-rw-r--r--simplejenkinsapi/order.py10
-rw-r--r--simplejenkinsapi/order_tests.py12
6 files changed, 57 insertions, 57 deletions
diff --git a/simplejenkinsapi/__init__.py b/simplejenkinsapi/__init__.py
index be54511..8974ed0 100644
--- a/simplejenkinsapi/__init__.py
+++ b/simplejenkinsapi/__init__.py
@@ -1,17 +1,17 @@
# simplejenkinsapi/__init__.py
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/simplejenkinsapi/api.py b/simplejenkinsapi/api.py
index 2c43396..9c6c66b 100644
--- a/simplejenkinsapi/api.py
+++ b/simplejenkinsapi/api.py
@@ -1,17 +1,17 @@
# simplejenkinsapi/api.py -- simple job management in Jenkins
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -33,13 +33,13 @@ import urlparse
class Jenkins(object):
'''Access a running Jenkins server.'''
-
+
def __init__(self, url): # pragma: no cover
self._url = url
-
+
def _connect(self): # pragma: no cover
'''Connect to HTTP server, return httplib.HTTPConnection.'''
- (scheme, netloc, path, params, query,
+ (scheme, netloc, path, params, query,
fragment) = urlparse.urlparse(self._url)
assert path == '/'
assert params == ''
@@ -56,19 +56,19 @@ class Jenkins(object):
return httplib.HTTPSConnection(host, port)
else:
return httplib.HTTPConnection(host, port)
-
+
def _do(self, method, path, body='', headers={}):
'''Make an HTTP request, return result.
-
+
If server returned JSON, return it as a Python object.
Otherwise, return as string.
-
+
'''
- logging.debug('HTTP method: %s' % repr(method))
- logging.debug('HTTP path: %s' % repr(path))
- logging.debug('HTTP body: %s' % repr(body))
- logging.debug('HTTP headers: %s' % repr(headers))
+ logging.debug('HTTP method: %s' % repr(method))
+ logging.debug('HTTP path: %s' % repr(path))
+ logging.debug('HTTP body: %s' % repr(body))
+ logging.debug('HTTP headers: %s' % repr(headers))
conn = self._connect()
conn.request(method, path, body, headers)
resp = conn.getresponse()
@@ -88,7 +88,7 @@ class Jenkins(object):
return json.loads(text)
else:
return text
-
+
def list_jobs(self):
'''Return list of job ids on the server.'''
@@ -103,10 +103,10 @@ class Jenkins(object):
def create_job(self, job_id, config_xml):
'''Create a new job.
-
- ``config_xml`` is a string containing the XML format configuration
+
+ ``config_xml`` is a string containing the XML format configuration
of the job.
-
+
'''
self._do('POST', '/createItem?name=%s' % job_id, body=config_xml,
@@ -114,18 +114,18 @@ class Jenkins(object):
def update_job(self, job_id, config_xml):
'''Update the configuration of a new job.
-
- ``config_xml`` is a string containing the XML format configuration
+
+ ``config_xml`` is a string containing the XML format configuration
of the job.
-
+
'''
-
+
self._do('POST', '/job/%s/config.xml' % job_id, body=config_xml,
headers={ 'Content-Type': 'text/xml' })
def get_job_config(self, job_id):
'''Return the XML configuration of a job.'''
-
+
return self._do('GET', '/job/%s/config.xml' % job_id)
def run_job(self, job_id): # pragma: no cover
diff --git a/simplejenkinsapi/api_tests.py b/simplejenkinsapi/api_tests.py
index 6e7c943..6c04c53 100644
--- a/simplejenkinsapi/api_tests.py
+++ b/simplejenkinsapi/api_tests.py
@@ -1,17 +1,17 @@
# simplejenkinsapi/api_tests.py -- unit test for simplejenkinsapi/api.py
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -31,13 +31,13 @@ class DummyResponse(object):
self.reason = 'yeah yeah'
self.body = body
self.content_type = content_type
-
+
def getheader(self, header):
if header == 'Content-Type':
return self.content_type
else:
return ''
-
+
def read(self):
return self.body
@@ -53,7 +53,7 @@ class DummyServer(object):
self.add_route('POST', '/job/job-1/config.xml', self.update_job_1)
self.jobs = {}
-
+
self.response = None
def add_route(self, method, path, callback):
@@ -95,7 +95,7 @@ class DummyServer(object):
key = (method, path)
assert key in self.routes
self.response, self.response_type = self.routes[key](body, headers)
-
+
def getresponse(self):
return DummyResponse(self.response, self.response_type)
@@ -105,26 +105,26 @@ class JenkinsTests(unittest.TestCase):
def setUp(self):
self.url = 'http://does.not.exist:8080/'
self.jenkins = simplejenkinsapi.Jenkins(self.url)
-
+
self.dummy_server = DummyServer()
self.jenkins._connect = lambda: self.dummy_server
-
+
self.config_xml = '''
<?xml version="1.0" encoding="UTF-8"?>
<project>
</project>
'''
-
+
self.config_xml_2 = '''
<?xml version="1.0" encoding="UTF-8"?>
<project>
<foo/>
</project>
'''
-
+
def test_lists_no_jobs_when_there_are_none(self):
self.assertEqual(self.jenkins.list_jobs(), [])
-
+
def test_lists_single_job_when_one_exists(self):
self.dummy_server.jobs = { 'job-1': '' }
self.assertEqual(self.jenkins.list_jobs(), ['job-1'])
@@ -142,6 +142,6 @@ class JenkinsTests(unittest.TestCase):
def test_updates_job(self):
self.jenkins.create_job('job-1', self.config_xml)
self.jenkins.update_job('job-1', self.config_xml_2)
- self.assertEqual(self.jenkins.get_job_config('job-1'),
+ self.assertEqual(self.jenkins.get_job_config('job-1'),
self.config_xml_2)
diff --git a/simplejenkinsapi/jobconfig.py b/simplejenkinsapi/jobconfig.py
index f49c0b2..0e7a38d 100644
--- a/simplejenkinsapi/jobconfig.py
+++ b/simplejenkinsapi/jobconfig.py
@@ -1,17 +1,17 @@
# jobconfig.py -- create Jenkins job config.xml files
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -44,10 +44,10 @@ empty = '''\
class JobConfig(object):
'''Create a Jenkins job configuration XML file.
-
+
This does not try to be complete, and only tries to do the minimal
things I need for my automated job creation needs.
-
+
'''
def __init__(self):
@@ -60,7 +60,7 @@ class JobConfig(object):
def add_param_dict(self, prefix, param_dict):
self._param_dicts.append((prefix, param_dict))
-
+
def _get_params(self):
unified = {}
for prefix, param_dict in self._param_dicts:
@@ -70,9 +70,9 @@ class JobConfig(object):
def job_id(self):
'''Create a unique job id from constituent parts.
-
+
Escape characters that Jenkins gets upset by, such as '@'.
-
+
'''
def esc(s):
diff --git a/simplejenkinsapi/order.py b/simplejenkinsapi/order.py
index 02fdf14..bf4212d 100644
--- a/simplejenkinsapi/order.py
+++ b/simplejenkinsapi/order.py
@@ -1,17 +1,17 @@
# order.py -- order projects in dependency order
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -22,11 +22,11 @@ def _traverse(project, result):
if project not in result:
result.append(project)
return result
-
+
def _roots(projects):
'''Return list of projects that are not build dependencies of anyone.'''
-
+
roots = projects[:]
for project in projects:
roots = [r for r in roots if r not in project['_']]
diff --git a/simplejenkinsapi/order_tests.py b/simplejenkinsapi/order_tests.py
index 7fef992..1eed6da 100644
--- a/simplejenkinsapi/order_tests.py
+++ b/simplejenkinsapi/order_tests.py
@@ -1,17 +1,17 @@
# simplejenkinsapi/order_tests.py -- unit tests for build ordering
#
# Copyright 2012 Lars Wirzenius
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -23,8 +23,8 @@ from simplejenkinsapi import order
def _names(projects):
return [p['name'] for p in projects]
-
-
+
+
class OrderTests(unittest.TestCase):
def setUp(self):
@@ -66,6 +66,6 @@ class OrderTests(unittest.TestCase):
self.B['build-depends'] = ['D']
self.C['build-depends'] = ['D']
ps = [self.A, self.B, self.C, self.D]
- self.assertEqual(_names(order(ps)),
+ self.assertEqual(_names(order(ps)),
_names([self.D, self.B, self.C, self.A]))