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 - --browsertime
- --no-conditioned-profile - --no-conditioned-profile
fission-run-on-projects: [] fission-run-on-projects: []
python-3: true
browsertime-tp6: browsertime-tp6:
description: "Raptor (browsertime) tp6 page-load tests" description: "Raptor (browsertime) tp6 page-load tests"

View File

@ -76,6 +76,7 @@ job-defaults:
chrome-m: [] chrome-m: []
fennec: [] fennec: []
default: ["webrender"] default: ["webrender"]
python-3: true
browsertime-tp6m: browsertime-tp6m:
description: "Raptor (browsertime) tp6 page-load tests on android" 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.moves.configparser import SafeConfigParser as ConfigParser
from six import StringIO, string_types from six import StringIO, string_types
import six
if six.PY3:
def unicode(input):
return input
__all__ = ("PreferencesReadError", "Preferences") __all__ = ("PreferencesReadError", "Preferences")
@ -232,7 +239,7 @@ class Preferences(object):
# write the preferences # write the preferences
for _pref in _prefs: for _pref in _prefs:
print(pref_string % _pref, file=f) print(unicode(pref_string % _pref), file=f)
# close the file if opened internally # close the file if opened internally
if isinstance(_file, string_types): if isinstance(_file, string_types):

View File

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

View File

@ -192,7 +192,7 @@ class MitmproxyAndroid(Mitmproxy):
cmd_output = self.certutil(args) cmd_output = self.certutil(args)
if "mitmproxy-cert" in cmd_output: if "mitmproxy-cert" in cmd_output.decode("utf-8"):
LOG.info( LOG.info(
"verfied the mitmproxy-cert is installed in the nss cert db on android" "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 if self.browsertime_failure, and raise an Exception if necessary
to stop Raptor execution (preventing the results processing). to stop Raptor execution (preventing the results processing).
""" """
match = line_matcher.match(line) match = line_matcher.match(line.decode("utf-8"))
if not match: if not match:
LOG.info(line) LOG.info(line)
return return

View File

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

View File

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