From f72360bce1c83d989edb7da24d77d6effcc14d52 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Wed, 11 Sep 2019 19:52:08 +0000 Subject: [PATCH] Bug 1580280 - [lint] Support Python 3 in the eslint integration r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D45438 --HG-- extra : moz-landing-system : lando --- tools/lint/eslint/__init__.py | 3 ++- tools/lint/eslint/setup_helper.py | 18 +++++++++--------- tools/lint/test/python.ini | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/lint/eslint/__init__.py b/tools/lint/eslint/__init__.py index 0cfe82bb496b..83e06fcd9192 100644 --- a/tools/lint/eslint/__init__.py +++ b/tools/lint/eslint/__init__.py @@ -86,7 +86,8 @@ def lint(paths, config, binary=None, fix=None, setup=None, **lintargs): shell = True orig = signal.signal(signal.SIGINT, signal.SIG_IGN) - proc = ProcessHandler(cmd_args, env=os.environ, stream=None, shell=shell) + proc = ProcessHandler(cmd_args, env=os.environ, stream=None, + shell=shell, universal_newlines=True) proc.run() signal.signal(signal.SIGINT, orig) diff --git a/tools/lint/eslint/setup_helper.py b/tools/lint/eslint/setup_helper.py index c9f5b0743aeb..8b6233990629 100644 --- a/tools/lint/eslint/setup_helper.py +++ b/tools/lint/eslint/setup_helper.py @@ -6,22 +6,22 @@ from __future__ import absolute_import, print_function -from filecmp import dircmp import json import os import platform import re -from mozfile.mozfile import remove as mozfileremove +import shutil import subprocess import sys -import shutil import tempfile from distutils.version import LooseVersion, StrictVersion -from mozbuild.util import ensure_subprocess_env +from filecmp import dircmp + from mozbuild.nodeutil import (find_node_executable, find_npm_executable, NPM_MIN_VERSION, NODE_MIN_VERSION) -sys.path.append(os.path.join( - os.path.dirname(__file__), "..", "..", "..", "third_party", "python", "which")) +from mozbuild.util import ensure_subprocess_env +from mozfile.mozfile import remove as mozfileremove + NODE_MACHING_VERSION_NOT_FOUND_MESSAGE = """ Could not find Node.js executable later than %s. @@ -233,7 +233,7 @@ def eslint_module_needs_setup(): needs_clobber = False node_modules_path = os.path.join(get_project_root(), "node_modules") - for name, expected_data in expected_eslint_modules().iteritems(): + for name, expected_data in expected_eslint_modules().items(): # expected_eslint_modules returns a string for the version number of # dependencies for installation of eslint generally, and an object # for our in-tree plugins (which contains the entire module info). @@ -316,8 +316,8 @@ def get_possible_node_paths_win(): def get_version(path): try: - version_str = subprocess.check_output([path, "--version"], - stderr=subprocess.STDOUT) + version_str = subprocess.check_output([path, "--version"], stderr=subprocess.STDOUT, + universal_newlines=True) return version_str except (subprocess.CalledProcessError, OSError): return None diff --git a/tools/lint/test/python.ini b/tools/lint/test/python.ini index c3b1fdfe7028..557f7164472f 100644 --- a/tools/lint/test/python.ini +++ b/tools/lint/test/python.ini @@ -2,7 +2,7 @@ subsuite = mozlint [test_eslint.py] -skip-if = python == 3 || os == "win" || os == "mac" # node not installed on worker +skip-if = os == "win" || os == "mac" # node not installed on worker [test_flake8.py] requirements = tools/lint/python/flake8_requirements.txt skip-if = os == "mac" # pip unable to find 'flake8==3.5.0'