diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2021-12-15 11:46:07 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2021-12-15 11:46:07 +0100 |
commit | ff2f4d4c4986bffbc5348a197396e11bef057346 (patch) | |
tree | ec673f29b1a18be6313a73ce642e68266a6aee93 | |
parent | ebbaae8d1f42f051282af79d60f19cb1161088a5 (diff) | |
download | psutil-ff2f4d4c4986bffbc5348a197396e11bef057346.tar.gz |
assert scripts have +x bit
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rwxr-xr-x | psutil/tests/test_misc.py | 11 | ||||
-rwxr-xr-x | scripts/internal/git_pre_commit.py | 5 | ||||
-rwxr-xr-x | scripts/internal/winmake.py | 10 |
3 files changed, 14 insertions, 12 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index fb4d0c02..0362432c 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -720,11 +720,12 @@ class TestScripts(PsutilTestCase): @unittest.skipIf(not POSIX, "POSIX only") def test_executable(self): - for name in os.listdir(SCRIPTS_DIR): - if name.endswith('.py'): - path = os.path.join(SCRIPTS_DIR, name) - if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]: - self.fail('%r is not executable' % path) + for root, dirs, files in os.walk(SCRIPTS_DIR): + for file in files: + if file.endswith('.py'): + path = os.path.join(root, file) + if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]: + raise self.fail('%r is not executable' % path) def test_disk_usage(self): self.assert_stdout('disk_usage.py') diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index dca17ffb..c6f223bb 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -13,6 +13,7 @@ the files which were modified in the commit. Checks: - assert not pdb.set_trace in code - assert no bare except clause ("except:") in code - assert "flake8" checks pass +- assert "isort" checks pass - assert C linter checks pass - abort if files were added/renamed/removed and MANIFEST.in was not updated @@ -124,7 +125,7 @@ def main(): cmd = "%s -m flake8 --config=.flake8 %s" % (PYTHON, " ".join(py_files)) ret = subprocess.call(shlex.split(cmd)) if ret != 0: - return exit("python code is not flake8 compliant; " + return exit("python code didn't pass 'flake8' style check; " "try running 'make fix-flake8'") # isort assert os.path.exists('.isort.cfg') @@ -132,7 +133,7 @@ def main(): PYTHON, " ".join(py_files)) ret = subprocess.call(shlex.split(cmd)) if ret != 0: - return exit("python code is not flake8 compliant; " + return exit("python code didn't pass 'isort' style check; " "try running 'make fix-imports'") # C linter if c_files: diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 4452ef09..6c482975 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -156,11 +156,11 @@ def rm(pattern, directory=False): safe_remove(pattern) return - for root, subdirs, subfiles in os.walk('.'): + for root, dirs, files in os.walk('.'): root = os.path.normpath(root) if root.startswith('.git/'): continue - found = fnmatch.filter(subdirs if directory else subfiles, pattern) + found = fnmatch.filter(dirs if directory else files, pattern) for name in found: path = os.path.join(root, name) if directory: @@ -195,15 +195,15 @@ def safe_rmtree(path): def recursive_rm(*patterns): """Recursively remove a file or matching a list of patterns.""" - for root, subdirs, subfiles in os.walk(u'.'): + for root, dirs, files in os.walk(u'.'): root = os.path.normpath(root) if root.startswith('.git/'): continue - for file in subfiles: + for file in files: for pattern in patterns: if fnmatch.fnmatch(file, pattern): safe_remove(os.path.join(root, file)) - for dir in subdirs: + for dir in dirs: for pattern in patterns: if fnmatch.fnmatch(dir, pattern): safe_rmtree(os.path.join(root, dir)) |