Skip to content

Commit ff2f4d4

Browse files
committed
assert scripts have +x bit
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
1 parent ebbaae8 commit ff2f4d4

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

psutil/tests/test_misc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,12 @@ def test_coverage(self):
720720

721721
@unittest.skipIf(not POSIX, "POSIX only")
722722
def test_executable(self):
723-
for name in os.listdir(SCRIPTS_DIR):
724-
if name.endswith('.py'):
725-
path = os.path.join(SCRIPTS_DIR, name)
726-
if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]:
727-
self.fail('%r is not executable' % path)
723+
for root, dirs, files in os.walk(SCRIPTS_DIR):
724+
for file in files:
725+
if file.endswith('.py'):
726+
path = os.path.join(root, file)
727+
if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]:
728+
raise self.fail('%r is not executable' % path)
728729

729730
def test_disk_usage(self):
730731
self.assert_stdout('disk_usage.py')

scripts/internal/git_pre_commit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- assert not pdb.set_trace in code
1414
- assert no bare except clause ("except:") in code
1515
- assert "flake8" checks pass
16+
- assert "isort" checks pass
1617
- assert C linter checks pass
1718
- abort if files were added/renamed/removed and MANIFEST.in was not updated
1819
@@ -124,15 +125,15 @@ def main():
124125
cmd = "%s -m flake8 --config=.flake8 %s" % (PYTHON, " ".join(py_files))
125126
ret = subprocess.call(shlex.split(cmd))
126127
if ret != 0:
127-
return exit("python code is not flake8 compliant; "
128+
return exit("python code didn't pass 'flake8' style check; "
128129
"try running 'make fix-flake8'")
129130
# isort
130131
assert os.path.exists('.isort.cfg')
131132
cmd = "%s -m isort --settings=.isort.cfg --check-only %s" % (
132133
PYTHON, " ".join(py_files))
133134
ret = subprocess.call(shlex.split(cmd))
134135
if ret != 0:
135-
return exit("python code is not flake8 compliant; "
136+
return exit("python code didn't pass 'isort' style check; "
136137
"try running 'make fix-imports'")
137138
# C linter
138139
if c_files:

scripts/internal/winmake.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ def onerror(fun, path, excinfo):
156156
safe_remove(pattern)
157157
return
158158

159-
for root, subdirs, subfiles in os.walk('.'):
159+
for root, dirs, files in os.walk('.'):
160160
root = os.path.normpath(root)
161161
if root.startswith('.git/'):
162162
continue
163-
found = fnmatch.filter(subdirs if directory else subfiles, pattern)
163+
found = fnmatch.filter(dirs if directory else files, pattern)
164164
for name in found:
165165
path = os.path.join(root, name)
166166
if directory:
@@ -195,15 +195,15 @@ def onerror(fun, path, excinfo):
195195

196196
def recursive_rm(*patterns):
197197
"""Recursively remove a file or matching a list of patterns."""
198-
for root, subdirs, subfiles in os.walk(u'.'):
198+
for root, dirs, files in os.walk(u'.'):
199199
root = os.path.normpath(root)
200200
if root.startswith('.git/'):
201201
continue
202-
for file in subfiles:
202+
for file in files:
203203
for pattern in patterns:
204204
if fnmatch.fnmatch(file, pattern):
205205
safe_remove(os.path.join(root, file))
206-
for dir in subdirs:
206+
for dir in dirs:
207207
for pattern in patterns:
208208
if fnmatch.fnmatch(dir, pattern):
209209
safe_rmtree(os.path.join(root, dir))

0 commit comments

Comments
 (0)