Bug 1922075 - Remove uses of 'six.moves' from testing/mozbase, r=mozbase-reviewers,jmaher

Differential Revision: https://phabricator.services.mozilla.com/D224255
This commit is contained in:
Andrew Halberstadt 2024-10-09 15:36:42 +00:00
parent 7587822fc6
commit 8a74d00933
19 changed files with 36 additions and 41 deletions

View File

@ -14,6 +14,7 @@ import tempfile
import traceback
import zipfile
from collections import namedtuple
from urllib.request import urlopen
import mozfile
import mozinfo
@ -290,7 +291,7 @@ class CrashInfo(object):
self.remove_symbols = True
self.logger.info("Downloading symbols from: %s" % self.symbols_path)
# Get the symbols and write them to a temporary zipfile
data = six.moves.urllib.request.urlopen(self.symbols_path)
data = urlopen(self.symbols_path)
with tempfile.TemporaryFile() as symbols_file:
symbols_file.write(data.read())
# extract symbols to a temporary directory (which we'll delete after

View File

@ -2,12 +2,12 @@
# coding=UTF-8
import zipfile
from urllib.parse import urlunsplit
import mozhttpd
import mozunit
from conftest import fspath
from six import BytesIO
from six.moves.urllib.parse import urlunsplit
def test_symbols_path_not_present(check_for_crashes, minidump_files):

View File

@ -13,8 +13,8 @@ import time
import warnings
from contextlib import contextmanager
from textwrap import dedent
from six.moves import urllib
from urllib.parse import urlparse
from urllib.request import urlopen
__all__ = [
"extract_tarball",
@ -612,7 +612,7 @@ def is_url(thing):
Return True if thing looks like a URL.
"""
parsed = urllib.parse.urlparse(thing)
parsed = urlparse(thing)
if "scheme" in parsed:
return len(parsed.scheme) >= 2
else:
@ -634,7 +634,7 @@ def load(resource):
# if no scheme is given, it is a file path
return open(resource)
return urllib.request.urlopen(resource)
return urlopen(resource)
# see https://docs.python.org/3/whatsnew/3.12.html#imp

View File

@ -15,13 +15,12 @@ import threading
import time
import traceback
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from http.server import HTTPServer, SimpleHTTPRequestHandler
from socketserver import ThreadingMixIn
from urllib.parse import unquote, urlsplit
import moznetwork
from six import ensure_binary, iteritems
from six.moves.BaseHTTPServer import HTTPServer
from six.moves.SimpleHTTPServer import SimpleHTTPRequestHandler
from six.moves.socketserver import ThreadingMixIn
from six.moves.urllib.parse import unquote, urlsplit
class EasyServer(ThreadingMixIn, HTTPServer):

View File

@ -7,13 +7,8 @@
import collections
import json
import os
import mozhttpd
import mozunit
import pytest
from six import ensure_binary, ensure_str
from six.moves.urllib.error import HTTPError
from six.moves.urllib.request import (
from urllib.error import HTTPError
from urllib.request import (
HTTPHandler,
ProxyHandler,
Request,
@ -22,6 +17,11 @@ from six.moves.urllib.request import (
urlopen,
)
import mozhttpd
import mozunit
import pytest
from six import ensure_binary, ensure_str
def httpd_url(httpd, path, querystr=None):
"""Return the URL to a started MozHttpd server for the given info."""

View File

@ -6,12 +6,12 @@
import os
import re
from urllib.request import urlopen
import mozhttpd
import mozunit
import pytest
from six import ensure_str
from six.moves.urllib.request import urlopen
@pytest.fixture(name="docroot")

View File

@ -3,11 +3,12 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from urllib.error import HTTPError
from urllib.request import urlopen
import mozhttpd
import mozunit
import pytest
from six.moves.urllib.error import HTTPError
from six.moves.urllib.request import urlopen
def try_get(url, expected_contents):

View File

@ -3,11 +3,11 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
import os
from urllib.request import urlopen
import mozhttpd
import mozunit
import pytest
from six.moves.urllib.request import urlopen
def log_requests(enabled):

View File

@ -5,8 +5,6 @@
import os
import signal
from six.moves import range
# a dict cache of signal number -> signal name
_SIG_NAME = None

View File

@ -5,7 +5,6 @@
import inspect
import six
from six.moves import range, zip
convertor_registry = {}
missing = object()

View File

@ -4,8 +4,7 @@
import json
import socket
from six.moves import socketserver
import socketserver
class LogMessageServer(socketserver.TCPServer):

View File

@ -2,11 +2,10 @@
import argparse
import collections
import configparser
import multiprocessing
import time
from six.moves import configparser
ProcessNode = collections.namedtuple("ProcessNode", ["maxtime", "children"])

View File

@ -9,9 +9,9 @@ add permissions to the profile
import codecs
import os
from urllib import parse
from six import string_types
from six.moves.urllib import parse
__all__ = [
"MissingPrimaryLocationError",

View File

@ -14,9 +14,10 @@ import six
from six import StringIO, string_types
try:
from six.moves.configparser import SafeConfigParser as ConfigParser
from configparser import SafeConfigParser as ConfigParser
except ImportError: # SafeConfigParser was removed in 3.12
from configparser import ConfigParser
try:
ConfigParser.read_file
except AttributeError: # read_file was added in 3.2, readfp removed in 3.12

View File

@ -15,13 +15,13 @@ import signal
import time
import typing
from collections import defaultdict
from urllib.parse import parse_qsl, unquote, urlparse
from mitmproxy import ctx, exceptions, http, io
# PATCHING AREA - ALLOWS HTTP/2 WITH NO CERT SNIFFING
from mitmproxy.proxy.protocol import tls
from mitmproxy.proxy.protocol.http2 import Http2Layer, SafeH2Connection
from six.moves import urllib
_PROTO = {}
@ -190,8 +190,8 @@ class AlternateServerPlayback:
# unquote url
# See Bug 1509835
_, _, path, _, query, _ = urllib.parse.urlparse(urllib.parse.unquote(r.url))
queriesArray = urllib.parse.parse_qsl(query, keep_blank_values=True)
_, _, path, _, query, _ = urlparse(unquote(r.url))
queriesArray = parse_qsl(query, keep_blank_values=True)
key = [str(r.port), str(r.scheme), str(r.method), str(path)]
key.append(str(r.raw_content))
@ -279,9 +279,7 @@ class AlternateServerPlayback:
# collecting stats only if we can dump them (see .done())
if ctx.options.upload_dir:
parsed_url = urllib.parse.urlparse(
urllib.parse.unquote(f.request.url)
)
parsed_url = urlparse(unquote(f.request.url))
self.netlocs[parsed_url.netloc][f.response.status_code] += 1
self.calls.append(
{

View File

@ -11,9 +11,9 @@ import socket
import sys
import time
from subprocess import PIPE, Popen
from urllib.request import urlretrieve
from redo import retriable, retry
from six.moves.urllib.request import urlretrieve
try:
import zstandard

View File

@ -15,10 +15,10 @@ import telnetlib
import time
from collections import namedtuple
from enum import Enum
from urllib.request import urlopen
import six
from mozdevice import ADBDeviceFactory, ADBHost
from six.moves import input, urllib
MOZBUILD_PATH = os.environ.get(
"MOZBUILD_STATE_PATH", os.path.expanduser(os.path.join("~", ".mozbuild"))
@ -1013,7 +1013,7 @@ def _log_info(text):
def _download_file(url, filename, path):
_log_debug("Download %s to %s/%s..." % (url, path, filename))
f = urllib.request.urlopen(url)
f = urlopen(url)
if not os.path.isdir(path):
try:
os.makedirs(path)

View File

@ -8,9 +8,9 @@ import posixpath
import shutil
import tempfile
import time
from configparser import ConfigParser, RawConfigParser
from mozdevice import ADBError, ADBHost
from six.moves.configparser import ConfigParser, RawConfigParser
class Device(object):

View File

@ -3,13 +3,13 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
import configparser
import io
import os
import sys
import zipfile
import mozlog
from six.moves import configparser
from mozversion import errors