Bug 1396217 - resolve py2 and py3 lint errors r=jmaher

MozReview-Commit-ID: LG332HzJKcw

--HG--
extra : rebase_source : b82da0cceac18f310cadf945578464c2fb4704c4
This commit is contained in:
Ionut Goldan 2017-09-08 11:27:26 +03:00
Родитель cb97473493
Коммит f3028165fe
45 изменённых файлов: 186 добавлений и 131 удалений

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

@ -6,11 +6,13 @@ installation script for talos. This script:
- sets up talos in development mode: `python setup.py develop`
- downloads pageloader and packages to talos/page_load_test/pageloader.xpi
"""
from __future__ import absolute_import
import os
import subprocess
import sys
import urllib2
try:
from subprocess import check_call as call
except:

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

@ -1,5 +1,7 @@
from __future__ import absolute_import
import os
from setuptools import setup, find_packages
try:

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

@ -1,35 +1,11 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import mozinfo
import threading
class CounterManager(object):
counterDict = {}
def __init__(self):
self.allCounters = {}
self.registeredCounters = {}
def _loadCounters(self):
"""Loads all of the counters defined in the counterDict"""
for counter in self.counterDict.keys():
self.allCounters[counter] = self.counterDict[counter]
def registerCounters(self, counters):
"""Registers a list of counters that will be monitoring.
Only counters whose names are found in allCounters will be added
"""
for counter in counters:
if counter in self.allCounters:
self.registeredCounters[counter] = \
[self.allCounters[counter], []]
def getCounterValue(self, counterName):
"""Returns the last value of the counter 'counterName'"""
import mozinfo
if mozinfo.os == 'linux':

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

@ -0,0 +1,27 @@
from __future__ import absolute_import
class CounterManager(object):
counterDict = {}
def __init__(self):
self.allCounters = {}
self.registeredCounters = {}
def _loadCounters(self):
"""Loads all of the counters defined in the counterDict"""
for counter in self.counterDict.keys():
self.allCounters[counter] = self.counterDict[counter]
def registerCounters(self, counters):
"""Registers a list of counters that will be monitoring.
Only counters whose names are found in allCounters will be added
"""
for counter in counters:
if counter in self.allCounters:
self.registeredCounters[counter] = \
[self.allCounters[counter], []]
def getCounterValue(self, counterName):
"""Returns the last value of the counter 'counterName'"""

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

@ -1,10 +1,12 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import re
import subprocess
from cmanager import CounterManager
from cmanager_base import CounterManager
def xrestop(binary='xrestop'):

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

@ -3,11 +3,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""CounterManager for Mac OSX"""
from __future__ import absolute_import, print_function
import subprocess
from cmanager import CounterManager
import sys
from cmanager_base import CounterManager
def GetProcessData(pid):
"""Runs a ps on the process identified by pid and returns the output line

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

@ -1,15 +1,18 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
from cmanager import CounterManager
import struct
from ctypes import byref, create_string_buffer, memmove, Union, c_double, \
c_longlong
from ctypes import windll
from ctypes.wintypes import DWORD, HANDLE, LPSTR, LPCSTR, LPCWSTR, Structure, \
pointer, LONG
from ctypes import byref, create_string_buffer, memmove, Union, c_double, \
c_longlong
import struct
from cmanager_base import CounterManager
from utils import TalosError
pdh = windll.pdh
_LONGLONG = c_longlong

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

@ -1,6 +1,7 @@
# 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 file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import argparse
import os

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

@ -1,13 +1,13 @@
# 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 file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import sys
import os
import copy
import os
import sys
from mozlog.commandline import setup_logging
from talos import utils, test
from talos.cmdline import parse_args

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

@ -5,21 +5,20 @@
"""
Set up a browser environment before running a test.
"""
from __future__ import absolute_import, print_function
import os
import tempfile
import mozfile
import mozinfo
import mozrunner
from mozlog import get_proxy_logger
from mozprocess import ProcessHandlerMixin
from mozprofile.profile import Profile
from mozlog import get_proxy_logger
from talos import utils
from talos.utils import TalosError
from talos.gecko_profile import GeckoProfile
from talos.utils import TalosError
LOG = get_proxy_logger()
@ -165,9 +164,9 @@ class FFSetup(object):
def clean(self):
try:
mozfile.remove(self._tmp_dir)
except Exception, e:
print "Exception while removing profile directory: %s" % self._tmp_dir
print e
except Exception as e:
print("Exception while removing profile directory: %s" % self._tmp_dir)
print(e)
if self.gecko_profile:
self.gecko_profile.clean()

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

@ -1,3 +1,5 @@
from __future__ import absolute_import
import math
"""

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

@ -5,15 +5,15 @@
"""
module to handle Gecko profilling.
"""
from __future__ import absolute_import
import json
import os
import tempfile
import zipfile
import json
import mozfile
from mozlog import get_proxy_logger
from talos.profiler import symbolication, profiling
LOG = get_proxy_logger()

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

@ -3,6 +3,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import os
import re

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

@ -4,18 +4,19 @@
# Altered features:
# * --kill returns 404 rather than dropping the whole HTTP/2 connection on the floor
# * best-match response handling is used to improve success rates
from __future__ import absolute_import, print_function
import hashlib
import urllib
import sys
import urllib
from collections import defaultdict
from typing import Any # noqa
from typing import List # noqa
from mitmproxy import ctx
from mitmproxy import exceptions
from mitmproxy import io
from mitmproxy import http
from mitmproxy import io
from typing import Any # noqa
from typing import List # noqa
class ServerPlayback:

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

@ -2,14 +2,15 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import os
import psutil
import sys
import subprocess
import sys
import time
import mozinfo
import psutil
from mozlog import get_proxy_logger
here = os.path.dirname(os.path.realpath(__file__))

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

@ -4,16 +4,14 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""output formats for Talos"""
from __future__ import absolute_import
import filter
# NOTE: we have a circular dependency with output.py when we import results
import simplejson as json
import utils
from mozlog import get_proxy_logger
# NOTE: we have a circular dependency with output.py when we import results
import results as TalosResults
LOG = get_proxy_logger()
@ -24,11 +22,13 @@ class Output(object):
def check(cls, urls):
"""check to ensure that the urls are valid"""
def __init__(self, results):
def __init__(self, results, tsresult_class):
"""
- results : TalosResults instance
- tsresult_class : Results class
"""
self.results = results
self.tsresult_class = tsresult_class
def __call__(self):
suites = []
@ -62,7 +62,7 @@ class Output(object):
if page == 'NULL':
page = test.name()
if tsresult is None:
tsresult = r = TalosResults.Results()
tsresult = r = self.tsresult_class()
r.results = [{'index': 0, 'page': test.name(),
'runs': val}]
else:

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

@ -1,6 +1,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import json

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

@ -1,8 +1,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from symLogging import LogTrace, LogError, LogMessage
from __future__ import absolute_import
import itertools
import os
@ -11,6 +10,8 @@ import threading
import time
from bisect import bisect
from .symLogging import LogTrace, LogError, LogMessage
# Libraries to keep prefetched
PREFETCHED_LIBS = ["xul.pdb", "firefox.pdb"]

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

@ -1,6 +1,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import sys
import threading
@ -13,17 +14,14 @@ def LogTrace(string):
global gEnableTracing
if gEnableTracing:
threadName = threading.currentThread().getName().ljust(12)
print >> sys.stdout, time.asctime() + " " + threadName + " TRACE " + \
string
print(time.asctime() + " " + threadName + " TRACE " + string, file=sys.stdout)
def LogError(string):
threadName = threading.currentThread().getName().ljust(12)
print >> sys.stderr, time.asctime() + " " + threadName + " ERROR " + \
string
print(time.asctime() + " " + threadName + " ERROR " + string, file=sys.stderr)
def LogMessage(string):
threadName = threading.currentThread().getName().ljust(12)
print >> sys.stdout, time.asctime() + " " + threadName + " " + \
string
print(time.asctime() + " " + threadName + " " + string, file=sys.stdout)

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

@ -1,6 +1,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import cStringIO
import hashlib
@ -10,9 +11,10 @@ import subprocess
import urllib2
import zipfile
from distutils import spawn
from symFileManager import SymFileManager
from symbolicationRequest import SymbolicationRequest
from symLogging import LogMessage
from .symFileManager import SymFileManager
from .symLogging import LogMessage
from .symbolicationRequest import SymbolicationRequest
"""
Symbolication is broken when using type 'str' in python 2.7, so we use 'basestring'.

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

@ -1,13 +1,14 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
from symLogging import LogTrace, LogError
import re
import json
import re
import urllib2
from .symLogging import LogTrace, LogError
# Precompiled regex for validating lib names
# Empty lib name means client couldn't associate frame with any lib
gLibNameRE = re.compile("[0-9a-zA-Z_+\-\.]*$")

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

@ -8,11 +8,13 @@
objects and methods for parsing and serializing Talos results
see https://wiki.mozilla.org/Buildbot/Talos/DataFormat
"""
from __future__ import absolute_import, print_function
import csv
import json
import os
import re
import csv
from talos import output, utils, filter
@ -37,7 +39,7 @@ class TalosResults(object):
try:
for key, urls in output_formats.items():
_output = output.Output(self)
_output = output.Output(self, Results)
results = _output()
for url in urls:
_output.output(results, url)

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

@ -3,24 +3,24 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import copy
import mozversion
import os
import sys
import time
import traceback
import urllib
import utils
import mozhttpd
import mozversion
import utils
from mozlog import get_proxy_logger
from talos.config import get_configs, ConfigurationError
from talos.mitmproxy import mitmproxy
from talos.results import TalosResults
from talos.ttest import TTest
from talos.utils import TalosError, TalosRegression
from talos.config import get_configs, ConfigurationError
# directory of this file
here = os.path.dirname(os.path.realpath(__file__))

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

@ -1,12 +1,15 @@
from datetime import datetime
import sys
import os
import csv
import numpy
import collections
from __future__ import absolute_import
import argparse
import compare
import collections
import csv
import os
import sys
from calendar import day_name
from datetime import datetime
import compare
import numpy
sys.path.insert(1, os.path.join(sys.path[0], '..'))

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

@ -1,17 +1,17 @@
# 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 file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import
import time
import pprint
import psutil
import mozcrash
import time
import traceback
from mozprocess import ProcessHandler
from threading import Event
import mozcrash
import psutil
from mozlog import get_proxy_logger
from mozprocess import ProcessHandler
from utils import TalosError
LOG = get_proxy_logger()

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

@ -1,5 +1,7 @@
import os
from __future__ import absolute_import, print_function
import json
import os
def writeConfigFile(obj, vals):

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

@ -1,4 +1,7 @@
from __future__ import absolute_import
import os
from talos import filter
"""

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

@ -11,24 +11,24 @@
- collects info on any counters while test runs
- waits for a 'dump' from the browser
"""
from __future__ import absolute_import, print_function
import os
import sys
import platform
import results
import subprocess
import utils
import mozcrash
import talosconfig
import shutil
import subprocess
import sys
import mozcrash
import mozfile
import results
import talosconfig
import utils
from mozlog import get_proxy_logger
from talos.utils import TalosCrash, TalosError, TalosRegression
from talos.talos_process import run_browser
from talos.ffsetup import FFSetup
from talos.cmanager import CounterManagement
from talos.ffsetup import FFSetup
from talos.talos_process import run_browser
from talos.utils import TalosCrash, TalosError, TalosRegression
LOG = get_proxy_logger()

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

@ -3,15 +3,16 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""Utility functions for Talos"""
from __future__ import absolute_import
import os
import time
import urlparse
import string
import urllib
import json
import re
import os
import platform
import re
import string
import time
import urllib
import urlparse
from mozlog import get_proxy_logger

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

@ -3,6 +3,7 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import json
import os

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

@ -1,4 +1,5 @@
# xtalos: talos + xperf
from __future__ import absolute_import
from start_xperf import start # noqa
from start_xperf import start_from_config # noqa

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

@ -3,17 +3,18 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import csv
import re
import os
import sys
import xtalos
import subprocess
import json
import mozfile
import os
import re
import shutil
import subprocess
import sys
import mozfile
import xtalos
EVENTNAME_INDEX = 0
PROCESS_INDEX = 2

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

@ -3,12 +3,14 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import os
import sys
import xtalos
import subprocess
import sys
import etlparser
import xtalos
def stop(xperf_path, debug=False):

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

@ -3,11 +3,13 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import os
import sys
import xtalos
import subprocess
import sys
import xtalos
def start(xperf_path, xperf_providers, xperf_stackwalk, xperf_user_providers,

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

@ -1,10 +1,11 @@
# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import os
import argparse
import json
import os
DEBUG_CRITICAL = 0
DEBUG_ERROR = 1

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

@ -9,13 +9,15 @@
# Author(s): Zambrano Gasparnian, Armen <armenzg@mozilla.com>
# Target: Python 2.5
#
from optparse import OptionParser
from __future__ import absolute_import, print_function
import json
import os
import re
import sys
import urllib2
import urlparse
import sys
import os
from optparse import OptionParser
def main():

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

@ -3,6 +3,7 @@
"""
test talos browser output parsing
"""
from __future__ import absolute_import
import os
import unittest

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

@ -5,8 +5,10 @@ test talos' filter module:
http://hg.mozilla.org/build/talos/file/tip/talos/filter.py
"""
from __future__ import absolute_import
import unittest
import talos.filter

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

@ -9,8 +9,10 @@ test talos results parsing
http://hg.mozilla.org/build/talos/file/tip/talos/results.py
"""
from __future__ import absolute_import
import unittest
import talos.filter
import talos.results

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

@ -1,8 +1,10 @@
from __future__ import absolute_import, print_function
import json
import unittest
from talos import talosconfig
from talos.configuration import YAML
import unittest
import json
# globals
ffox_path = 'test/path/to/firefox'

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

@ -8,8 +8,10 @@
test URL parsing; see
https://bugzilla.mozilla.org/show_bug.cgi?id=793875
"""
from __future__ import absolute_import
import unittest
import talos.utils

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

@ -1,6 +1,9 @@
from talos import utils
import unittest
from __future__ import absolute_import
import os
import unittest
from talos import utils
class TestTimer(unittest.TestCase):

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

@ -3,10 +3,12 @@
"""
Tests for talos.xrestop
"""
from __future__ import absolute_import
import os
import subprocess
import unittest
from talos.cmanager_linux import xrestop
here = os.path.dirname(os.path.abspath(__file__))

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

@ -48,7 +48,6 @@ py2:
- testing/remotecppunittests.py
- testing/runcppunittests.py
- testing/runtimes
- testing/talos
- testing/tools
- testing/tps
- testing/web-platform

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

@ -36,7 +36,6 @@ py3:
- testing/mochitest
- testing/mozbase
- testing/mozharness
- testing/talos
- testing/tools/iceserver
- testing/tps
- testing/xpcshell