Bug 1532427 - Fix tox errors in mozharness/mozharness/mozilla when running python 3.5 r=egao

Differential Revision: https://phabricator.services.mozilla.com/D55188

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gautham Velchuru 2019-12-02 19:59:07 +00:00
Родитель c233a3dd80
Коммит ee1252df2d
3 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -8,7 +8,7 @@
"""
import os
import urllib2
from six.moves import urllib
import json
@ -20,7 +20,7 @@ class SecretsMixin(object):
# within a taskcluster task. Outside of that environment, do not
# use this action.
url = "http://taskcluster/secrets/v1/secret/" + secret_name
res = urllib2.urlopen(url)
res = urllib.request.urlopen(url)
if res.getcode() != 200:
self.fatal("Error fetching from secrets API:" + res.read())

Просмотреть файл

@ -121,7 +121,7 @@ class StructuredOutputParser(OutputParser):
self.update_levels(tbpl_level, level)
def _subtract_tuples(self, old, new):
items = set(old.keys() + new.keys())
items = set(list(old.keys()) + list(new.keys()))
merged = defaultdict(int)
for item in items:
merged[item] = new.get(item, 0) - old.get(item, 0)
@ -210,7 +210,7 @@ class StructuredOutputParser(OutputParser):
'suite_end': 'No suite end message was emitted by this harness.',
'test_end': 'No checks run.',
}
for action, diagnostic_message in required_actions.iteritems():
for action, diagnostic_message in required_actions.items():
if action not in summary.action_counts:
self.log(diagnostic_message, ERROR)
self.update_levels(*error_pair)

Просмотреть файл

@ -8,9 +8,9 @@
import copy
import os
import platform
import urllib2
from six.moves import urllib
import json
from urlparse import urlparse, ParseResult
from six.moves.urllib.parse import urlparse, ParseResult
from mozharness.base.errors import BaseErrorList
from mozharness.base.log import FATAL, WARNING
@ -132,7 +132,7 @@ class TestingMixin(VirtualenvMixin, AutomationMixin, ResourceMonitoringMixin,
self.fatal("Can't figure out build directory urls without an installer_url "
"or test_packages_url!")
reference_url = urllib2.unquote(reference_url)
reference_url = urllib.parse.unquote(reference_url)
parts = list(urlparse(reference_url))
last_slash = parts[2].rfind('/')
@ -230,7 +230,7 @@ class TestingMixin(VirtualenvMixin, AutomationMixin, ResourceMonitoringMixin,
if c.get("test_packages_url"):
c["test_packages_url"] = _replace_url(c["test_packages_url"], c["replace_urls"])
for key, value in self.config.iteritems():
for key, value in self.config.items():
if type(value) == str and value.startswith("http"):
self.config[key] = _replace_url(value, c["replace_urls"])
@ -253,20 +253,20 @@ class TestingMixin(VirtualenvMixin, AutomationMixin, ResourceMonitoringMixin,
self.https_username, self.https_password = get_credentials()
# This creates a password manager
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman = urllib.request.HTTPPasswordMgrWithDefaultRealm()
# Because we have put None at the start it will use this username/password
# combination from here on
passman.add_password(None, url, self.https_username, self.https_password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
authhandler = urllib.request.HTTPBasicAuthHandler(passman)
return urllib2.build_opener(authhandler).open(url, **kwargs)
return urllib.request.build_opener(authhandler).open(url, **kwargs)
# If we have the developer_run flag enabled then we will switch
# URLs to the right place and enable http authentication
if "developer_config.py" in self.config["config_files"]:
return _urlopen_basic_auth(url, **kwargs)
else:
return urllib2.urlopen(url, **kwargs)
return urllib.request.urlopen(url, **kwargs)
def _query_binary_version(self, regex, cmd):
output = self.get_output_from_command(cmd, silent=False)