Use print() (with 'from __future__ import print_function')
authorLars Hupfeldt <lhn@hupfeldtit.dk>
Thu, 13 Feb 2014 17:47:10 +0000 (18:47 +0100)
committerLars Hupfeldt <lhn@hupfeldtit.dk>
Thu, 13 Feb 2014 18:07:04 +0000 (19:07 +0100)
15 files changed:
examples/how_to/create_a_job.py
examples/how_to/create_nested_views.py
examples/how_to/get_config.py
examples/how_to/get_version_info_from_last_good_build.py
examples/how_to/query_a_build.py
examples/how_to/search_artifact_by_regexp.py
examples/how_to/search_artifacts.py
examples/low_level/copy_a_job.py
examples/low_level/create_a_view_low_level.py
examples/low_level/example_param_build.py
examples/low_level/login_with_auth.py
jenkinsapi/plugins.py
jenkinsapi_tests/test_utils/random_strings.py
jenkinsapi_tests/unittests/test_requester.py
jenkinsapi_utils/simple_post_logger.py

index 5c7eda6..343685e 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import logging
 logging.basicConfig()
 
@@ -7,12 +9,12 @@ J = Jenkins('http://localhost:8080')
 jobName = 'foo_job2'
 xml = resource_string('examples', 'addjob.xml')
 
-print xml
+print(xml)
 
 j = J.create_job(jobname=jobName, config=xml)
 
 j2 = J[jobName]
-print j
+print(j)
 
 # Delete job
 J.delete_job(jobName)
index 1ce245c..b82b28d 100644 (file)
@@ -1,5 +1,7 @@
 # This example requires NestedViews plugin to be installed in Jenkins
 # You need to have at least one job in your Jenkins to see views
+from __future__ import print_function
+
 import logging
 from pkg_resources import resource_string
 
@@ -27,7 +29,7 @@ if top_view is None:
 else:
     logger.info('View has been created')
 
-print 'top_view.views=', top_view.views.keys()
+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 is None:
index 088dafb..72b6635 100644 (file)
@@ -1,10 +1,12 @@
 """
 An example of how to use JenkinsAPI to fetch the config XML of a job.
 """
+from __future__ import print_function
+
 from jenkinsapi.jenkins import Jenkins
 J = Jenkins('http://localhost:8080')
 jobName = 'create_fwrgmkbbzk'
 
 config = J[jobName].get_config()
 
-print config
+print(config)
index 575f2bb..3df5f55 100644 (file)
@@ -1,6 +1,8 @@
 """
 Extract version information from the latest build.
 """
+from __future__ import print_function
+
 from jenkinsapi.jenkins import Jenkins
 
 
@@ -11,4 +13,4 @@ def getSCMInfroFromLatestGoodBuild(url, jobName, username=None, password=None):
     return lgb.get_revision()
 
 if __name__ == '__main__':
-    print getSCMInfroFromLatestGoodBuild('http://localhost:8080', 'fooJob')
+    print(getSCMInfroFromLatestGoodBuild('http://localhost:8080', 'fooJob'))
index 8272517..16dc569 100644 (file)
@@ -1,11 +1,14 @@
+from __future__ import print_function
+
 from jenkinsapi.view import View
 from jenkinsapi.jenkins import Jenkins
+
 J = Jenkins('http://localhost:8080')
-print J.items()
+print(J.items())
 j = J['foo']
 j = J.get_job("foo")
 b = j.get_last_build()
-print b
+print(b)
 mjn = b.get_master_job_name()
 print(mjn)
 
index 322b541..7f73562 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 from jenkinsapi.api import search_artifact_by_regexp
 import re
 
index cbf3c9b..31d19c6 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 from jenkinsapi.api import search_artifacts
 
 jenkinsurl = "http://localhost:8080/jenkins"
index 3ee4299..ae0399b 100644 (file)
@@ -1,6 +1,7 @@
 """
 A lower-level implementation of copying a job in Jenkins
 """
+from __future__ import print_function
 
 import requests
 from jenkinsapi.jenkins import Jenkins
@@ -19,4 +20,4 @@ j = J.create_job(jobname=jobName, config=xml)
 
 h = {'Content-Type': 'application/x-www-form-urlencoded'}
 response = requests.post(url, data='dysjsjsjs', headers=h)
-print response.text.encode('UTF-8')
+print(response.text.encode('UTF-8'))
index 606941a..21115ca 100644 (file)
@@ -2,6 +2,8 @@
 A low level example:
 This is how JenkinsAPI creates views
 """
+from __future__ import print_function
+
 import requests
 import json
 
@@ -18,4 +20,4 @@ data = {
 }
 # Try 1
 result = requests.post(url, params=params, data=data, headers=headers)
-print result.text.encode('UTF-8')
+print(result.text.encode('UTF-8'))
index 987d0f1..d6e8c33 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import json
 import requests
 
@@ -12,7 +14,7 @@ def foo():
     headers = {'Content-Type': 'application/x-www-form-urlencoded'}
     form = {'json': json.dumps(toJson)}
     response = requests.post(url, data=form, headers=headers)
-    print response.text.encode('UTF-8')
+    print(response.text.encode('UTF-8'))
 
 if __name__ == '__main__':
     foo()
index c28f670..c11aa9f 100644 (file)
@@ -1,6 +1,7 @@
 """
 A lower level example of how we login with authentication
 """
+from __future__ import print_function
 
 from jenkinsapi import jenkins
 
@@ -8,4 +9,4 @@ from jenkinsapi import jenkins
 J = jenkins.Jenkins("http://localhost:8080", username="sal", password="foobar")
 J.poll()
 
-print J.items()
+print(J.items())
index ea38b5d..cad4e59 100644 (file)
@@ -1,6 +1,7 @@
 """
 jenkinsapi plugins
 """
+from __future__ import print_function
 
 import logging
 
@@ -18,7 +19,7 @@ class Plugins(JenkinsBase):
     def __init__(self, url, jenkins_obj):
         self.jenkins_obj = jenkins_obj
         JenkinsBase.__init__(self, url)
-        # print 'DEBUG: Plugins._data=', self._data
+        # print('DEBUG: Plugins._data=', self._data)
 
     def get_jenkins_obj(self):
         return self.jenkins_obj
index ffcbf57..18f13fa 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import random
 import string
 
@@ -6,4 +8,4 @@ def random_string(length=10):
     return ''.join(random.choice(string.ascii_lowercase) for i in range(length))
 
 if __name__ == '__main__':
-    print random_string()
+    print(random_string())
index c556ae9..86502b4 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import mock
 import unittest
 
@@ -78,7 +80,7 @@ class TestQueue(unittest.TestCase):
         )
 
         self.assertTrue(isinstance(req_return, dict))
-        print req_return.get('data')
+        print(req_return.get('data'))
         self.assertTrue(req_return.get('data'))
         self.assertTrue(req_return['data'] == 'some data')
 
@@ -180,7 +182,7 @@ class TestQueue(unittest.TestCase):
                 data='some data'
             )
 
-        print ae.exception.message
+        print(ae.exception.message)
         self.assertTrue(ae.exception.message == "Operation failed. url=None, data=some data, headers={'Content-Type': 'application/x-www-form-urlencoded'}, status=500, text=")
 
     @mock.patch.object(requests, 'get')
@@ -208,7 +210,7 @@ class TestQueue(unittest.TestCase):
                 params={'param': 'value'}
             )
 
-        print ae.exception.message
+        print(ae.exception.message)
         self.assertTrue(ae.exception.message == "Operation failed. url=None, headers=None, status=500, text=")
 
 if __name__ == "__main__":
index 87bf4f0..f5be1ab 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import SimpleHTTPServer
 import SocketServer
 import logging
@@ -28,5 +30,5 @@ Handler = ServerHandler
 
 httpd = SocketServer.TCPServer(("", PORT), Handler)
 
-print "serving at port", PORT
+print("serving at port", PORT)
 httpd.serve_forever()