зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563797 - Use 'backports.shutil_which' instead of 'which' across the tree r=Callek
Differential Revision: https://phabricator.services.mozilla.com/D37097 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9a1ff6557d
Коммит
3486ba642c
|
@ -37,14 +37,17 @@
|
|||
# It uses the C preprocessor to process its inputs.
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import errno
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import mozpack.path as mozpath
|
||||
import subprocess
|
||||
import shlex
|
||||
import which
|
||||
|
||||
import buildconfig
|
||||
import mozpack.path as mozpath
|
||||
from mozfile import which
|
||||
|
||||
|
||||
def ToCAsciiArray(lines):
|
||||
|
@ -113,7 +116,11 @@ def embed(cxx, preprocessorOption, cppflags, msgs, sources, c_out, js_out, names
|
|||
|
||||
def preprocess(cxx, preprocessorOption, source, args=[]):
|
||||
if (not os.path.exists(cxx[0])):
|
||||
cxx[0] = which.which(cxx[0])
|
||||
binary = cxx[0]
|
||||
cxx[0] = which(binary)
|
||||
if not cxx[0]:
|
||||
raise OSError(errno.ENOENT, "%s not found on PATH" % binary)
|
||||
|
||||
# Clang seems to complain and not output anything if the extension of the
|
||||
# input is not something it recognizes, so just fake a .cpp here.
|
||||
tmpIn = 'self-hosting-cpp-input.cpp'
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import errno
|
||||
import sys
|
||||
|
||||
from mach.decorators import (
|
||||
|
@ -67,23 +68,24 @@ class VersionControlCommands(object):
|
|||
and this command only ensures that remote repositories providing
|
||||
VCS extensions are up to date.
|
||||
"""
|
||||
import which
|
||||
import mozboot.bootstrap as bootstrap
|
||||
import mozversioncontrol
|
||||
from mozfile import which
|
||||
|
||||
repo = mozversioncontrol.get_repository_object(self._context.topdir)
|
||||
vcs = 'hg'
|
||||
tool = 'hg'
|
||||
if repo.name == 'git':
|
||||
vcs = 'git'
|
||||
tool = 'git'
|
||||
|
||||
# "hg" is an executable script with a shebang, which will be found
|
||||
# by which.which. We need to pass a win32 executable to the function
|
||||
# because we spawn a process
|
||||
# from it.
|
||||
# "hg" is an executable script with a shebang, which will be found by
|
||||
# which. We need to pass a win32 executable to the function because we
|
||||
# spawn a process from it.
|
||||
if sys.platform in ('win32', 'msys'):
|
||||
vcs = which.which(vcs + '.exe')
|
||||
else:
|
||||
vcs = which.which(vcs)
|
||||
tool += '.exe'
|
||||
|
||||
vcs = which(tool)
|
||||
if not vcs:
|
||||
raise OSError(errno.ENOENT, "Could not find {} on $PATH".format(tool))
|
||||
|
||||
if update_only:
|
||||
if repo.name == 'git':
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -667,9 +668,8 @@ class TestInfoCommand(MachCommandBase):
|
|||
@CommandArgument('--verbose', action='store_true',
|
||||
help='Enable debug logging.')
|
||||
def test_info(self, **params):
|
||||
|
||||
import which
|
||||
from mozbuild.base import MozbuildObject
|
||||
from mozfile import which
|
||||
|
||||
self.branches = params['branches']
|
||||
self.start = params['start']
|
||||
|
@ -698,17 +698,15 @@ class TestInfoCommand(MachCommandBase):
|
|||
|
||||
self._hg = None
|
||||
if conditions.is_hg(build_obj):
|
||||
if self._is_windows():
|
||||
self._hg = which.which('hg.exe')
|
||||
else:
|
||||
self._hg = which.which('hg')
|
||||
self._hg = which('hg')
|
||||
if not self._hg:
|
||||
raise OSError(errno.ENOENT, "Could not find 'hg' on PATH.")
|
||||
|
||||
self._git = None
|
||||
if conditions.is_git(build_obj):
|
||||
if self._is_windows():
|
||||
self._git = which.which('git.exe')
|
||||
else:
|
||||
self._git = which.which('git')
|
||||
self._git = which('git')
|
||||
if not self._git:
|
||||
raise OSError(errno.ENOENT, "Could not find 'git' on PATH.")
|
||||
|
||||
for test_name in params['test_names']:
|
||||
print("===== %s =====" % test_name)
|
||||
|
|
|
@ -134,19 +134,21 @@ class MachBrowsertime(MachCommandBase):
|
|||
if host_platform().startswith('linux'):
|
||||
# On Linux ImageMagick needs to be installed manually, and `mach bootstrap` doesn't
|
||||
# do that (yet). Provide some guidance.
|
||||
import which
|
||||
im_programs = ('compare', 'convert', 'mogrify')
|
||||
try:
|
||||
for im_program in im_programs:
|
||||
which.which(im_program)
|
||||
except which.WhichError as e:
|
||||
print('Error: {} On Linux, ImageMagick must be on the PATH. '
|
||||
'Install ImageMagick manually and try again (or update PATH). '
|
||||
'On Ubuntu and Debian, try `sudo apt-get install imagemagick`. '
|
||||
'On Fedora, try `sudo dnf install imagemagick`. '
|
||||
'On CentOS, try `sudo yum install imagemagick`.'
|
||||
.format(e))
|
||||
return 1
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from shutil_which import which
|
||||
|
||||
im_programs = ('compare', 'convert', 'mogrify')
|
||||
for im_program in im_programs:
|
||||
prog = which(im_program)
|
||||
if not prog:
|
||||
print('Error: On Linux, ImageMagick must be on the PATH. '
|
||||
'Install ImageMagick manually and try again (or update PATH). '
|
||||
'On Ubuntu and Debian, try `sudo apt-get install imagemagick`. '
|
||||
'On Fedora, try `sudo dnf install imagemagick`. '
|
||||
'On CentOS, try `sudo yum install imagemagick`.')
|
||||
return 1
|
||||
|
||||
# Download the visualmetrics.py requirements.
|
||||
artifact_cache = ArtifactCache(self.artifact_cache_path,
|
||||
|
|
|
@ -8,15 +8,13 @@ import os
|
|||
import sys
|
||||
from functools import partial
|
||||
|
||||
from mozbuild.base import MachCommandBase
|
||||
from mach.decorators import (
|
||||
Command,
|
||||
CommandArgument,
|
||||
CommandProvider,
|
||||
)
|
||||
|
||||
import which
|
||||
from mozbuild.base import MachCommandBase
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
|
@ -53,9 +51,10 @@ class Documentation(MachCommandBase):
|
|||
help='Upload generated files to S3.')
|
||||
def build_docs(self, path=None, fmt='html', outdir=None, auto_open=True,
|
||||
serve=True, http=None, archive=False, upload=False):
|
||||
try:
|
||||
which.which('jsdoc')
|
||||
except which.WhichError:
|
||||
|
||||
from mozfile import which
|
||||
|
||||
if not which('jsdoc'):
|
||||
return die('jsdoc not found - please install from npm.')
|
||||
|
||||
self.activate_pipenv(os.path.join(here, 'Pipfile'))
|
||||
|
|
|
@ -109,6 +109,11 @@ let's call the file ``flake8_lint.py``:
|
|||
|
||||
from mozlint import result
|
||||
|
||||
try:
|
||||
from shutil import which
|
||||
except ImportError:
|
||||
from shutil_which import which
|
||||
|
||||
|
||||
FLAKE8_NOT_FOUND = """
|
||||
Could not find flake8! Install flake8 and try again.
|
||||
|
@ -116,13 +121,10 @@ let's call the file ``flake8_lint.py``:
|
|||
|
||||
|
||||
def lint(files, config, **lintargs):
|
||||
import which
|
||||
|
||||
binary = os.environ.get('FLAKE8')
|
||||
if not binary:
|
||||
try:
|
||||
binary = which.which('flake8')
|
||||
except which.WhichError:
|
||||
binary = which('flake8')
|
||||
if not binary:
|
||||
print(FLAKE8_NOT_FOUND)
|
||||
return 1
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ from collections import namedtuple
|
|||
|
||||
import os
|
||||
import signal
|
||||
import which
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from mozfile import which
|
||||
from mozlint import result
|
||||
from mozlint.pathutils import expand_exclusions
|
||||
from mozprocess import ProcessHandler
|
||||
|
@ -105,10 +105,7 @@ def get_rustfmt_binary():
|
|||
if binary:
|
||||
return binary
|
||||
|
||||
try:
|
||||
return which.which("rustfmt")
|
||||
except which.WhichError:
|
||||
return None
|
||||
return which("rustfmt")
|
||||
|
||||
|
||||
def is_old_rustfmt(binary):
|
||||
|
|
|
@ -7,17 +7,17 @@ from __future__ import absolute_import, print_function
|
|||
import os
|
||||
import json
|
||||
import signal
|
||||
import which
|
||||
|
||||
# Py3/Py2 compatibility.
|
||||
# py2-compat
|
||||
try:
|
||||
from json.decoder import JSONDecodeError
|
||||
except ImportError:
|
||||
JSONDecodeError = ValueError
|
||||
|
||||
import mozpack.path as mozpath
|
||||
from mozpack.files import FileFinder
|
||||
from mozfile import which
|
||||
from mozlint import result
|
||||
from mozpack.files import FileFinder
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
|
||||
|
@ -135,10 +135,7 @@ def get_shellcheck_binary():
|
|||
if binary:
|
||||
return binary
|
||||
|
||||
try:
|
||||
return which.which('shellcheck')
|
||||
except which.WhichError:
|
||||
return None
|
||||
return which('shellcheck')
|
||||
|
||||
|
||||
def lint(paths, config, **lintargs):
|
||||
|
|
|
@ -6,15 +6,15 @@ from __future__ import absolute_import, print_function
|
|||
|
||||
import os
|
||||
import signal
|
||||
import which
|
||||
import re
|
||||
|
||||
# Py3/Py2 compatibility.
|
||||
# py2-compat
|
||||
try:
|
||||
from json.decoder import JSONDecodeError
|
||||
except ImportError:
|
||||
JSONDecodeError = ValueError
|
||||
|
||||
from mozfile import which
|
||||
from mozlint import result
|
||||
from mozlint.util import pip
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
@ -90,10 +90,7 @@ def get_codespell_binary():
|
|||
if binary:
|
||||
return binary
|
||||
|
||||
try:
|
||||
return which.which('codespell')
|
||||
except which.WhichError:
|
||||
return None
|
||||
return which('codespell')
|
||||
|
||||
|
||||
def lint(paths, config, fix=None, **lintargs):
|
||||
|
|
|
@ -8,11 +8,10 @@ import signal
|
|||
import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
import which
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
from mozfile import which
|
||||
from mozlint import result
|
||||
from mozlint.pathutils import get_ancestors_by_name
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
@ -71,10 +70,7 @@ def get_yamllint_binary():
|
|||
if binary:
|
||||
return binary
|
||||
|
||||
try:
|
||||
return which.which('yamllint')
|
||||
except which.WhichError:
|
||||
return None
|
||||
return which('yamllint')
|
||||
|
||||
|
||||
def _run_pip(*args):
|
||||
|
|
|
@ -4,19 +4,25 @@
|
|||
# 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/.
|
||||
|
||||
import errno
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
import which
|
||||
|
||||
import buildconfig
|
||||
from mozfile import which
|
||||
|
||||
|
||||
def preprocess(out, asm_file):
|
||||
cxx = shlex.split(buildconfig.substs['CXX'])
|
||||
if not os.path.exists(cxx[0]):
|
||||
cxx[0] = which.which(cxx[0])
|
||||
tool = cxx[0]
|
||||
cxx[0] = which(tool)
|
||||
if not cxx[0]:
|
||||
raise OSError(errno.ENOENT, "Could not find {} on PATH.".format(tool))
|
||||
|
||||
cppflags = buildconfig.substs['OS_CPPFLAGS']
|
||||
|
||||
# subprocess.Popen(stdout=) only accepts actual file objects, which `out`,
|
||||
|
|
Загрузка…
Ссылка в новой задаче