Skip to content

Commit

Permalink
[#8396] Revert "[#8386] remove chardet, make requests library still w…
Browse files Browse the repository at this point in the history
…ork"

This reverts commit f4ac641.
  • Loading branch information
brondsem authored and Kenton Taylor committed Sep 17, 2021
1 parent 96787ed commit 2314636
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ jobs:
- pip install https://sourceforge.net/projects/pysvn/files/pysvn/V1.9.12/pysvn-1.9.12.tar.gz
install:
- sudo apt-get install -qq libjpeg8-dev zlib1g-dev
- pip install nose
- pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed
- pip install -r requirements.txt
- npm install
script:
- ./rebuild-all.bash
Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/custom_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
from tg.support.middlewares import _call_wsgi_application as call_wsgi_application
from timermiddleware import Timer, TimerMiddleware
from webob import exc, Request
import pysolr
import six
from ming.odm import session

from allura.lib import helpers as h
import pysolr # after 'h' import to get requests/chardet patched
from allura.lib.utils import is_ajax
from allura import model as M
import allura.model.repository
Expand Down
16 changes: 0 additions & 16 deletions Allura/allura/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@
from io import BytesIO
import cgi


# https://forge-allura.apache.org/p/allura/tickets/8386/
# we don't want to depend on LGPL'd chardet, but the requests library needs it
# so if we can't import it, we'll make it exist as a copy of cchardet
# this spot in the codebase is best, since it is imported by many things and is before 'requests' is imported
# if https://github.com/psf/requests/pull/5797 is resolved, this hack could be removed
try:
import chardet
except ImportError:
import sys
import cchardet
sys.modules['chardet'] = sys.modules['cchardet']
import chardet
chardet.__version__ += '.cchardet'


import emoji
import tg
import six
Expand Down
1 change: 0 additions & 1 deletion Allura/allura/lib/phone/nexmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import cgi
import json

from allura.lib import helpers as h # to get requests/chardet patched
import requests
import jinja2

Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/project_create_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import colander as col
import bson
import requests
import formencode
import six
from six.moves.urllib.parse import urlparse
Expand All @@ -42,7 +43,6 @@

from allura import model as M
from allura.lib import helpers as h
import requests
from allura.lib.plugin import ProjectRegistrationProvider


Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from tg import redirect, url
from tg import tmpl_context as c, app_globals as g
from tg import request
from pysolr import SolrError

from allura.lib import helpers as h
from pysolr import SolrError # after 'h' import to get requests/chardet patched
from allura.lib.solr import escape_solr_arg
from allura.lib.utils import urlencode
import six
Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import logging
from collections import defaultdict
import hashlib
import requests

from tg import tmpl_context as c
from tg import request
Expand Down Expand Up @@ -562,7 +563,6 @@ def check_breached_password(cls, password):
Raises a named HIBPCompromisedCredentials exception if any found
:param password: user-supplied password
"""
import requests
result = 0
try:
# sha1 it
Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

from tg import config
from paste.deploy.converters import asbool
import pysolr
import six

from allura.lib.helpers import shlex_split
import pysolr # after helpers import to get requests/chardet patched

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import socket
import ssl

import requests
from bson import ObjectId
from tg import expose, validate, redirect, flash, config
from tg.decorators import with_trailing_slash, without_trailing_slash
Expand All @@ -39,7 +40,6 @@
from allura.app import AdminControllerMixin
from allura.controllers import BaseController
from allura.lib import helpers as h
import requests
from allura.lib import validators as v
from allura.lib.decorators import require_post, task
from allura.lib.utils import DateJSONEncoder
Expand Down
2 changes: 1 addition & 1 deletion Allura/docs/getting_started/install_each_step.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ We'll upgrade `pip <https://pip.pypa.io/en/stable/>`_ to make sure its a current
(env-allura)~/src$ cd allura
(env-allura)~/src/allura$ pip install -U pip
(env-allura)~/src/allura$ pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed
(env-allura)~/src/allura$ pip install -r requirements.txt
This may take a little while.

Expand Down
2 changes: 1 addition & 1 deletion Allura/docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Update requirements and reinstall apps:

.. code-block:: bash
docker-compose run web pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed
docker-compose run web pip install -r requirements.txt
docker-compose run web ./rebuild-all.bash
You may want to restart at least "taskd" container after that in order for it to
Expand Down
3 changes: 1 addition & 2 deletions AlluraTest/alluratest/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@
import webtest
from webtest import TestApp
from ming.utils import LazyProperty
import requests

from allura.lib import utils
from allura.lib import helpers as h # to get requests/chardet patched
import requests

log = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion ForgeImporters/forgeimporters/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from tg import config, session, redirect, request, expose
from tg.decorators import without_trailing_slash
from tg import tmpl_context as c
from allura.lib import helpers as h # to get requests/chardet patched
from requests_oauthlib import OAuth2Session
import requests
from formencode import validators as fev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# under the License.
from __future__ import unicode_literals
from __future__ import absolute_import
import requests
import tg
from mock import patch, call, Mock
from alluratest.tools import assert_equal
from unittest import TestCase

from allura.tests import TestController
from allura import model as M
import requests


class TestGitHubImportController(TestController, TestCase):
Expand Down
1 change: 0 additions & 1 deletion ForgeImporters/forgeimporters/trac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from __future__ import unicode_literals
from __future__ import absolute_import
from formencode import validators as fev
from allura.lib import helpers as h # to get requests/chardet patched
import requests

from allura.lib import validators
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ certifi==2019.6.16
# via requests
cffi==1.12.2
# via cryptography
chardet==3.0.4
# via requests
colander==1.7.0
# via -r requirements.in
crank==0.8.1
Expand Down
6 changes: 3 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ fi
echo 'Getting latest code with `git pull` ...'
git pull

echo 'Updating python packages with pip install ...'
pip install -r requirements.txt --no-deps --upgrade --upgrade-strategy=only-if-needed
echo 'Updating python packages with `pip install -r requirements.txt` ...'
pip install -r requirements.txt
if [ "$?" -gt 0 ]; then
echo
echo
echo 'Command `pip install ...` failed. Sometimes this is a random download error. If so, just try again.'
echo 'Command `pip install -r requirements.txt` failed. Sometimes this is a random download error. If so, just try again.'
exit;
fi

Expand Down

0 comments on commit 2314636

Please sign in to comment.