Py3: Fixes eventlet ImportError: No module named urllib2
Python3: from eventlet.green.urllib import request Python2: from eventlet.green import urllib2 Change-Id: Ib38865e0b6a8f076b8a54de4fae221d49f315c91
This commit is contained in:
parent
1717f2cbcb
commit
eea574a78a
@ -81,7 +81,11 @@ presented below::
|
||||
from swift.proxy.controllers.base import get_container_info
|
||||
|
||||
from eventlet import Timeout
|
||||
from eventlet.green import urllib2
|
||||
import six
|
||||
if six.PY3:
|
||||
from eventlet.green.urllib import request as urllib2
|
||||
else:
|
||||
from eventlet.green import urllib2
|
||||
|
||||
# x-container-sysmeta-webhook
|
||||
SYSMETA_WEBHOOK = get_sys_meta_prefix('container') + 'webhook'
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from eventlet.green import urllib2, socket
|
||||
from eventlet.green import socket
|
||||
from six.moves.urllib.parse import urlparse
|
||||
from swift.common.utils import SWIFT_CONF_FILE
|
||||
from swift.common.ring import Ring
|
||||
@ -28,8 +28,14 @@ import json
|
||||
import optparse
|
||||
import time
|
||||
import sys
|
||||
import six
|
||||
import os
|
||||
|
||||
if six.PY3:
|
||||
from eventlet.green.urllib import request as urllib2
|
||||
else:
|
||||
from eventlet.green import urllib2
|
||||
|
||||
|
||||
def seconds2timeunit(seconds):
|
||||
elapsed = seconds
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from eventlet import sleep, Timeout
|
||||
from eventlet.green import httplib, socket, urllib2
|
||||
from eventlet.green import httplib, socket
|
||||
import json
|
||||
import six
|
||||
from six.moves import range
|
||||
@ -32,6 +32,11 @@ from swift.common.swob import Request
|
||||
from swift.common.utils import quote
|
||||
from swift.common.wsgi import loadapp, pipeline_property
|
||||
|
||||
if six.PY3:
|
||||
from eventlet.green.urllib import request as urllib2
|
||||
else:
|
||||
from eventlet.green import urllib2
|
||||
|
||||
|
||||
class UnexpectedResponse(Exception):
|
||||
"""
|
||||
|
@ -22,8 +22,9 @@ import time
|
||||
import unittest
|
||||
import shutil
|
||||
import sys
|
||||
import six
|
||||
|
||||
from eventlet.green import urllib2, socket
|
||||
from eventlet.green import socket
|
||||
from six import StringIO
|
||||
from six.moves import urllib
|
||||
|
||||
@ -34,6 +35,11 @@ from swift.common.ring import utils as ring_utils
|
||||
from swift.common.storage_policy import StoragePolicy, POLICIES
|
||||
from test.unit import patch_policies
|
||||
|
||||
if six.PY3:
|
||||
from eventlet.green.urllib import request as urllib2
|
||||
else:
|
||||
from eventlet.green import urllib2
|
||||
|
||||
|
||||
class TestHelpers(unittest.TestCase):
|
||||
def test_seconds2timeunit(self):
|
||||
|
@ -25,7 +25,6 @@ from six import StringIO
|
||||
from six.moves import range
|
||||
from six.moves.urllib.parse import quote
|
||||
from test.unit import FakeLogger
|
||||
from eventlet.green import urllib2
|
||||
from swift.common import exceptions, internal_client, swob
|
||||
from swift.common.header_key_dict import HeaderKeyDict
|
||||
from swift.common.storage_policy import StoragePolicy
|
||||
@ -33,6 +32,11 @@ from swift.common.storage_policy import StoragePolicy
|
||||
from test.unit import with_tempdir, write_fake_ring, patch_policies
|
||||
from test.unit.common.middleware.helpers import FakeSwift
|
||||
|
||||
if six.PY3:
|
||||
from eventlet.green.urllib import request as urllib2
|
||||
else:
|
||||
from eventlet.green import urllib2
|
||||
|
||||
|
||||
class FakeConn(object):
|
||||
def __init__(self, body=None):
|
||||
|
Loading…
Reference in New Issue
Block a user