2to3 conversion, untested.
authorsalimfadhley <sal@stodge.org>
Wed, 4 Jul 2012 23:08:57 +0000 (00:08 +0100)
committersalimfadhley <sal@stodge.org>
Wed, 4 Jul 2012 23:08:57 +0000 (00:08 +0100)
14 files changed:
build.xml
doc/source/conf.py
jenkinsapi/api.py
jenkinsapi/artifact.py
jenkinsapi/command_line/jenkins_invoke.py
jenkinsapi/fingerprint.py
jenkinsapi/jenkins.py
jenkinsapi/jenkinsbase.py
jenkinsapi/job.py
jenkinsapi/result_set.py
jenkinsapi/utils/retry.py
jenkinsapi/utils/urlopener.py
jenkinsapi/view.py
setup.py

index 3a2c96e..dfd3fd0 100644 (file)
--- a/build.xml
+++ b/build.xml
                </exec>
        </target>
        
-       <target name="bdist_egg_26">
-                       <exec executable="python2.6">
-                               <arg value="setup.py" />
-                               <arg value="bdist_egg" />
-                               <arg value="upload" />
-                       </exec>
-       </target>
-       
        <target name="bdist_egg_27">
                                <exec executable="python2.7">
                                        <arg value="setup.py" />
                                        <arg value="upload" />
                        </exec>
        </target>
-       
-       <target name="bdist_wininst_27">
-                                       <exec executable="python2.6">
-                                               <arg value="setup.py" />
-                                               <arg value="bdist_wininst" />
-                                               <arg value="upload" />
-                               </exec>
-       </target>
-       
 
 </project>
\ No newline at end of file
index 8012299..fb2bf59 100644 (file)
@@ -20,7 +20,7 @@ if __name__ == "__main__":
 log = logging.getLogger(__name__)
 
 # CHANGE THIS
-VERSION = REVISION = '0.1.8'
+VERSION = REVISION = '0.1.11'
 PROJECT_NAME = 'JenkinsAPI'
 PROJECT_AUTHORS = "Salim Fadhley, Ramon van Alteren, Ruslan Lutsenko"
 PROJECT_EMAILS = 'salimfadhley@gmail.com, ramon@vanalteren.nl, ruslan.lutcenko@gmail.com'
@@ -30,7 +30,13 @@ SHORT_DESCRIPTION = 'A Python API for accessing resources on a Jenkins continuou
 
 REQUIRE_STRING = "%s==%s" % (PROJECT_NAME.lower(), VERSION)
 
-pkg_resources.require(REQUIRE_STRING)
+try:
+    pkg_resources.require(REQUIRE_STRING)
+except pkg_resources.VersionConflict:
+    import setuptools.command.easy_install
+    setuptools.command.easy_install.main(["-Zma", REQUIRE_STRING])
+    pkg_resources.require(REQUIRE_STRING)
+
 distrib = pkg_resources.get_distribution(REQUIRE_STRING)
 #Sanity check
 import jenkinsapi
@@ -58,8 +64,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u' JenkinsAPI'
-copyright = u'2012, %s' % PROJECT_AUTHORS
+project = ' JenkinsAPI'
+copyright = '2012, %s' % PROJECT_AUTHORS
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -201,8 +207,8 @@ latex_elements = {
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'JenkinsAPI.tex', u' JenkinsAPI Documentation',
-   u'xxx', 'manual'),
+  ('index', 'JenkinsAPI.tex', ' JenkinsAPI Documentation',
+   'xxx', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -231,8 +237,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'jenkinsapi', u' JenkinsAPI Documentation',
-     [u'xxx'], 1)
+    ('index', 'jenkinsapi', ' JenkinsAPI Documentation',
+     ['xxx'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -245,8 +251,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index', 'JenkinsAPI', u' JenkinsAPI Documentation',
-   u'xxx', 'JenkinsAPI', 'One line description of project.',
+  ('index', 'JenkinsAPI', ' JenkinsAPI Documentation',
+   'xxx', 'JenkinsAPI', 'One line description of project.',
    'Miscellaneous'),
 ]
 
index a906288..152864d 100644 (file)
@@ -45,7 +45,7 @@ def get_artifacts( jenkinsurl, jobid=None, build_no=None, proxyhost=None, proxyp
     else:
         build = job.get_last_good_build()
     artifacts = dict((artifact.filename, artifact) for artifact in build.get_artifacts())
-    log.info("Found %i artifacts in '%s'" % ( len(artifacts.keys() ), build_no ))
+    log.info("Found %i artifacts in '%s'" % ( len(list(artifacts.keys()) ), build_no ))
     return artifacts
 
 def search_artifacts(jenkinsurl, jobid, artifact_ids=None ):
@@ -90,7 +90,7 @@ def block_until_complete(jenkinsurl, jobs, maxwait=12000, interval=30, raise_on_
 
     obj_jenkins = Jenkins(jenkinsurl)
     obj_jobs = [obj_jenkins[jid] for jid in jobs]
-    for time_left in xrange(maxwait, 0, -interval):
+    for time_left in range(maxwait, 0, -interval):
         still_running = [j for j in obj_jobs if j.is_queued_or_running()]
         if not still_running:
             return
@@ -118,7 +118,7 @@ def install_artifacts(artifacts, dirstruct, installdir, basestaticurl):
         """
         assert basestaticurl.endswith("/"), "Basestaticurl should end with /"
         installed = []
-        for reldir, artifactnames in dirstruct.items():
+        for reldir, artifactnames in list(dirstruct.items()):
             destdir = os.path.join(installdir, reldir)
             if not os.path.exists(destdir):
                 log.warn("Making install directory %s" % destdir)
@@ -127,7 +127,7 @@ def install_artifacts(artifacts, dirstruct, installdir, basestaticurl):
                 assert os.path.isdir(destdir)
             for artifactname in artifactnames:
                 destpath = os.path.abspath(os.path.join( destdir, artifactname))
-                if artifactname in artifacts.keys():
+                if artifactname in list(artifacts.keys()):
                     # The artifact must be loaded from jenkins
                     theartifact = artifacts[artifactname]
                 else:
@@ -158,7 +158,7 @@ def search_artifact_by_regexp( jenkinsurl, jobid, artifactRegExp ):
         
         artifacts = build.getArtifactDict()
         
-        for name, art in artifacts.iteritems():
+        for name, art in artifacts.items():
             md_match = artifactRegExp.search( name )
             
             if md_match:
index e26c2ee..0dbd393 100644 (file)
@@ -7,8 +7,8 @@ artifacts associated with it.
 This module provides a class called Artifact which allows you to download objects from the server
 and also access them as a stream.
 """
-from __future__ import with_statement
-import urllib
+
+import urllib.request, urllib.parse, urllib.error
 import os
 import logging
 import hashlib
@@ -63,7 +63,7 @@ class Artifact(object):
         """
         Download the the artifact to a path.
         """
-        filename, _ = urllib.urlretrieve(self.url, filename=fspath)
+        filename, _ = urllib.request.urlretrieve(self.url, filename=fspath)
         return filename
 
     def _verify_download(self, fspath):
index d725d28..26c822d 100644 (file)
@@ -31,7 +31,7 @@ class jenkins_invoke(object):
         options, args = parser.parse_args()
         try:
             assert len(args) > 0, "Need to specify at least one job name"
-        except AssertionError, e:
+        except AssertionError as e:
             log.critical(e[0])
             parser.print_help()
             sys.exit(1)
index 54abfab..9284336 100644 (file)
@@ -1,7 +1,7 @@
 from jenkinsapi.jenkinsbase import JenkinsBase
 from jenkinsapi.exceptions import ArtifactBroken
 
-import urllib2
+import urllib.request, urllib.error, urllib.parse
 import re
 
 import logging
@@ -34,7 +34,7 @@ class Fingerprint(JenkinsBase):
         """
         try:
             self.poll()
-        except urllib2.HTTPError:
+        except urllib.error.HTTPError:
             return False
         return True
 
@@ -62,7 +62,7 @@ class Fingerprint(JenkinsBase):
             assert self.valid()
         except AssertionError:
             raise ArtifactBroken( "Artifact %s seems to be broken, check %s" % ( self.id, self.baseurl ) )
-        except urllib2.HTTPError:
+        except urllib.error.HTTPError:
             raise ArtifactBroken( "Unable to validate artifact id %s using %s" % ( self.id, self.baseurl ) )
         return True
 
index 040b8d2..799946a 100644 (file)
@@ -4,13 +4,13 @@ from jenkinsapi.job import Job
 from jenkinsapi.view import View
 from jenkinsapi.node import Node
 from jenkinsapi.exceptions import UnknownJob, NotAuthorized
-from utils.urlopener import mkurlopener, mkopener, NoAuto302Handler
+from .utils.urlopener import mkurlopener, mkopener, NoAuto302Handler
 import logging
 import time
-import urllib2
-import urllib
-import urlparse
-import cookielib
+import urllib.request, urllib.error, urllib.parse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
+import http.cookiejar
 try:
     import json
 except ImportError:
@@ -63,21 +63,21 @@ class Jenkins(JenkinsBase):
     def get_login_opener(self):
         hdrs = []
         if getattr(self, '_cookies', False):
-            mcj = cookielib.MozillaCookieJar()
+            mcj = http.cookiejar.MozillaCookieJar()
             for c in self._cookies:
                 mcj.set_cookie(c)
-            hdrs.append(urllib2.HTTPCookieProcessor(mcj))
+            hdrs.append(urllib.request.HTTPCookieProcessor(mcj))
         return mkopener(*hdrs)
 
     def login(self):
         formdata = dict(j_username=self.username, j_password=self.password,
                         remember_me=True, form='/')
         formdata.update(dict(json=json.dumps(formdata), Submit='log in'))
-        formdata = urllib.urlencode(formdata)
+        formdata = urllib.parse.urlencode(formdata)
 
-        loginurl = urlparse.urljoin(self.baseurl, 'j_acegi_security_check')
-        mcj = cookielib.MozillaCookieJar()
-        cookiehandler = urllib2.HTTPCookieProcessor(mcj)
+        loginurl = urllib.parse.urljoin(self.baseurl, 'j_acegi_security_check')
+        mcj = http.cookiejar.MozillaCookieJar()
+        cookiehandler = urllib.request.HTTPCookieProcessor(mcj)
 
         urlopen = mkopener(NoAuto302Handler, cookiehandler)
         res = urlopen(loginurl, data=formdata)
@@ -93,7 +93,7 @@ class Jenkins(JenkinsBase):
         '''Try and reload the configuration from disk'''
         try:
             self.hit_url("%(baseurl)s/reload" % self.__dict__)
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             if e.code == 403:
                 raise NotAuthorized("You are not authorized to reload this server")
             raise
@@ -157,10 +157,10 @@ class Jenkins(JenkinsBase):
         :param newjobname: name of new job, str
         :return: new Job obj
         """
-        qs = urllib.urlencode({'name': newjobname,
+        qs = urllib.parse.urlencode({'name': newjobname,
                                'mode': 'copy',
                                'from': jobname})
-        copy_job_url = urlparse.urljoin(self.baseurl, "createItem?%s" % qs)
+        copy_job_url = urllib.parse.urljoin(self.baseurl, "createItem?%s" % qs)
         self.post_data(copy_job_url, '')
         newjk = Jenkins(self.baseurl, username=self.username,
                         password=self.password, proxyhost=self.proxyhost,
@@ -174,7 +174,7 @@ class Jenkins(JenkinsBase):
         :param jobname: name of a exist job, str
         :return: new jenkins_obj
         """
-        delete_job_url = urlparse.urljoin(Jenkins(self.baseurl).get_job(jobname).baseurl, "doDelete" )
+        delete_job_url = urllib.parse.urljoin(Jenkins(self.baseurl).get_job(jobname).baseurl, "doDelete" )
         self.post_data(delete_job_url, '')
         newjk = Jenkins(self.baseurl, username=self.username,
                         password=self.password, proxyhost=self.proxyhost,
@@ -190,13 +190,13 @@ class Jenkins(JenkinsBase):
             yield info["name"]
 
     def keys(self):
-        return [ a for a in self.iterkeys() ]
+        return [ a for a in self.keys() ]
 
     def __str__(self):
         return "Jenkins server at %s" % self.baseurl
 
     def _get_views(self):
-        if not self._data.has_key("views"):
+        if "views" not in self._data:
             pass
         else:
             for viewdict in self._data["views"]:
@@ -211,7 +211,7 @@ class Jenkins(JenkinsBase):
             return view_dict[ str_view_name ]
         except KeyError:
             #noinspection PyUnboundLocalVariable
-            all_views = ", ".join(view_dict.keys())
+            all_views = ", ".join(list(view_dict.keys()))
             raise KeyError("View %s is not known - available: %s" % (str_view_name, all_views))
 
     def get_view(self, str_view_name):
@@ -239,13 +239,13 @@ class Jenkins(JenkinsBase):
         :param str_view_name: name of new view, str
         :return: new view obj
         """
-        url = urlparse.urljoin(self.baseurl, "user/%s/my-views/" % people) if people else self.baseurl
-        qs = urllib.urlencode({'value': str_view_name})
-        viewExistsCheck_url = urlparse.urljoin(url, "viewExistsCheck?%s" % qs)
+        url = urllib.parse.urljoin(self.baseurl, "user/%s/my-views/" % people) if people else self.baseurl
+        qs = urllib.parse.urlencode({'value': str_view_name})
+        viewExistsCheck_url = urllib.parse.urljoin(url, "viewExistsCheck?%s" % qs)
         fn_urlopen = self.get_jenkins_obj().get_opener()
         try:
             r = fn_urlopen(viewExistsCheck_url).read()
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.debug("Error reading %s" % viewExistsCheck_url)
             log.exception(e)
             raise
@@ -256,14 +256,14 @@ class Jenkins(JenkinsBase):
             data = {"mode":"hudson.model.ListView", "Submit": "OK"}
             data['name']=str_view_name
             data['json'] = data.copy()
-            params = urllib.urlencode(data)
+            params = urllib.parse.urlencode(data)
             try:
-                createView_url = urlparse.urljoin(url, "createView")
+                createView_url = urllib.parse.urljoin(url, "createView")
                 result = self.post_data(createView_url, params)
-            except urllib2.HTTPError, e:
+            except urllib.error.HTTPError as e:
                 log.debug("Error post_data %s" % createView_url)
                 log.exception(e)
-            return urlparse.urljoin(url, "view/%s/" % str_view_name)
+            return urllib.parse.urljoin(url, "view/%s/" % str_view_name)
 
     def __getitem__(self, jobname):
         """
@@ -291,7 +291,7 @@ class Jenkins(JenkinsBase):
 
     def get_node_url(self, nodename=""):
         """Return the url for nodes"""
-        url = "%(baseurl)s/computer/%(nodename)s" % {'baseurl': self.baseurl, 'nodename': urllib.quote(nodename)}
+        url = "%(baseurl)s/computer/%(nodename)s" % {'baseurl': self.baseurl, 'nodename': urllib.parse.quote(nodename)}
         return url
 
     def has_node(self, nodename):
@@ -316,7 +316,7 @@ class Jenkins(JenkinsBase):
         fn_urlopen = self.get_jenkins_obj().get_opener()
         try:
             fn_urlopen(url).read()
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.debug("Error reading %s" % url)
             log.exception(e)
             raise
@@ -359,13 +359,13 @@ class Jenkins(JenkinsBase):
         }
         url = "%(nodeurl)s/doCreateItem?%(params)s" % {
             'nodeurl': self.get_node_url(),
-            'params': urllib.urlencode(params)
+            'params': urllib.parse.urlencode(params)
         }
-        print url
+        print(url)
         fn_urlopen = self.get_jenkins_obj().get_opener()
         try:
             fn_urlopen(url).read()
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.debug("Error reading %s" % url)
             log.exception(e)
             raise
index 97b81e3..1ed110b 100644 (file)
@@ -1,4 +1,4 @@
-import urllib2
+import urllib.request, urllib.error, urllib.parse
 import logging
 import pprint
 from jenkinsapi import config
@@ -32,7 +32,7 @@ class JenkinsBase(object):
         if poll and not self.formauth:
             try:
                 self.poll()
-            except urllib2.HTTPError, hte:
+            except urllib.error.HTTPError as hte:
                 log.exception(hte)
                 log.warn( "Failed to conenct to %s" % baseurl )
                 raise
@@ -67,7 +67,7 @@ class JenkinsBase(object):
         try:
             stream = fn_urlopen(url)
             result = eval(stream.read())
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.warn("Error reading %s" % url)
             log.exception(e)
             raise
@@ -77,7 +77,7 @@ class JenkinsBase(object):
         try:
             urlopen = self.get_jenkins_obj().get_opener()
             return urlopen(url, data=content).read().strip()
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.warn("Error post data %s" % url)
             log.exception(e)
             raise
@@ -88,7 +88,7 @@ class JenkinsBase(object):
         try:
             stream = fn_urlopen( url )
             html_result = stream.read()
-        except urllib2.HTTPError, e:
+        except urllib.error.HTTPError as e:
             log.debug( "Error reading %s" % url )
             log.exception(e)
             raise
index 2dfe279..b827847 100644 (file)
@@ -1,14 +1,14 @@
 import logging
-import urlparse
-import urllib2
-import urllib
+import urllib.parse
+import urllib.request, urllib.error, urllib.parse
+import urllib.request, urllib.parse, urllib.error
 from bs4 import BeautifulSoup
 from collections import defaultdict
 from time import sleep
 from jenkinsapi.build import Build
 from jenkinsapi.jenkinsbase import JenkinsBase
 
-from exceptions import NoBuildData, NotFound
+from .exceptions import NoBuildData, NotFound
 
 log = logging.getLogger(__name__)
 
@@ -40,11 +40,11 @@ class Job(JenkinsBase):
             if token:
                 assert isinstance(token, str ), "token if provided should be a string."
                 params['token'] = token
-            extra = "buildWithParameters?" + urllib.urlencode(params)
+            extra = "buildWithParameters?" + urllib.parse.urlencode(params)
         else:
             assert isinstance(token, str ), "token if provided should be a string."
-            extra = "build?" + urllib.urlencode({'token':token})
-        buildurl = urlparse.urljoin( self.baseurl, extra )
+            extra = "build?" + urllib.parse.urlencode({'token':token})
+        buildurl = urllib.parse.urljoin( self.baseurl, extra )
         return buildurl
 
     def invoke(self, securitytoken=None, block=False, skip_if_running=False, invoke_pre_check_delay=3, invoke_block_delay=15, params={}):
@@ -118,7 +118,7 @@ class Job(JenkinsBase):
         return self._buildid_for_type(buildtype="lastCompletedBuild")
 
     def get_build_dict(self):
-        if not self._data.has_key( "builds" ):
+        if "builds" not in self._data:
             raise NoBuildData( repr(self) )
         return dict( ( a["number"], a["url"] ) for a in self._data["builds"] )
 
index e3def36..5692960 100644 (file)
@@ -21,10 +21,10 @@ class ResultSet(JenkinsBase):
         return "Test Result for %s" % str( self.build )
 
     def keys(self):
-        return [ a[0] for a in self.iteritems() ]
+        return [ a[0] for a in self.items() ]
 
     def items(self):
-        return [a for a in self.iteritems()]
+        return [a for a in self.items()]
 
     def iteritems(self):
         for suite in self._data.get("suites", [] ):
@@ -39,4 +39,4 @@ class ResultSet(JenkinsBase):
                     yield R.id(), R
 
     def __len__(self):
-        return len(self.items())
+        return len(list(self.items()))
index 334d5c8..ac2548c 100644 (file)
@@ -25,7 +25,7 @@ def retry_function( tries, fn, *args, **kwargs ):
             if attempt > 0:
                 log.info( "Result obtained after attempt %i" % attemptno )
             return result
-        except Exception, e:
+        except Exception as e:
             if type(e) in IGNORE_EXCEPTIONS:
                 # Immediatly raise in some cases.
                 raise
index b6e7942..4aaad65 100644 (file)
@@ -1,11 +1,11 @@
-import urllib2
+import urllib.request, urllib.error, urllib.parse
 import base64
 
 import logging
 
 log = logging.getLogger( __name__ )
 
-class PreemptiveBasicAuthHandler(urllib2.BaseHandler):
+class PreemptiveBasicAuthHandler(urllib.request.BaseHandler):
     """
     A BasicAuthHandler class that will add Basic Auth headers to a request
     even when there is no basic auth challenge from the server
@@ -13,7 +13,7 @@ class PreemptiveBasicAuthHandler(urllib2.BaseHandler):
     """
     def __init__(self, password_mgr=None):
         if password_mgr is None:
-            password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
+            password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
         self.passwd = password_mgr
         self.add_password = self.passwd.add_password
 
@@ -45,11 +45,11 @@ def mkurlopener( jenkinsuser, jenkinspass, jenkinsurl, proxyhost, proxyport, pro
         handlers.append(handler)
     for handler in get_proxy_handler(proxyhost, proxyport, proxyuser, proxypass):
         handlers.append(handler)
-    opener = urllib2.build_opener(*handlers)
+    opener = urllib.request.build_opener(*handlers)
     return opener.open
 
 def mkopener(*handlers):
-    opener = urllib2.build_opener(*handlers)
+    opener = urllib.request.build_opener(*handlers)
     return opener.open
 
 def get_jenkins_auth_handler(jenkinsuser, jenkinspass, jenkinsurl):
@@ -91,13 +91,13 @@ def get_proxy_handler(proxyhost, proxyport, proxyuser, proxypass):
     proxy_spec = { 'http': 'http://%s:%i/' % (proxyhost, proxyport),
                    'https': 'http://%s:%i/' % (proxyhost, proxyport) }
 
-    proxy_handler = urllib2.ProxyHandler( proxy_spec )
-    proxy_auth_handler = urllib2.HTTPBasicAuthHandler()
+    proxy_handler = urllib.request.ProxyHandler( proxy_spec )
+    proxy_auth_handler = urllib.request.HTTPBasicAuthHandler()
     proxy_auth_handler.add_password( None, proxyhost, proxyuser, proxypass )
     return [proxy_handler, proxy_auth_handler]
 
 
-class NoAuto302Handler(urllib2.HTTPRedirectHandler):
+class NoAuto302Handler(urllib.request.HTTPRedirectHandler):
     def http_error_302(self, req, fp, code, msg, hdrs):
         return fp
 
index 86b7632..618c4d4 100644 (file)
@@ -1,6 +1,6 @@
 from jenkinsapi.jenkinsbase import JenkinsBase
 from jenkinsapi.job import Job
-import urllib
+import urllib.request, urllib.parse, urllib.error
 
 class View(JenkinsBase):
 
@@ -18,21 +18,21 @@ class View(JenkinsBase):
         return Job( api_url, str_job_id, self.jenkins_obj )
 
     def keys(self):
-        return self.get_job_dict().keys()
+        return list(self.get_job_dict().keys())
 
     def iteritems(self):
-        for name, url in self.get_job_dict().iteritems():
+        for name, url in self.get_job_dict().items():
             api_url = self.python_api_url( url )
             yield name, Job( api_url, name, self.jenkins_obj )
 
     def values(self):
-        return [ a[1] for a in self.iteritems() ]
+        return [ a[1] for a in self.items() ]
 
     def items(self):
-        return [ a for a in self.iteritems() ]
+        return [ a for a in self.items() ]
 
     def _get_jobs( self ):
-        if not self._data.has_key( "jobs" ):
+        if "jobs" not in self._data:
             pass
         else:
             for viewdict in self._data["jobs"]:
@@ -42,7 +42,7 @@ class View(JenkinsBase):
         return dict( self._get_jobs() )
 
     def __len__(self):
-        return len( self.get_job_dict().keys() )
+        return len( list(self.get_job_dict().keys()) )
 
     def get_job_url( self, str_job_name ):
         try:
@@ -50,7 +50,7 @@ class View(JenkinsBase):
             return job_dict[ str_job_name ]
         except KeyError:
             #noinspection PyUnboundLocalVariable
-            all_views = ", ".join( job_dict.keys() )
+            all_views = ", ".join( list(job_dict.keys()) )
             raise KeyError("Job %s is not known - available: %s" % ( str_job_name, all_views ) )
 
     def get_jenkins_obj(self):
@@ -77,11 +77,11 @@ class View(JenkinsBase):
                 "Submit":"OK",
                 }
             data["name"] = self.name
-            for job in self.get_job_dict().keys():
+            for job in list(self.get_job_dict().keys()):
                 data[job]='on'
             data[str_job_name] = "on"
             data['json'] = data.copy()
-            self.post_data('%sconfigSubmit' % self.baseurl, urllib.urlencode(data))
+            self.post_data('%sconfigSubmit' % self.baseurl, urllib.parse.urlencode(data))
             return "Job %s is add in View %s successful" % (str_job_name, self.baseurl)
 
     def id(self):
index 7822b03..631f7f3 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
 import os
 
 PROJECT_ROOT, _ = os.path.split(__file__)
-VERSION = REVISION = '0.1.9'
+VERSION = REVISION = '0.1.11'
 PROJECT_NAME = 'JenkinsAPI'
 PROJECT_AUTHORS = "Salim Fadhley, Ramon van Alteren, Ruslan Lutsenko"
 PROJECT_EMAILS = 'salimfadhley@gmail.com, ramon@vanalteren.nl, ruslan.lutcenko@gmail.com'
@@ -11,7 +11,7 @@ SHORT_DESCRIPTION = 'A Python API for accessing resources on a Jenkins continuou
 
 try:
     DESCRIPTION = open(os.path.join(PROJECT_ROOT, "README.rst")).read()
-except IOError, _:
+except IOError as _:
     DESCRIPTION = SHORT_DESCRIPTION
     
 GLOBAL_ENTRY_POINTS = {