Skip to content

Commit

Permalink
Merge branch 'oneshot' into oneshot-win
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 27, 2016
2 parents 68ba191 + ed64f4a commit 0f98202
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 30 deletions.
14 changes: 7 additions & 7 deletions Makefile
Expand Up @@ -35,16 +35,16 @@ all: test

# Remove all build files.
clean:
rm -rf `find . \
-type f -name \*.pyc \
rm -rf `find . -type d -name __pycache__
-o -type f -name \*.bak \
-o -type f -name \*.orig \
-o -type f -name \*.pyc \
-o -type f -name \*.pyd \
-o -type f -name \*.pyo \
-o -type f -name \*.so \
-o -type f -name \*.~ \
-o -type f -name \*.orig \
-o -type f -name \*.bak \
-o -type f -name \*.rej \
-o -type d -name __pycache__`
-o -type f -name \*.so \
-o -type f -name \*.~
-o -type f -name \*\$testfn`
rm -rf \
*.core \
*.egg-info \
Expand Down
2 changes: 1 addition & 1 deletion psutil/tests/__init__.py
Expand Up @@ -103,7 +103,7 @@
PYTHON = os.path.realpath(sys.executable)
DEVNULL = open(os.devnull, 'r+')

TESTFILE_PREFIX = '$psutil'
TESTFILE_PREFIX = '$testfn'
TESTFN = os.path.join(os.path.realpath(os.getcwd()), TESTFILE_PREFIX)
_TESTFN = TESTFN + '-internal'
TESTFN_UNICODE = TESTFN + "-ƒőő"
Expand Down
4 changes: 2 additions & 2 deletions scripts/internal/bench_oneshot.py
Expand Up @@ -121,8 +121,8 @@ def call_oneshot(funs):


def main():
print("%s methods involved on platform %r (%s iterations):" % (
len(names), sys.platform, ITERATIONS))
print("%s methods involved on platform %r (%s iterations, psutil %s):" % (
len(names), sys.platform, ITERATIONS, psutil.__version__))
for name in sorted(names):
print(" " + name)

Expand Down
4 changes: 2 additions & 2 deletions scripts/internal/bench_oneshot_2.py
Expand Up @@ -41,8 +41,8 @@ def main():

args = runner.parse_args()
if not args.worker:
print("%s methods involved on platform %r:" % (
len(names), sys.platform))
print("%s methods involved on platform %r (psutil %s):" % (
len(names), sys.platform, psutil.__version__))
for name in sorted(names):
print(" " + name)

Expand Down
78 changes: 60 additions & 18 deletions scripts/internal/winmake.py
Expand Up @@ -110,6 +110,44 @@ def onerror(fun, path, excinfo):
safe_remove(path)


def safe_remove(path):
try:
os.remove(path)
except OSError as err:
if err.errno != errno.ENOENT:
raise
else:
print("rm %s" % path)


def safe_rmtree(path):
def onerror(fun, path, excinfo):
exc = excinfo[1]
if exc.errno != errno.ENOENT:
raise

existed = os.path.isdir(path)
shutil.rmtree(path, onerror=onerror)
if existed:
print("rmdir -f %s" % path)


def recursive_rm(*patterns):
"""Recursively remove a file or dir by pattern."""
for root, subdirs, subfiles in os.walk('.'):
root = os.path.normpath(root)
if root.startswith('.git/'):
continue
for file in subfiles:
for pattern in patterns:
if fnmatch.fnmatch(file, pattern):
safe_remove(os.path.join(root, file))
for dir in subdirs:
for pattern in patterns:
if fnmatch.fnmatch(dir, pattern):
safe_rmtree(os.path.join(root, dir))


# ===================================================================
# commands
# ===================================================================
Expand Down Expand Up @@ -201,24 +239,28 @@ def uninstall():
@cmd
def clean():
"""Deletes dev files"""
rm("*.egg-info", directory=True)
rm("*__pycache__", directory=True)
rm("build", directory=True)
rm("dist", directory=True)
rm("htmlcov", directory=True)
rm("tmp", directory=True)

rm("*.bak")
rm("*.core")
rm("*.orig")
rm("*.pyc")
rm("*.pyd")
rm("*.pyo")
rm("*.rej")
rm("*.so")
rm("*.~")
rm(".coverage")
rm(".tox")
recursive_rm(
"$testfn*",
"*.bak",
"*.core",
"*.egg-info",
"*.orig",
"*.pyc",
"*.pyd",
"*.pyo",
"*.rej",
"*.so",
"*.~",
"*__pycache__",
".coverage",
".tox",
)
safe_rmtree("build")
safe_rmtree(".coverage")
safe_rmtree("dist")
safe_rmtree("docs/_build")
safe_rmtree("htmlcov")
safe_rmtree("tmp")


@cmd
Expand Down

0 comments on commit 0f98202

Please sign in to comment.