Bug 1681096 - python3 - pylint --py3k - W1619: from __future__ import division r=marionette-reviewers,perftest-reviewers,gbrown

Differential Revision: https://phabricator.services.mozilla.com/D98938
This commit is contained in:
Bob Clary 2020-12-11 16:05:25 +00:00
Родитель c90491dbe9
Коммит 9e125ea710
42 изменённых файлов: 117 добавлений и 41 удалений

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

@ -3,7 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import os import os
import sys import sys
@ -54,10 +54,12 @@ PERF_SUITES = [
def median(values): def median(values):
sorted_ = sorted(values) sorted_ = sorted(values)
# pylint --py3k W1619
med = int(len(sorted_) / 2) med = int(len(sorted_) / 2)
if len(sorted_) % 2: if len(sorted_) % 2:
return sorted_[med] return sorted_[med]
# pylint --py3k W1619
return (sorted_[med - 1] + sorted_[med]) / 2 return (sorted_[med - 1] + sorted_[med]) / 2
@ -173,6 +175,7 @@ def create_suite(
# Add the geometric mean. For more details on the calculation see: # Add the geometric mean. For more details on the calculation see:
# https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms # https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms
# pylint --py3k W1619
suite["value"] = math.exp(total / len(checkpoints)) suite["value"] = math.exp(total / len(checkpoints))
return suite return suite

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

@ -22,7 +22,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
""" """
from __future__ import absolute_import from __future__ import absolute_import, division
import sys import sys
import time import time
@ -92,6 +92,7 @@ class Bar(object):
self.last_progress = progress self.last_progress = progress
if (time.time() - self.etadelta) > ETA_INTERVAL: if (time.time() - self.etadelta) > ETA_INTERVAL:
self.etadelta = time.time() self.etadelta = time.time()
# pylint --py3k W1619
self.ittimes = self.ittimes[-ETA_SMA_WINDOW:] + [ self.ittimes = self.ittimes[-ETA_SMA_WINDOW:] + [
-(self.start - time.time()) / (progress + 1) -(self.start - time.time()) / (progress + 1)
] ]
@ -101,6 +102,7 @@ class Bar(object):
* (self.expected_size - progress) * (self.expected_size - progress)
) )
self.etadisp = self.format_time(self.eta) self.etadisp = self.format_time(self.eta)
# pylint --py3k W1619
x = int(self.width * progress / self.expected_size) x = int(self.width * progress / self.expected_size)
if not self.hide: if not self.hide:
if (progress % self.every) == 0 or ( # True every "every" updates if (progress % self.every) == 0 or ( # True every "every" updates

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

@ -4,8 +4,7 @@
# #
# This module needs to stay Python 2 and 3 compatible # This module needs to stay Python 2 and 3 compatible
# #
from __future__ import absolute_import from __future__ import absolute_import, division, print_function
from __future__ import print_function
import platform import platform
import time import time
@ -245,6 +244,7 @@ def download_file(url, target=None):
f.flush() f.flush()
else: else:
iter = req.iter_content(chunk_size=1024) iter = req.iter_content(chunk_size=1024)
# pylint --py3k W1619
size = total_length / 1024 + 1 size = total_length / 1024 + 1
for chunk in progress.bar(iter, expected_size=size): for chunk in progress.bar(iter, expected_size=size):
if chunk: if chunk:

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

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import print_function from __future__ import division, print_function
import sys import sys
import subprocess import subprocess
import json import json
@ -13,6 +12,7 @@ for line in proc.stdout:
data = json.loads(line[len("PERFHERDER_DATA:") :].decode("utf8")) data = json.loads(line[len("PERFHERDER_DATA:") :].decode("utf8"))
for suite in data["suites"]: for suite in data["suites"]:
for subtest in suite["subtests"]: for subtest in suite["subtests"]:
# pylint --py3k W1619
print( print(
"%4d.%03d ± %6s ms %s.%s" "%4d.%03d ± %6s ms %s.%s"
% ( % (

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import json import json
import os import os
@ -137,6 +137,7 @@ class RunOnceBenchmark(Benchmark):
for bench, scores in self.scores.items(): for bench, scores in self.scores.items():
for score, values in scores.items(): for score, values in scores.items():
test_name = "{}-{}".format(self.name, score) test_name = "{}-{}".format(self.name, score)
# pylint --py3k W1619
mean = sum(values) / len(values) mean = sum(values) / len(values)
self.suite["subtests"].append({"name": test_name, "value": mean}) self.suite["subtests"].append({"name": test_name, "value": mean})
bench_total += int(sum(values)) bench_total += int(sum(values))
@ -193,6 +194,7 @@ class Ares6(Benchmark):
def collect_results(self): def collect_results(self):
for bench, scores in self.scores.items(): for bench, scores in self.scores.items():
for score, values in scores.items(): for score, values in scores.items():
# pylint --py3k W1619
mean = sum(values) / len(values) mean = sum(values) / len(values)
test_name = "{}-{}".format(bench, score) test_name = "{}-{}".format(bench, score)
self.suite["subtests"].append({"name": test_name, "value": mean}) self.suite["subtests"].append({"name": test_name, "value": mean})
@ -296,6 +298,7 @@ class WebToolingBenchmark(Benchmark):
for bench, scores in self.scores.items(): for bench, scores in self.scores.items():
for score_name, values in scores.items(): for score_name, values in scores.items():
test_name = "{}-{}".format(self.name, score_name) test_name = "{}-{}".format(self.name, score_name)
# pylint --py3k W1619
mean = sum(values) / len(values) mean = sum(values) / len(values)
self.suite["subtests"].append( self.suite["subtests"].append(
{ {
@ -348,6 +351,7 @@ class Octane(RunOnceBenchmark):
for bench, scores in self.scores.items(): for bench, scores in self.scores.items():
for score_name, values in scores.items(): for score_name, values in scores.items():
test_name = "{}-{}".format(self.name, score_name) test_name = "{}-{}".format(self.name, score_name)
# pylint --py3k W1619
mean = sum(values) / len(values) mean = sum(values) / len(values)
self.suite["subtests"].append({"name": test_name, "value": mean}) self.suite["subtests"].append({"name": test_name, "value": mean})
if score_name == "score": if score_name == "score":

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from .legacy_actions import MultiActions, Actions from .legacy_actions import MultiActions, Actions
@ -70,6 +70,7 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration=
time_increment = 10 time_increment = 10
if time_increment >= duration: if time_increment >= duration:
time_increment = duration time_increment = duration
# pylint --py3k W1619
move_x1 = time_increment * 1.0 / duration * (x3 - x1) move_x1 = time_increment * 1.0 / duration * (x3 - x1)
move_y1 = time_increment * 1.0 / duration * (y3 - y1) move_y1 = time_increment * 1.0 / duration * (y3 - y1)
move_x2 = time_increment * 1.0 / duration * (x4 - x2) move_x2 = time_increment * 1.0 / duration * (x4 - x2)
@ -81,6 +82,7 @@ def pinch(marionette_session, element, x1, y1, x2, y2, x3, y3, x4, y4, duration=
action2.press(element, x2, y2) action2.press(element, x2, y2)
while time < duration: while time < duration:
time += time_increment time += time_increment
# pylint --py3k W1619
action1.move_by_offset(move_x1, move_y1).wait(time_increment / 1000) action1.move_by_offset(move_x1, move_y1).wait(time_increment / 1000)
action2.move_by_offset(move_x2, move_y2).wait(time_increment / 1000) action2.move_by_offset(move_x2, move_y2).wait(time_increment / 1000)
action1.release() action1.release()

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from . import errors from . import errors
from .marionette import MouseButton from .marionette import MouseButton
@ -218,12 +218,14 @@ class Actions(object):
time_increment = 10 time_increment = 10
if time_increment >= duration: if time_increment >= duration:
time_increment = duration time_increment = duration
# pylint --py3k W1619
move_x = time_increment * 1.0 / duration * (x2 - x1) move_x = time_increment * 1.0 / duration * (x2 - x1)
move_y = time_increment * 1.0 / duration * (y2 - y1) move_y = time_increment * 1.0 / duration * (y2 - y1)
self.action_chain.append(["press", element, x1, y1]) self.action_chain.append(["press", element, x1, y1])
while elapsed < duration: while elapsed < duration:
elapsed += time_increment elapsed += time_increment
self.action_chain.append(["moveByOffset", move_x, move_y]) self.action_chain.append(["moveByOffset", move_x, move_y])
# pylint --py3k W1619
self.action_chain.append(["wait", time_increment / 1000]) self.action_chain.append(["wait", time_increment / 1000])
self.action_chain.append(["release"]) self.action_chain.append(["release"])
return self return self

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import base64 import base64
import datetime import datetime
@ -1195,6 +1195,7 @@ class Marionette(object):
timeout = self.session.get("moz:shutdownTimeout") timeout = self.session.get("moz:shutdownTimeout")
if timeout is not None: if timeout is not None:
# pylint --py3k W1619
self.shutdown_timeout = timeout / 1000 + 10 self.shutdown_timeout = timeout / 1000 + 10
return self.session return self.session

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from six.moves.urllib.parse import quote from six.moves.urllib.parse import quote
@ -45,6 +45,7 @@ class BaseMouseAction(MarionetteTestCase):
) )
def get_element_center_point(self, elem): def get_element_center_point(self, elem):
# pylint --py3k W1619
return { return {
"x": elem.rect["x"] + elem.rect["width"] / 2, "x": elem.rect["x"] + elem.rect["width"] / 2,
"y": elem.rect["y"] + elem.rect["height"] / 2, "y": elem.rect["y"] + elem.rect["height"] / 2,

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

@ -1,4 +1,4 @@
from __future__ import print_function from __future__ import division, print_function
import math import math
import mozinfo import mozinfo
@ -139,6 +139,7 @@ class Bisect(object):
self.contents["start"] = 0 self.contents["start"] = 0
self.contents["end"] = totalTests - 2 self.contents["end"] = totalTests - 2
# pylint --py3k W1619
mid = (self.contents["start"] + self.contents["end"]) / 2 mid = (self.contents["start"] + self.contents["end"]) / 2
if "result" in self.contents: if "result" in self.contents:
if self.contents["result"] == "PASS": if self.contents["result"] == "PASS":

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

@ -5,6 +5,8 @@
# The content of this file comes orginally from automationutils.py # The content of this file comes orginally from automationutils.py
# and *should* be revised. # and *should* be revised.
from __future__ import division
import re import re
from operator import itemgetter from operator import itemgetter
@ -153,6 +155,7 @@ class ShutdownLeaks(object):
# Note: to figure out how many hidden windows were created, we divide # Note: to figure out how many hidden windows were created, we divide
# this number by 2, because 1 hidden window creation implies in # this number by 2, because 1 hidden window creation implies in
# 1 outer window + 1 inner window. # 1 outer window + 1 inner window.
# pylint --py3k W1619
self.logger.info( self.logger.info(
"TEST-INFO | %s | This test created %d hidden window(s)" "TEST-INFO | %s | This test created %d hidden window(s)"
% (test["fileName"], test["hiddenWindowsCount"] / 2) % (test["fileName"], test["hiddenWindowsCount"] / 2)

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

@ -33,6 +33,8 @@ Specification:
http://tools.ietf.org/html/rfc6455 http://tools.ietf.org/html/rfc6455
""" """
from __future__ import division
from collections import deque from collections import deque
import logging import logging
import os import os
@ -272,6 +274,7 @@ def parse_frame(receive_bytes,
raw_payload_bytes = receive_bytes(payload_length) raw_payload_bytes = receive_bytes(payload_length)
if logger.isEnabledFor(common.LOGLEVEL_FINE): if logger.isEnabledFor(common.LOGLEVEL_FINE):
# pylint --py3k W1619
logger.log( logger.log(
common.LOGLEVEL_FINE, 'Done receiving payload data at %s MB/s', common.LOGLEVEL_FINE, 'Done receiving payload data at %s MB/s',
payload_length / (time.time() - receive_start) / 1000 / 1000) payload_length / (time.time() - receive_start) / 1000 / 1000)
@ -283,6 +286,7 @@ def parse_frame(receive_bytes,
unmasked_bytes = masker.mask(raw_payload_bytes) unmasked_bytes = masker.mask(raw_payload_bytes)
if logger.isEnabledFor(common.LOGLEVEL_FINE): if logger.isEnabledFor(common.LOGLEVEL_FINE):
# pylint --py3k W1619
logger.log(common.LOGLEVEL_FINE, logger.log(common.LOGLEVEL_FINE,
'Done unmasking payload data at %s MB/s', 'Done unmasking payload data at %s MB/s',
payload_length / (time.time() - unmask_start) / 1000 / 1000) payload_length / (time.time() - unmask_start) / 1000 / 1000)

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

@ -6,7 +6,7 @@
Runs the Mochitest test harness. Runs the Mochitest test harness.
""" """
from __future__ import print_function, with_statement from __future__ import division, print_function, with_statement
import os import os
import sys import sys
@ -357,6 +357,7 @@ class MessageLogger(object):
last_timestamp = None last_timestamp = None
for buf in dumped_messages: for buf in dumped_messages:
# pylint --py3k W1619
timestamp = datetime.fromtimestamp(buf["time"] / 1000).strftime("%H:%M:%S") timestamp = datetime.fromtimestamp(buf["time"] / 1000).strftime("%H:%M:%S")
if timestamp != last_timestamp: if timestamp != last_timestamp:
self.logger.info("Buffered messages logged at {}".format(timestamp)) self.logger.info("Buffered messages logged at {}".format(timestamp))

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

@ -8,7 +8,7 @@ dictionary of values, and returns a new iterable of test objects. It is
possible to define custom filters if the built-in ones are not enough. possible to define custom filters if the built-in ones are not enough.
""" """
from __future__ import absolute_import from __future__ import absolute_import, division
import itertools import itertools
import os import os
@ -362,6 +362,7 @@ class chunk_by_runtime(InstanceFilter):
# Compute the average to use as a default for manifests that don't exist. # Compute the average to use as a default for manifests that don't exist.
times = [r[0] for r in runtimes] times = [r[0] for r in runtimes]
# pylint --py3k W1619
avg = round(sum(times) / len(times), 2) if times else 0 avg = round(sum(times) / len(times), 2) if times else 0
missing = sorted([m for m in manifests if m not in self.runtimes]) missing = sorted([m for m in manifests if m not in self.runtimes])
log( log(
@ -392,6 +393,7 @@ class chunk_by_runtime(InstanceFilter):
manifests = set(self.get_manifest(t) for t in tests) manifests = set(self.get_manifest(t) for t in tests)
chunks = self.get_chunked_manifests(manifests) chunks = self.get_chunked_manifests(manifests)
runtime, this_manifests = chunks[self.this_chunk - 1] runtime, this_manifests = chunks[self.this_chunk - 1]
# pylint --py3k W1619
log( log(
"Cumulative test runtime is around {} minutes (average is {} minutes)".format( "Cumulative test runtime is around {} minutes (average is {} minutes)".format(
round(runtime / 60), round(runtime / 60),

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file, # License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/. # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import io import io
import os import os
@ -3401,6 +3401,7 @@ class ADBDevice(ADBCommand):
elif parameter == "scale": elif parameter == "scale":
scale = float(value) scale = float(value)
if parameter is not None and scale is not None: if parameter is not None and scale is not None:
# pylint --py3k W1619
percentage = 100.0 * level / scale percentage = 100.0 * level / scale
break break
return percentage return percentage

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

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import hashlib import hashlib
import os import os
@ -312,6 +312,7 @@ class ProfileSymbolicator:
left = 0 left = 0
right = len(libs) - 1 right = len(libs) - 1
while left <= right: while left <= right:
# pylint --py3k W1619
mid = (left + right) / 2 mid = (left + right) / 2
if address >= libs[mid]["end"]: if address >= libs[mid]["end"]:
left = mid + 1 left = mid + 1

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import functools import functools
from collections import deque from collections import deque
@ -307,6 +307,7 @@ class TbplFormatter(BaseFormatter):
def suite_end(self, data): def suite_end(self, data):
start_time = self.suite_start_time start_time = self.suite_start_time
# pylint --py3k W1619
time = int((data["time"] - start_time) / 1000) time = int((data["time"] - start_time) / 1000)
return "SUITE-END | took %is\n" % time return "SUITE-END | took %is\n" % time

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

@ -4,7 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from . import base from . import base
@ -78,6 +78,7 @@ class UnittestFormatter(base.BaseFormatter):
return "\n".join("ERROR %(test)s\n%(message)s" % data for data in self.errors) return "\n".join("ERROR %(test)s\n%(message)s" % data for data in self.errors)
def output_summary(self): def output_summary(self):
# pylint --py3k W1619
return "Ran %i tests in %.1fs" % ( return "Ran %i tests in %.1fs" % (
self.tests_run, self.tests_run,
(self.end_time - self.start_time) / 1000, (self.end_time - self.start_time) / 1000,

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

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, division, unicode_literals
import csv import csv
import os import os
@ -548,6 +548,7 @@ class IPGResultsHandler(object):
# exist in the file and that the columns have the correct # exist in the file and that the columns have the correct
# data type. # data type.
column_datatypes = {"System Time": str, "RDTSC": int, "default": float} column_datatypes = {"System Time": str, "RDTSC": int, "default": float}
# pylint --py3k W1619
expected_samples = int( expected_samples = int(
self._ipg_measure_duration / (float(self._sampling_rate) / 1000) self._ipg_measure_duration / (float(self._sampling_rate) / 1000)
) )
@ -694,6 +695,7 @@ class IPGResultsHandler(object):
) )
# Check that the combined results have the expected number of samples. # Check that the combined results have the expected number of samples.
# pylint W16919
expected_samples = int( expected_samples = int(
self._ipg_measure_duration / (float(self._sampling_rate) / 1000) self._ipg_measure_duration / (float(self._sampling_rate) / 1000)
) )
@ -817,6 +819,7 @@ class IPGResultsHandler(object):
watt_usage = {} watt_usage = {}
for measure in cut_results: for measure in cut_results:
if "watt" in measure.lower() and "limit" not in measure.lower(): if "watt" in measure.lower() and "limit" not in measure.lower():
# pylint --py3k W1619
watt_usage[replace_measure_name(measure) + "-avg"] = sum( watt_usage[replace_measure_name(measure) + "-avg"] = sum(
[float(val) for val in cut_results[measure]] [float(val) for val in cut_results[measure]]
) / len(cut_results[measure]) ) / len(cut_results[measure])
@ -839,6 +842,7 @@ class IPGResultsHandler(object):
elif "gt " in utilized_name: elif "gt " in utilized_name:
utilized_name = "gpu" utilized_name = "gpu"
# pylint --py3k W1619
average_utilization[utilized_name] = sum( average_utilization[utilized_name] = sum(
[float(val) for val in cut_results[utilization]] [float(val) for val in cut_results[utilization]]
) / len(cut_results[utilization]) ) / len(cut_results[utilization])
@ -857,6 +861,7 @@ class IPGResultsHandler(object):
fmeasure_name = "cpu" fmeasure_name = "cpu"
elif "gt " in fmeasure_name: elif "gt " in fmeasure_name:
fmeasure_name = "gpu" fmeasure_name = "gpu"
# pylint --py3k W1619
frequency_info[fmeasure_name]["favg"] = sum( frequency_info[fmeasure_name]["favg"] = sum(
[float(val) for val in cut_results[frequency_measure]] [float(val) for val in cut_results[frequency_measure]]

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

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, division, unicode_literals
def get_logger(logger_name): def get_logger(logger_name):
@ -32,6 +32,7 @@ def average_summary(values):
:param list values: list of values to average. :param list values: list of values to average.
:returns: float :returns: float
""" """
# pylint --py3k W1619
return sum([float(v[0]) for v in values]) / len(values) return sum([float(v[0]) for v in values]) / len(values)

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

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file, # License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/. # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import os import os
@ -35,6 +35,7 @@ def test_with_profile_should_cleanup():
def test_with_profile_should_cleanup_even_on_exception(): def test_with_profile_should_cleanup_even_on_exception():
with pytest.raises(ZeroDivisionError): with pytest.raises(ZeroDivisionError):
# pylint --py3k W1619
with Profile() as profile: with Profile() as profile:
assert os.path.exists(profile.profile) assert os.path.exists(profile.profile)
1 / 0 # will raise ZeroDivisionError 1 / 0 # will raise ZeroDivisionError

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
class EmulatorBattery(object): class EmulatorBattery(object):
@ -26,6 +26,7 @@ class EmulatorBattery(object):
value = float(value) value = float(value)
status[field] = value status[field] = value
# pylint --py3k W1619
state["level"] = status.get("capacity", 0.0) / 100 state["level"] = status.get("capacity", 0.0) / 100
if status.get("AC") == "online": if status.get("AC") == "online":
state["charging"] = True state["charging"] = True

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

@ -6,7 +6,7 @@
"""Utility functions for mozrunner""" """Utility functions for mozrunner"""
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import os import os
import sys import sys
@ -170,6 +170,7 @@ def test_environment(
# Returns total system memory in kilobytes. # Returns total system memory in kilobytes.
if mozinfo.isWin: if mozinfo.isWin:
# pylint --py3k W1619
totalMemory = ( totalMemory = (
int( int(
os.popen( os.popen(
@ -179,6 +180,7 @@ def test_environment(
/ 1024 / 1024
) )
elif mozinfo.isMac: elif mozinfo.isMac:
# pylint --py3k W1619
totalMemory = ( totalMemory = (
int(os.popen("sysctl hw.memsize").readlines()[0].split()[1]) / 1024 int(os.popen("sysctl hw.memsize").readlines()[0].split()[1]) / 1024
) )

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file, # License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/. # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from contextlib import contextmanager from contextlib import contextmanager
import multiprocessing import multiprocessing
@ -527,10 +527,12 @@ class SystemResourceMonitor(object):
return 0 return 0
if per_cpu: if per_cpu:
# pylint --py3k W1619
return [sum(x) / samples for x in cpu] return [sum(x) / samples for x in cpu]
cores = [sum(x) for x in cpu] cores = [sum(x) for x in cpu]
# pylint --py3k W1619
return sum(cores) / len(cpu) / samples return sum(cores) / len(cpu) / samples
def aggregate_cpu_times(self, start=None, end=None, phase=None, per_cpu=True): def aggregate_cpu_times(self, start=None, end=None, phase=None, per_cpu=True):
@ -672,6 +674,7 @@ class SystemResourceMonitor(object):
def populate_derived(e): def populate_derived(e):
if e["cpu_percent_cores"]: if e["cpu_percent_cores"]:
# pylint --py3k W1619
e["cpu_percent_mean"] = sum(e["cpu_percent_cores"]) / len( e["cpu_percent_mean"] = sum(e["cpu_percent_cores"]) / len(
e["cpu_percent_cores"] e["cpu_percent_cores"]
) )

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

@ -28,6 +28,7 @@
pass pass
""" """
from __future__ import division
import ctypes import ctypes
import logging import logging
import os import os
@ -67,6 +68,7 @@ def convert_to(size, from_unit, to_unit):
try: try:
df = sizes[to_unit] df = sizes[to_unit]
sf = sizes[from_unit] sf = sizes[from_unit]
# pylint --py3k W1619
return size * sf / df return size * sf / df
except KeyError: except KeyError:
raise DiskutilsError("conversion error: Invalid source or destination format") raise DiskutilsError("conversion error: Invalid source or destination format")

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

@ -7,6 +7,7 @@
"""Python usage, esp. virtualenv. """Python usage, esp. virtualenv.
""" """
from __future__ import division
import errno import errno
import json import json
import os import os
@ -835,6 +836,7 @@ class ResourceMonitoringMixin(PerfherderResourceOptionsMixin):
for attr in cpu_attrs: for attr in cpu_attrs:
value = getattr(cpu_times, attr) value = getattr(cpu_times, attr)
# cpu_total can be 0.0. Guard against division by 0. # cpu_total can be 0.0. Guard against division by 0.
# pylint --py3k W1619
percent = value / cpu_total * 100.0 if cpu_total else 0.0 percent = value / cpu_total * 100.0 if cpu_total else 0.0
if percent > 1.00: if percent > 1.00:

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

@ -2,6 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import division
from distutils.version import LooseVersion from distutils.version import LooseVersion
import json import json
import math import math
@ -39,6 +40,7 @@ def is_triangualar(x):
>>> all(not is_triangualar(x) for x in [4, 5, 8, 9, 11, 17, 25, 29, 39, 44, 59, 61, 72, 98, 112]) >>> all(not is_triangualar(x) for x in [4, 5, 8, 9, 11, 17, 25, 29, 39, 44, 59, 61, 72, 98, 112])
True True
""" """
# pylint --py3k W1619
n = (math.sqrt(8 * x + 1) - 1) / 2 n = (math.sqrt(8 * x + 1) - 1) / 2
return n == int(n) return n == int(n)

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

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
@ -322,11 +322,13 @@ class Browsertime(Perftest):
# bt_timeout will be the overall browsertime cmd/session timeout (seconds) # bt_timeout will be the overall browsertime cmd/session timeout (seconds)
# browsertime deals with page cycles internally, so we need to give it a timeout # browsertime deals with page cycles internally, so we need to give it a timeout
# value that includes all page cycles # value that includes all page cycles
# pylint --py3k W1619
bt_timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) bt_timeout = int(timeout / 1000) * int(test.get("page_cycles", 1))
# the post-startup-delay is a delay after the browser has started, to let it settle # the post-startup-delay is a delay after the browser has started, to let it settle
# it's handled within browsertime itself by loading a 'preUrl' (about:blank) and having a # it's handled within browsertime itself by loading a 'preUrl' (about:blank) and having a
# delay after that ('preURLDelay') as the post-startup-delay, so we must add that in sec # delay after that ('preURLDelay') as the post-startup-delay, so we must add that in sec
# pylint --py3k W1619
bt_timeout += int(self.post_startup_delay / 1000) bt_timeout += int(self.post_startup_delay / 1000)
# add some time for browser startup, time for the browsertime measurement code # add some time for browser startup, time for the browsertime measurement code

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

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import time import time
import threading import threading
@ -132,7 +132,9 @@ class AndroidCPUProfiler(object):
u"type": u"cpu", u"type": u"cpu",
u"test": test_name + "-avg", u"test": test_name + "-avg",
u"unit": u"%", u"unit": u"%",
u"values": {u"avg": sum(self.polls) / len(self.polls)}, u"values": {
u"avg": sum(self.polls) / len(self.polls)
}, # pylint --py3k W1619
} }
self.raptor.control_server.submit_supporting_data(avg_cpuinfo_data) self.raptor.control_server.submit_supporting_data(avg_cpuinfo_data)

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

@ -4,7 +4,7 @@
# originally taken from /testing/talos/talos/filter.py # originally taken from /testing/talos/talos/filter.py
from __future__ import absolute_import from __future__ import absolute_import, division
import math import math
@ -120,9 +120,12 @@ def median(series):
series = sorted(series) series = sorted(series)
if len(series) % 2: if len(series) % 2:
# odd # odd
return series[len(series) / 2] # pylint --py3k W1619
# must force to int to use as index.
return series[int(len(series) / 2)]
else: else:
# even # even
# pylint --py3k W1619
middle = int(len(series) / 2) # the higher of the middle 2, actually middle = int(len(series) / 2) # the higher of the middle 2, actually
return 0.5 * (series[middle - 1] + series[middle]) return 0.5 * (series[middle - 1] + series[middle])
@ -181,6 +184,7 @@ def geometric_mean(series):
total = 0 total = 0
for i in series: for i in series:
total += math.log(i + 1) total += math.log(i + 1)
# pylint --py3k W1619
return math.exp(total / len(series)) - 1 return math.exp(total / len(series)) - 1
@ -269,6 +273,7 @@ def v8_subtest(series, name):
"Splay": 81491.0, "Splay": 81491.0,
} }
# pylint --py3k W1619
return reference[name] / geometric_mean(series) return reference[name] / geometric_mean(series)

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

@ -5,7 +5,7 @@
# some parts of this originally taken from /testing/talos/talos/output.py # some parts of this originally taken from /testing/talos/talos/output.py
"""output raptor test results""" """output raptor test results"""
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import filters import filters
@ -334,6 +334,7 @@ class PerftestOutput(object):
) )
results = results[9::10] results = results[9::10]
# pylint --py3k W1619
score = 60 * 1000 / filters.geometric_mean(results) / correctionFactor score = 60 * 1000 / filters.geometric_mean(results) / correctionFactor
return score return score
@ -379,6 +380,7 @@ class PerftestOutput(object):
"StyleBench requires 380 entries, found: %s instead" % len(results) "StyleBench requires 380 entries, found: %s instead" % len(results)
) )
results = results[75::76] results = results[75::76]
# pylint --py3k W1619
return 60 * 1000 / filters.geometric_mean(results) / correctionFactor return 60 * 1000 / filters.geometric_mean(results) / correctionFactor
if testname.startswith(("raptor-kraken", "raptor-sunspider")): if testname.startswith(("raptor-kraken", "raptor-sunspider")):

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import os import os
import re import re
@ -358,6 +358,7 @@ def finish_android_power_test(raptor, test_name, os_baseline=False):
if not baseline_measure: if not baseline_measure:
LOG.error("Power test baseline_measure is Zero.") LOG.error("Power test baseline_measure is Zero.")
return 0 return 0
# pylint --py3k W1619
return ( return (
100 * ((power_measure + baseline_measure) / baseline_measure) 100 * ((power_measure + baseline_measure) / baseline_measure)
) - 100 ) - 100
@ -369,6 +370,7 @@ def finish_android_power_test(raptor, test_name, os_baseline=False):
"values": {}, "values": {},
} }
for power_measure in power_data["values"]: for power_measure in power_data["values"]:
# pylint --py3k W1619
pc_power_data["values"][power_measure] = calculate_pc( pc_power_data["values"][power_measure] = calculate_pc(
(power_data["values"][power_measure] / test_time), (power_data["values"][power_measure] / test_time),
raptor.os_baseline_data["values"][power_measure], raptor.os_baseline_data["values"][power_measure],

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

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import json import json
import os import os
@ -73,9 +73,11 @@ class WebExtension(Perftest):
# we don't want this timeout occurring unless abosultely necessary # we don't want this timeout occurring unless abosultely necessary
# convert timeout to seconds and account for page cycles # convert timeout to seconds and account for page cycles
# pylint --py3k W1619
timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) timeout = int(timeout / 1000) * int(test.get("page_cycles", 1))
# account for the pause the raptor webext runner takes after browser startup # account for the pause the raptor webext runner takes after browser startup
# and the time an exception is propagated through the framework # and the time an exception is propagated through the framework
# pylint --py3k W1619
timeout += int(self.post_startup_delay / 1000) + 10 timeout += int(self.post_startup_delay / 1000) + 10
# for page-load tests we don't start the page-timeout timer until the pageload.js content # for page-load tests we don't start the page-timeout timer until the pageload.js content

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

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, division, unicode_literals
import os import os
@ -165,6 +165,7 @@ def test_usage_with_fallback():
cpu_profiler.polls.append(0) cpu_profiler.polls.append(0)
# Verify the response contains our expected CPU % of 8 # Verify the response contains our expected CPU % of 8
# pylint --py3k W1619
avg_cpuinfo_data = { avg_cpuinfo_data = {
"type": "cpu", "type": "cpu",
"test": "usage_with_fallback-avg", "test": "usage_with_fallback-avg",

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import math import math
import six import six
@ -180,6 +180,7 @@ def geometric_mean(series):
total = 0 total = 0
for i in series: for i in series:
total += math.log(i + 1) total += math.log(i + 1)
# pylint --py3k W1619
return math.exp(total / len(series)) - 1 return math.exp(total / len(series)) - 1
@ -254,6 +255,7 @@ def v8_subtest(series, name):
"Splay": 81491.0, "Splay": 81491.0,
} }
# pylint --py3k W1619
return reference[name] / geometric_mean(series) return reference[name] / geometric_mean(series)

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

@ -5,7 +5,7 @@
""" """
Downloads Heavy profiles from TaskCluster. Downloads Heavy profiles from TaskCluster.
""" """
from __future__ import absolute_import from __future__ import absolute_import, division
import os import os
import tarfile import tarfile
import functools import functools
@ -121,6 +121,7 @@ def download_profile(name, profiles_dir=None):
template = "Download progress %d%%" template = "Download progress %d%%"
with open(archive_file, "wb") as f: with open(archive_file, "wb") as f:
iter = req.iter_content(chunk_size=1024) iter = req.iter_content(chunk_size=1024)
# pylint --py3k W1619
size = total_length / 1024 + 1 size = total_length / 1024 + 1
with ProgressBar(size=size, template=template) as bar: with ProgressBar(size=size, template=template) as bar:
for chunk in iter: for chunk in iter:

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

@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""output formats for Talos""" """output formats for Talos"""
from __future__ import absolute_import from __future__ import absolute_import, division
from talos import filter from talos import filter
@ -310,6 +310,7 @@ class Output(object):
) )
results = results[75::76] results = results[75::76]
# pylint --py3k W1619
score = 60 * 1000 / filter.geometric_mean(results) / correctionFactor score = 60 * 1000 / filter.geometric_mean(results) / correctionFactor
return score return score

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import from __future__ import absolute_import, division
import argparse import argparse
import collections import collections
@ -77,6 +77,7 @@ def generate_report(tuple_list, filepath, mode="variance"):
for day in day_name: for day in day_name:
if mode == "variance": if mode == "variance":
# removing top and bottom 10% to reduce outlier influence # removing top and bottom 10% to reduce outlier influence
# pylint --py3k W1619
tenth = len(days[day]) / 10 tenth = len(days[day]) / 10
average = numpy.average(sorted(days[day])[tenth : tenth * 9 + 1]) average = numpy.average(sorted(days[day])[tenth : tenth * 9 + 1])
elif mode == "count": elif mode == "count":
@ -116,6 +117,7 @@ def is_normal(y):
clean_week = y clean_week = y
# look at weekends now # look at weekends now
# pylint --py3k W1619
avg = sum(clean_week) / len(clean_week) avg = sum(clean_week) / len(clean_week)
for i in six.moves.range(5, 7): for i in six.moves.range(5, 7):
# look for something outside of the 20% window # look for something outside of the 20% window

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import datetime import datetime
import errno import errno
@ -530,6 +530,7 @@ class TestInfoLongRunningTasks(TestInfo):
def get_long_running_ratio(record): def get_long_running_ratio(record):
count = record["count"] count = record["count"]
tasks_gt_pct = record["tasks_gt_pct"] tasks_gt_pct = record["tasks_gt_pct"]
# pylint --py3k W1619
return count / tasks_gt_pct return count / tasks_gt_pct
# Search test durations in ActiveData for long-running tests # Search test durations in ActiveData for long-running tests
@ -589,6 +590,7 @@ class TestInfoLongRunningTasks(TestInfo):
count = record["count"] count = record["count"]
max_run_time = record["max_run_time"] max_run_time = record["max_run_time"]
tasks_gt_pct = record["tasks_gt_pct"] tasks_gt_pct = record["tasks_gt_pct"]
# pylint --py3k W1619
print( print(
"%-55s: %d of %d runs (%.1f%%) exceeded %d%% of max-run-time (%d s)" "%-55s: %d of %d runs (%.1f%%) exceeded %d%% of max-run-time (%d s)"
% ( % (

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

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import json import json
import yaml import yaml
@ -211,6 +211,7 @@ class TPSTestRunner(object):
possible_time = line[0:13] possible_time = line[0:13]
if len(possible_time) == 13 and possible_time.isdigit(): if len(possible_time) == 13 and possible_time.isdigit():
time_ms = int(possible_time) time_ms = int(possible_time)
# pylint --py3k W1619
formatted = time.strftime( formatted = time.strftime(
"%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S",
time.localtime(time_ms / 1000), time.localtime(time_ms / 1000),

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

@ -4,7 +4,7 @@
# Integrates the xpcshell test runner with mach. # Integrates the xpcshell test runner with mach.
from __future__ import absolute_import, unicode_literals, print_function from __future__ import absolute_import, division, print_function, unicode_literals
import errno import errno
import logging import logging
@ -260,6 +260,7 @@ class MachCommands(MachCommandBase):
) )
if not params["threadCount"]: if not params["threadCount"]:
# pylint --py3k W1619
params["threadCount"] = int((cpu_count() * 3) / 2) params["threadCount"] = int((cpu_count() * 3) / 2)
if conditions.is_android(self) or self.substs.get("MOZ_BUILD_APP") == "b2g": if conditions.is_android(self) or self.substs.get("MOZ_BUILD_APP") == "b2g":

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

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function from __future__ import absolute_import, division, print_function
import copy import copy
import json import json
@ -1656,6 +1656,7 @@ class XPCShellTests(object):
): ):
# TSan requires significantly more memory, so reduce the amount of parallel # TSan requires significantly more memory, so reduce the amount of parallel
# tests we run to avoid OOMs and timeouts. # tests we run to avoid OOMs and timeouts.
# pylint --py3k W1619
self.threadCount = self.threadCount / 2 self.threadCount = self.threadCount / 2
self.stack_fixer_function = None self.stack_fixer_function = None