Revert "2to3 conversion, untested."
authorsalimfadhley <sal@stodge.org>
Sat, 7 Jul 2012 22:52:49 +0000 (23:52 +0100)
committersalimfadhley <sal@stodge.org>
Sat, 7 Jul 2012 22:52:49 +0000 (23:52 +0100)
This reverts commit a564d931eef0087e38551f14cf672c874d66d009.

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 dfd3fd0..3a2c96e 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 fb2bf59..8012299 100644 (file)
@@ -20,7 +20,7 @@ if __name__ == "__main__":
 log = logging.getLogger(__name__)
 
 # CHANGE THIS
-VERSION = REVISION = '0.1.11'
+VERSION = REVISION = '0.1.8'
 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,13 +30,7 @@ SHORT_DESCRIPTION = 'A Python API for accessing resources on a Jenkins continuou
 
 REQUIRE_STRING = "%s==%s" % (PROJECT_NAME.lower(), VERSION)
 
-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)
-
+pkg_resources.require(REQUIRE_STRING)
 distrib = pkg_resources.get_distribution(REQUIRE_STRING)
 #Sanity check
 import jenkinsapi
@@ -64,8 +58,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = ' JenkinsAPI'
-copyright = '2012, %s' % PROJECT_AUTHORS
+project = u' JenkinsAPI'
+copyright = u'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
@@ -207,8 +201,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', ' JenkinsAPI Documentation',
-   'xxx', 'manual'),
+  ('index', 'JenkinsAPI.tex', u' JenkinsAPI Documentation',
+   u'xxx', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -237,8 +231,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'jenkinsapi', ' JenkinsAPI Documentation',
-     ['xxx'], 1)
+    ('index', 'jenkinsapi', u' JenkinsAPI Documentation',
+     [u'xxx'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -251,8 +245,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index', 'JenkinsAPI', ' JenkinsAPI Documentation',
-   'xxx', 'JenkinsAPI', 'One line description of project.',
+  ('index', 'JenkinsAPI', u' JenkinsAPI Documentation',
+   u'xxx', 'JenkinsAPI', 'One line description of project.',
    'Miscellaneous'),
 ]
 
index 152864d..a906288 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(list(artifacts.keys()) ), build_no ))
+    log.info("Found %i artifacts in '%s'" % ( len(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 range(maxwait, 0, -interval):
+    for time_left in xrange(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 list(dirstruct.items()):
+        for reldir, artifactnames in 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 list(artifacts.keys()):
+                if artifactname in 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.items():
+        for name, art in artifacts.iteritems():
             md_match = artifactRegExp.search( name )
             
             if md_match:
index 0dbd393..e26c2ee 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.
 """
-
-import urllib.request, urllib.parse, urllib.error
+from __future__ import with_statement
+import urllib
 import os
 import logging
 import hashlib
@@ -63,7 +63,7 @@ class Artifact(object):
         """
         Download the the artifact to a path.
         """
-        filename, _ = urllib.request.urlretrieve(self.url, filename=fspath)
+        filename, _ = urllib.urlretrieve(self.url, filename=fspath)
         return filename
 
     def _verify_download(self, fspath):
index 26c822d..d725d28 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 as e:
+        except AssertionError, e:
             log.critical(e[0])
             parser.print_help()
             sys.exit(1)
index 9284336..54abfab 100644 (file)
@@ -1,7 +1,7 @@
 from jenkinsapi.jenkinsbase import JenkinsBase
 from jenkinsapi.exceptions import ArtifactBroken
 
-import urllib.request, urllib.error, urllib.parse
+import urllib2
 import re
 
 import logging
@@ -34,7 +34,7 @@ class Fingerprint(JenkinsBase):
         """
         try:
             self.poll()
-        except urllib.error.HTTPError:
+        except urllib2.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 urllib.error.HTTPError:
+        except urllib2.HTTPError:
             raise ArtifactBroken( "Unable to validate artifact id %s using %s" % ( self.id, self.baseurl ) )
         return True
 
index 799946a..040b8d2 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 urllib.request, urllib.error, urllib.parse
-import urllib.request, urllib.parse, urllib.error
-import urllib.parse
-import http.cookiejar
+import urllib2
+import urllib
+import urlparse
+import cookielib
 try:
     import json
 except ImportError:
@@ -63,21 +63,21 @@ class Jenkins(JenkinsBase):
     def get_login_opener(self):
         hdrs = []
         if getattr(self, '_cookies', False):
-            mcj = http.cookiejar.MozillaCookieJar()
+            mcj = cookielib.MozillaCookieJar()
             for c in self._cookies:
                 mcj.set_cookie(c)
-            hdrs.append(urllib.request.HTTPCookieProcessor(mcj))
+            hdrs.append(urllib2.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.parse.urlencode(formdata)
+        formdata = urllib.urlencode(formdata)
 
-        loginurl = urllib.parse.urljoin(self.baseurl, 'j_acegi_security_check')
-        mcj = http.cookiejar.MozillaCookieJar()
-        cookiehandler = urllib.request.HTTPCookieProcessor(mcj)
+        loginurl = urlparse.urljoin(self.baseurl, 'j_acegi_security_check')
+        mcj = cookielib.MozillaCookieJar()
+        cookiehandler = urllib2.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 urllib.error.HTTPError as e:
+        except urllib2.HTTPError, 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.parse.urlencode({'name': newjobname,
+        qs = urllib.urlencode({'name': newjobname,
                                'mode': 'copy',
                                'from': jobname})
-        copy_job_url = urllib.parse.urljoin(self.baseurl, "createItem?%s" % qs)
+        copy_job_url = urlparse.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 = urllib.parse.urljoin(Jenkins(self.baseurl).get_job(jobname).baseurl, "doDelete" )
+        delete_job_url = urlparse.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.keys() ]
+        return [ a for a in self.iterkeys() ]
 
     def __str__(self):
         return "Jenkins server at %s" % self.baseurl
 
     def _get_views(self):
-        if "views" not in self._data:
+        if not self._data.has_key("views"):
             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(list(view_dict.keys()))
+            all_views = ", ".join(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 = 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)
+        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)
         fn_urlopen = self.get_jenkins_obj().get_opener()
         try:
             r = fn_urlopen(viewExistsCheck_url).read()
-        except urllib.error.HTTPError as e:
+        except urllib2.HTTPError, 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.parse.urlencode(data)
+            params = urllib.urlencode(data)
             try:
-                createView_url = urllib.parse.urljoin(url, "createView")
+                createView_url = urlparse.urljoin(url, "createView")
                 result = self.post_data(createView_url, params)
-            except urllib.error.HTTPError as e:
+            except urllib2.HTTPError, e:
                 log.debug("Error post_data %s" % createView_url)
                 log.exception(e)
-            return urllib.parse.urljoin(url, "view/%s/" % str_view_name)
+            return urlparse.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.parse.quote(nodename)}
+        url = "%(baseurl)s/computer/%(nodename)s" % {'baseurl': self.baseurl, 'nodename': urllib.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 urllib.error.HTTPError as e:
+        except urllib2.HTTPError, 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.parse.urlencode(params)
+            'params': urllib.urlencode(params)
         }
-        print(url)
+        print url
         fn_urlopen = self.get_jenkins_obj().get_opener()
         try:
             fn_urlopen(url).read()
-        except urllib.error.HTTPError as e:
+        except urllib2.HTTPError, e:
             log.debug("Error reading %s" % url)
             log.exception(e)
             raise
index 1ed110b..97b81e3 100644 (file)
@@ -1,4 +1,4 @@
-import urllib.request, urllib.error, urllib.parse
+import urllib2
 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 urllib.error.HTTPError as hte:
+            except urllib2.HTTPError, 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 urllib.error.HTTPError as e:
+        except urllib2.HTTPError, 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 urllib.error.HTTPError as e:
+        except urllib2.HTTPError, 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 urllib.error.HTTPError as e:
+        except urllib2.HTTPError, e:
             log.debug( "Error reading %s" % url )
             log.exception(e)
             raise
index b827847..2dfe279 100644 (file)
@@ -1,14 +1,14 @@
 import logging
-import urllib.parse
-import urllib.request, urllib.error, urllib.parse
-import urllib.request, urllib.parse, urllib.error
+import urlparse
+import urllib2
+import urllib
 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.parse.urlencode(params)
+            extra = "buildWithParameters?" + urllib.urlencode(params)
         else:
             assert isinstance(token, str ), "token if provided should be a string."
-            extra = "build?" + urllib.parse.urlencode({'token':token})
-        buildurl = urllib.parse.urljoin( self.baseurl, extra )
+            extra = "build?" + urllib.urlencode({'token':token})
+        buildurl = urlparse.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 "builds" not in self._data:
+        if not self._data.has_key( "builds" ):
             raise NoBuildData( repr(self) )
         return dict( ( a["number"], a["url"] ) for a in self._data["builds"] )
 
index 5692960..e3def36 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.items() ]
+        return [ a[0] for a in self.iteritems() ]
 
     def items(self):
-        return [a for a in self.items()]
+        return [a for a in self.iteritems()]
 
     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(list(self.items()))
+        return len(self.items())
index ac2548c..334d5c8 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 as e:
+        except Exception, e:
             if type(e) in IGNORE_EXCEPTIONS:
                 # Immediatly raise in some cases.
                 raise
index 4aaad65..b6e7942 100644 (file)
@@ -1,11 +1,11 @@
-import urllib.request, urllib.error, urllib.parse
+import urllib2
 import base64
 
 import logging
 
 log = logging.getLogger( __name__ )
 
-class PreemptiveBasicAuthHandler(urllib.request.BaseHandler):
+class PreemptiveBasicAuthHandler(urllib2.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(urllib.request.BaseHandler):
     """
     def __init__(self, password_mgr=None):
         if password_mgr is None:
-            password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
+            password_mgr = urllib2.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 = urllib.request.build_opener(*handlers)
+    opener = urllib2.build_opener(*handlers)
     return opener.open
 
 def mkopener(*handlers):
-    opener = urllib.request.build_opener(*handlers)
+    opener = urllib2.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 = urllib.request.ProxyHandler( proxy_spec )
-    proxy_auth_handler = urllib.request.HTTPBasicAuthHandler()
+    proxy_handler = urllib2.ProxyHandler( proxy_spec )
+    proxy_auth_handler = urllib2.HTTPBasicAuthHandler()
     proxy_auth_handler.add_password( None, proxyhost, proxyuser, proxypass )
     return [proxy_handler, proxy_auth_handler]
 
 
-class NoAuto302Handler(urllib.request.HTTPRedirectHandler):
+class NoAuto302Handler(urllib2.HTTPRedirectHandler):
     def http_error_302(self, req, fp, code, msg, hdrs):
         return fp
 
index 618c4d4..86b7632 100644 (file)
@@ -1,6 +1,6 @@
 from jenkinsapi.jenkinsbase import JenkinsBase
 from jenkinsapi.job import Job
-import urllib.request, urllib.parse, urllib.error
+import urllib
 
 class View(JenkinsBase):
 
@@ -18,21 +18,21 @@ class View(JenkinsBase):
         return Job( api_url, str_job_id, self.jenkins_obj )
 
     def keys(self):
-        return list(self.get_job_dict().keys())
+        return self.get_job_dict().keys()
 
     def iteritems(self):
-        for name, url in self.get_job_dict().items():
+        for name, url in self.get_job_dict().iteritems():
             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.items() ]
+        return [ a[1] for a in self.iteritems() ]
 
     def items(self):
-        return [ a for a in self.items() ]
+        return [ a for a in self.iteritems() ]
 
     def _get_jobs( self ):
-        if "jobs" not in self._data:
+        if not self._data.has_key( "jobs" ):
             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( list(self.get_job_dict().keys()) )
+        return len( 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( list(job_dict.keys()) )
+            all_views = ", ".join( 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 list(self.get_job_dict().keys()):
+            for job in self.get_job_dict().keys():
                 data[job]='on'
             data[str_job_name] = "on"
             data['json'] = data.copy()
-            self.post_data('%sconfigSubmit' % self.baseurl, urllib.parse.urlencode(data))
+            self.post_data('%sconfigSubmit' % self.baseurl, urllib.urlencode(data))
             return "Job %s is add in View %s successful" % (str_job_name, self.baseurl)
 
     def id(self):
index 631f7f3..7822b03 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.11'
+VERSION = REVISION = '0.1.9'
 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 as _:
+except IOError, _:
     DESCRIPTION = SHORT_DESCRIPTION
     
 GLOBAL_ENTRY_POINTS = {