Bug 1696540 - browsertime python-3 r=perftest-reviewers,Bebe

migrate browsertime to python-3

Differential Revision: https://phabricator.services.mozilla.com/D108841
This commit is contained in:
Joel Maher 2021-03-18 12:45:07 +00:00
parent 1cad7af959
commit a1318fa15b
8 changed files with 31 additions and 11 deletions

View File

@ -31,6 +31,7 @@ job-defaults:
- --browsertime
- --no-conditioned-profile
fission-run-on-projects: []
python-3: true
browsertime-tp6:
description: "Raptor (browsertime) tp6 page-load tests"

View File

@ -76,6 +76,7 @@ job-defaults:
chrome-m: []
fennec: []
default: ["webrender"]
python-3: true
browsertime-tp6m:
description: "Raptor (browsertime) tp6 page-load tests on android"

View File

@ -14,6 +14,13 @@ import tokenize
from six.moves.configparser import SafeConfigParser as ConfigParser
from six import StringIO, string_types
import six
if six.PY3:
def unicode(input):
return input
__all__ = ("PreferencesReadError", "Preferences")
@ -232,7 +239,7 @@ class Preferences(object):
# write the preferences
for _pref in _prefs:
print(pref_string % _pref, file=f)
print(unicode(pref_string % _pref), file=f)
# close the file if opened internally
if isinstance(_file, string_types):

View File

@ -13,10 +13,17 @@ import time
import uuid
from abc import ABCMeta, abstractmethod, abstractproperty
from shutil import copytree
from io import open
import mozfile
from six import string_types, python_2_unicode_compatible
if six.PY3:
def unicode(input):
return input
from .addons import AddonManager
from .permissions import Permissions
from .prefs import Preferences
@ -313,12 +320,12 @@ class Profile(BaseProfile):
self.written_prefs.add(filename)
# opening delimeter
f.write("\n%s\n" % self.delimeters[0])
f.write(unicode("\n%s\n" % self.delimeters[0]))
Preferences.write(f, preferences)
# closing delimeter
f.write("%s\n" % self.delimeters[1])
f.write(unicode("%s\n" % self.delimeters[1]))
def set_persistent_preferences(self, preferences):
"""
@ -347,7 +354,7 @@ class Profile(BaseProfile):
"""
path = os.path.join(self.profile, filename)
with open(path) as f:
with open(path, "r", encoding="utf-8") as f:
lines = f.read().splitlines()
def last_index(_list, value):
@ -554,7 +561,10 @@ class ChromiumProfile(BaseProfile):
with open(pref_file, "w") as fh:
prefstr = json.dumps(prefs)
prefstr % values # interpolate prefs with values
fh.write(prefstr)
if six.PY2:
fh.write(unicode(prefstr))
else:
fh.write(prefstr)
class ChromeProfile(ChromiumProfile):

View File

@ -192,7 +192,7 @@ class MitmproxyAndroid(Mitmproxy):
cmd_output = self.certutil(args)
if "mitmproxy-cert" in cmd_output:
if "mitmproxy-cert" in cmd_output.decode("utf-8"):
LOG.info(
"verfied the mitmproxy-cert is installed in the nss cert db on android"
)

View File

@ -412,7 +412,7 @@ class Browsertime(Perftest):
if self.browsertime_failure, and raise an Exception if necessary
to stop Raptor execution (preventing the results processing).
"""
match = line_matcher.match(line)
match = line_matcher.match(line.decode("utf-8"))
if not match:
LOG.info(line)
return

View File

@ -757,7 +757,7 @@ class PerftestDesktop(Perftest):
bmeta = proc.output
meta_re = re.compile(r"([A-z\s]+)\s+([\w.]*)")
if len(bmeta) != 0:
match = meta_re.match(bmeta[0])
match = meta_re.match(bmeta[0].decode("utf-8"))
if match:
browser_name = self.config["app"]
browser_version = match.group(2)
@ -771,7 +771,7 @@ class PerftestDesktop(Perftest):
bmeta = subprocess.check_output(command)
meta_re = re.compile(r"\s+([\d.a-z]+)\s+")
match = meta_re.findall(bmeta)
match = meta_re.findall(bmeta.decode("utf-8"))
if len(match) > 0:
browser_name = self.config["app"]
browser_version = match[-1]

View File

@ -10,6 +10,7 @@ import json
import os
import shutil
from abc import ABCMeta, abstractmethod
from io import open
import six
from logger.logger import RaptorLogger
@ -229,7 +230,7 @@ class PerftestResultsHandler(object):
)
LOG.info("Validating PERFHERDER_DATA against %s" % schema_path)
try:
with open(schema_path) as f:
with open(schema_path, encoding="utf-8") as f:
schema = json.load(f)
if output.summarized_results:
data = output.summarized_results
@ -673,7 +674,7 @@ class BrowsertimeResultsHandler(PerftestResultsHandler):
return False
try:
with open(bt_res_json, "r") as f:
with open(bt_res_json, "r", encoding="utf8") as f:
raw_btresults = json.load(f)
except Exception as e:
LOG.error("Exception reading %s" % bt_res_json)