From 844d104d063acf641577c777975e3c38c3fbf157 Mon Sep 17 00:00:00 2001 From: Alexey Kuzmin Date: Thu, 30 Sep 2021 15:48:59 +0200 Subject: [PATCH] chore: fix pylint (#31207) * chore: fix pylint * chore: fix linter errors --- script/lib/git.py | 5 ++--- script/lib/native_tests.py | 2 +- script/lint.js | 19 ++++++++++++++++--- script/patches-mtime-cache.py | 2 +- script/release/uploaders/upload.py | 3 ++- script/verify-ffmpeg.py | 3 ++- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/script/lib/git.py b/script/lib/git.py index 630a42e2a62b9..cb8f7434dd630 100644 --- a/script/lib/git.py +++ b/script/lib/git.py @@ -232,9 +232,8 @@ def remove_patch_filename(patch): def export_patches(repo, out_dir, patch_range=None, dry_run=False): if patch_range is None: patch_range, num_patches = guess_base_commit(repo) - sys.stderr.write( - "Exporting {} patches in {} since {}\n".format(num_patches, repo, patch_range[0:7]) - ) + sys.stderr.write("Exporting {} patches in {} since {}\n".format( + num_patches, repo, patch_range[0:7])) patch_data = format_patch(repo, patch_range) patches = split_patches(patch_data) diff --git a/script/lib/native_tests.py b/script/lib/native_tests.py index f28d827fa6d89..e84f393848793 100644 --- a/script/lib/native_tests.py +++ b/script/lib/native_tests.py @@ -4,7 +4,7 @@ import subprocess import sys -from util import SRC_DIR +from lib.util import SRC_DIR PYYAML_LIB_DIR = os.path.join(SRC_DIR, 'third_party', 'pyyaml', 'lib') sys.path.append(PYYAML_LIB_DIR) diff --git a/script/lint.js b/script/lint.js index 94cf85ac4469e..3ee6ace0bd3d8 100755 --- a/script/lint.js +++ b/script/lint.js @@ -29,8 +29,21 @@ const IS_WINDOWS = process.platform === 'win32'; function spawnAndCheckExitCode (cmd, args, opts) { opts = Object.assign({ stdio: 'inherit' }, opts); - const status = childProcess.spawnSync(cmd, args, opts).status; - if (status) process.exit(status); + const { error, status, signal } = childProcess.spawnSync(cmd, args, opts); + if (error) { + // the subsprocess failed or timed out + console.error(error); + process.exit(1); + } + if (status === null) { + // the subprocess terminated due to a signal + console.error(signal); + process.exit(1); + } + if (status !== 0) { + // `status` is an exit code + process.exit(status); + } } function cpplint (args) { @@ -91,7 +104,7 @@ const LINTERS = [{ const rcfile = path.join(DEPOT_TOOLS, 'pylintrc'); const args = ['--rcfile=' + rcfile, ...filenames]; const env = Object.assign({ PYTHONPATH: path.join(SOURCE_ROOT, 'script') }, process.env); - spawnAndCheckExitCode('pylint.py', args, { env }); + spawnAndCheckExitCode('pylint', args, { env }); } }, { key: 'javascript', diff --git a/script/patches-mtime-cache.py b/script/patches-mtime-cache.py index 38f93ebd06a1e..800d3b03cbb83 100644 --- a/script/patches-mtime-cache.py +++ b/script/patches-mtime-cache.py @@ -135,7 +135,7 @@ def main(): json.load(f) # Make sure it's not an empty file print("Using existing mtime cache for patches") return 0 - except: + except Exception: pass try: diff --git a/script/release/uploaders/upload.py b/script/release/uploaders/upload.py index 6d62d16a0fbb1..b021f91dadf9d 100755 --- a/script/release/uploaders/upload.py +++ b/script/release/uploaders/upload.py @@ -100,7 +100,8 @@ def main(): # Upload libcxx_objects.zip for linux only libcxx_objects = get_zip_name('libcxx-objects', ELECTRON_VERSION) libcxx_objects_zip = os.path.join(OUT_DIR, libcxx_objects) - shutil.copy2(os.path.join(OUT_DIR, 'libcxx_objects.zip'), libcxx_objects_zip) + shutil.copy2(os.path.join(OUT_DIR, 'libcxx_objects.zip'), + libcxx_objects_zip) upload_electron(release, libcxx_objects_zip, args) # Upload headers.zip and abi_headers.zip as non-platform specific diff --git a/script/verify-ffmpeg.py b/script/verify-ffmpeg.py index 8aeffb18627f8..ee7de30fbc1b4 100755 --- a/script/verify-ffmpeg.py +++ b/script/verify-ffmpeg.py @@ -48,7 +48,8 @@ def main(): # FIXME: Enable after ELECTRON_ENABLE_LOGGING works again # env['ELECTRON_ENABLE_LOGGING'] = 'true' testargs = [electron, test_path] - if sys.platform != 'linux' and (platform.machine() == 'ARM64' or os.environ.get('TARGET_ARCH') == 'arm64'): + if sys.platform != 'linux' and (platform.machine() == 'ARM64' or + os.environ.get('TARGET_ARCH') == 'arm64'): testargs.append('--disable-accelerated-video-decode') subprocess.check_call(testargs, env=env) except subprocess.CalledProcessError as e: