Skip to content

Commit

Permalink
Remove more six
Browse files Browse the repository at this point in the history
Fixes places where six was not actually removed from the code.

Signed-off-by: Joshua Watt <[email protected]>
  • Loading branch information
JPEWdev authored and twoerner committed Mar 27, 2024
1 parent db89941 commit ee69ec9
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/bmaptool/TransRead.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
import threading
import subprocess
import netrc
from six.moves.urllib import parse as urlparse
import http.client
import urllib.error
import urllib.parse
import urllib.request
from . import BmapHelpers

_log = logging.getLogger(__name__) # pylint: disable=C0103
Expand Down Expand Up @@ -578,13 +581,7 @@ def _print_warning(timeout):
"proxy configured correctly? Keep trying ..." % timeout
)

import socket

from six.moves import http_client as httplib
from six.moves.urllib import request as urllib
from six.moves.urllib.error import URLError

parsed_url = urlparse.urlparse(url)
parsed_url = urllib.parse.urlparse(url)

if parsed_url.scheme == "ssh":
# Unfortunately, urllib2 does not handle "ssh://" URLs
Expand Down Expand Up @@ -615,18 +612,18 @@ def _print_warning(timeout):
new_url[1] = "%s:%s" % (parsed_url.hostname, parsed_url.port)
else:
new_url[1] = parsed_url.hostname
url = urlparse.urlunparse(new_url)
url = urllib.parse.urlunparse(new_url)

# Build an URL opener which will do the authentication
password_manager = urllib.HTTPPasswordMgrWithDefaultRealm()
password_manager = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(None, url, username, password)
auth_handler = urllib.HTTPBasicAuthHandler(password_manager)
opener = urllib.build_opener(auth_handler)
auth_handler = urllib.request.HTTPBasicAuthHandler(password_manager)
opener = urllib.request.build_opener(auth_handler)
else:
opener = urllib.build_opener()
opener = urllib.request.build_opener()

opener.addheaders = [("User-Agent", "Mozilla/5.0")]
urllib.install_opener(opener)
urllib.request.install_opener(opener)

# Open the URL. First try with a short timeout, and print a message
# which should supposedly give the a clue that something may be going
Expand All @@ -639,14 +636,14 @@ def _print_warning(timeout):
for timeout in (10, None):
try:
f_obj = opener.open(url, timeout=timeout)
except URLError as err:
except urllib.error.URLError as err:
if timeout is not None:
_print_warning(timeout)
else:
raise Error("cannot open URL '%s': %s" % (url, err))
except (IOError, ValueError, httplib.InvalidURL) as err:
except (IOError, ValueError, http.client.InvalidURL) as err:
raise Error("cannot open URL '%s': %s" % (url, err))
except httplib.BadStatusLine:
except http.client.BadStatusLine:
raise Error(
"cannot open URL '%s': server responds with an "
"HTTP status code that we don't understand" % url
Expand Down

1 comment on commit ee69ec9

@a-detiste
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(love)

Please sign in to comment.