</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
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'
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
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
# 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
# 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.
# (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'),
]
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 ):
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
"""
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)
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:
artifacts = build.getArtifactDict()
- for name, art in artifacts.items():
+ for name, art in artifacts.iteritems():
md_match = artifactRegExp.search( name )
if md_match:
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
"""
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):
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)
from jenkinsapi.jenkinsbase import JenkinsBase
from jenkinsapi.exceptions import ArtifactBroken
-import urllib.request, urllib.error, urllib.parse
+import urllib2
import re
import logging
"""
try:
self.poll()
- except urllib.error.HTTPError:
+ except urllib2.HTTPError:
return False
return True
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
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:
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)
'''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
: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,
: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,
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"]:
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):
: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
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):
"""
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):
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
}
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
-import urllib.request, urllib.error, urllib.parse
+import urllib2
import logging
import pprint
from jenkinsapi import config
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
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
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
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
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__)
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={}):
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"] )
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", [] ):
yield R.id(), R
def __len__(self):
- return len(list(self.items()))
+ return len(self.items())
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
-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
"""
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
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):
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
from jenkinsapi.jenkinsbase import JenkinsBase
from jenkinsapi.job import Job
-import urllib.request, urllib.parse, urllib.error
+import urllib
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"]:
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:
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):
"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):
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'
try:
DESCRIPTION = open(os.path.join(PROJECT_ROOT, "README.rst")).read()
-except IOError as _:
+except IOError, _:
DESCRIPTION = SHORT_DESCRIPTION
GLOBAL_ENTRY_POINTS = {