Fix Jenkins compatibility with Review Board 3.0.

Review Request #10980 — Created March 27, 2020 and submitted

Information

rbintegrations
master

Reviewers

The new Jenkins integration is mostly fine running on top of old Review
Board versions, but there was one utility class that was renamed. This
change fixes it to use the correct import for both 3.0 and 4.0.

Was able to load the master branch of the rbintegrations extension on
Review Board 3.0.x.

Summary ID
Fix Jenkins compatibility with Review Board 3.0.
The new Jenkins integration is mostly fine running on top of old Review Board versions, but there was one utility class that was renamed. This change fixes it to use the correct import for both 3.0 and 4.0. Testing Done: Was able to load the master branch of the rbintegrations extension on Review Board 3.0.x.
ee6ed03e7323ea36200607388c687795b2424536
Description From Last Updated

Hi David, This fix alone was not enough, because the classes are not equivalent. I can confirm that, as mentioned …

YX yxejamir
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to master (5e0f8ac)
YX
  1. 
      
  2. Show all issues

    Hi David,

    This fix alone was not enough, because the classes are not equivalent. I can confirm that, as mentioned in Testing Done, the extension is able to load on Review Board 3.0.18. However, as soon as I try to add an integration, it fails on an AttributeError in the following line, see below.

    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/api.py" in _make_raw_request
      208.         response = request.open()
    

    Full traceback:

    Environment:
    
    
    Request Method: POST
    Request URL: https://reviewboard.example.com/admin/integrations/rbintegrations.jenkinsci.integration.JenkinsCIIntegration/configs/add/
    
    Django Version: 1.6.11
    Python Version: 2.7.12
    Installed Applications:
    [u'corsheaders',
     u'django.contrib.admin',
     u'django.contrib.auth',
     u'django.contrib.contenttypes',
     u'django.contrib.sites',
     u'django.contrib.sessions',
     u'django.contrib.staticfiles',
     u'djblets',
     u'djblets.avatars',
     u'djblets.configforms',
     u'djblets.datagrid',
     u'djblets.extensions',
     u'djblets.features',
     u'djblets.feedview',
     u'djblets.forms',
     u'djblets.gravatars',
     u'djblets.integrations',
     u'djblets.log',
     u'djblets.pipeline',
     u'djblets.privacy',
     u'djblets.recaptcha',
     u'djblets.siteconfig',
     u'djblets.util',
     u'haystack',
     u'oauth2_provider',
     u'pipeline',
     u'reviewboard',
     u'reviewboard.accounts',
     u'reviewboard.admin',
     u'reviewboard.attachments',
     u'reviewboard.avatars',
     u'reviewboard.changedescs',
     u'reviewboard.diffviewer',
     u'reviewboard.extensions',
     u'reviewboard.hostingsvcs',
     u'reviewboard.integrations',
     u'reviewboard.notifications',
     u'reviewboard.oauth',
     u'reviewboard.reviews',
     u'reviewboard.scmtools',
     u'reviewboard.site',
     u'reviewboard.webapi',
     u'django_evolution',
     u'rbintegrations']
    Installed Middleware:
    [u'django.middleware.gzip.GZipMiddleware',
     u'reviewboard.admin.middleware.InitReviewBoardMiddleware',
     u'corsheaders.middleware.CorsMiddleware',
     u'django.middleware.clickjacking.XFrameOptionsMiddleware',
     u'django.middleware.common.CommonMiddleware',
     u'django.middleware.http.ConditionalGetMiddleware',
     u'django.middleware.locale.LocaleMiddleware',
     u'django.contrib.sessions.middleware.SessionMiddleware',
     u'django.contrib.auth.middleware.AuthenticationMiddleware',
     u'django.contrib.messages.middleware.MessageMiddleware',
     u'djblets.siteconfig.middleware.SettingsMiddleware',
     u'reviewboard.admin.middleware.LoadSettingsMiddleware',
     u'djblets.extensions.middleware.ExtensionsMiddleware',
     u'djblets.integrations.middleware.IntegrationsMiddleware',
     u'djblets.log.middleware.LoggingMiddleware',
     u'reviewboard.accounts.middleware.TimezoneMiddleware',
     u'reviewboard.accounts.middleware.UpdateLastLoginMiddleware',
     u'reviewboard.admin.middleware.CheckUpdatesRequiredMiddleware',
     u'reviewboard.accounts.middleware.X509AuthMiddleware',
     u'reviewboard.site.middleware.LocalSiteMiddleware',
     u'djblets.extensions.middleware.ExtensionsMiddlewareRunner',
     u'reviewboard.admin.middleware.ExtraExceptionInfoMiddleware']
    
    
    Traceback:
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
      112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
      69.             return self.dispatch(request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
      29.             return bound_func(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/decorators.py" in _checklogin
      17.             return view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
      25.                 return func(self, *args2, **kwargs2)
    File "/usr/local/lib/python2.7/dist-packages/djblets/integrations/views.py" in dispatch
      446.             *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
      29.             return bound_func(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view
      22.                 return view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
      25.                 return func(self, *args2, **kwargs2)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
      29.             return bound_func(*args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
      99.                     response = view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
      25.                 return func(self, *args2, **kwargs2)
    File "/usr/local/lib/python2.7/dist-packages/djblets/integrations/views.py" in dispatch
      286.             request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
      87.         return handler(request, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/django/views/generic/edit.py" in post
      170.         if form.is_valid():
    File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in is_valid
      129.         return self.is_bound and not bool(self.errors)
    File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in errors
      121.             self.full_clean()
    File "/usr/local/lib/python2.7/dist-packages/reviewboard/site/mixins.py" in full_clean
      275.             return super(LocalSiteAwareModelFormMixin, self).full_clean()
    File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in full_clean
      274.         self._clean_form()
    File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in _clean_form
      300.             self.cleaned_data = self.clean()
    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/forms.py" in clean
      103.             api.test_connection()
    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/api.py" in test_connection
      59.                            method='GET')
    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/api.py" in _make_request
      155.                 self._fetch_csrf_token()
    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/api.py" in _fetch_csrf_token
      117.                                       % self.endpoint)
    File "/usr/local/lib/python2.7/dist-packages/rbintegrations/jenkinsci/api.py" in _make_raw_request
      208.         response = request.open()
    File "/usr/lib/python2.7/urllib2.py" in __getattr__
      254.         raise AttributeError, attr
    
    Exception Type: AttributeError at /admin/integrations/rbintegrations.jenkinsci.integration.JenkinsCIIntegration/configs/add/
    Exception Value: open
    
  3.