← Back to team overview

python-jenkins-developers team mailing list archive

[Bug 1826802] [NEW] get_version() throws jenkins.BadHTTPException when login is required

 

Public bug reported:

Our site is set up so that all users need to login first, before they
can see anything.

Because of that, when I call get_version, it will fail with the
following:

    >>> server.get_version()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/bhj/.linuxbrew/Cellar/python@2/2.7.16/lib/python2.7/site-packages/jenkins/__init__.py", line 835, in get_version         
        % self.server)
    jenkins.BadHTTPException: Error communicating with server[server url] 

It can be fixed by the following patch:

    diff --git a/jenkins/__init__.py b/jenkins/__init__.py
    index 9717f58..b443756 100755
    --- a/jenkins/__init__.py
    +++ b/jenkins/__init__.py
    @@ -826,7 +826,7 @@ class Jenkins(object):
             try:
                 request = requests.Request('GET', self._build_url(''))
                 request.headers['X-Jenkins'] = '0.0'
    -            response = self._response_handler(self._request(request))                                                                 
    +            response = self.jenkins_request(request)
    
                 return response.headers['X-Jenkins']

** Affects: python-jenkins
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1826802

Title:
  get_version() throws jenkins.BadHTTPException when login is required

Status in Python Jenkins:
  New

Bug description:
  Our site is set up so that all users need to login first, before they
  can see anything.

  Because of that, when I call get_version, it will fail with the
  following:

      >>> server.get_version()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/home/bhj/.linuxbrew/Cellar/python@2/2.7.16/lib/python2.7/site-packages/jenkins/__init__.py", line 835, in get_version         
          % self.server)
      jenkins.BadHTTPException: Error communicating with server[server url] 

  It can be fixed by the following patch:

      diff --git a/jenkins/__init__.py b/jenkins/__init__.py
      index 9717f58..b443756 100755
      --- a/jenkins/__init__.py
      +++ b/jenkins/__init__.py
      @@ -826,7 +826,7 @@ class Jenkins(object):
               try:
                   request = requests.Request('GET', self._build_url(''))
                   request.headers['X-Jenkins'] = '0.0'
      -            response = self._response_handler(self._request(request))                                                                 
      +            response = self.jenkins_request(request)
      
                   return response.headers['X-Jenkins']

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1826802/+subscriptions