diff options
author | Jack Lloyd <[email protected]> | 2017-12-31 16:18:15 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-31 16:18:15 -0500 |
commit | 6e20975e8ebac325f6cb34be184886d55158c9e1 (patch) | |
tree | d5cc8b6ebeb1c1a44b3be6f7a2b9328c003654eb | |
parent | 987662117c2b98b12fdbe8e8ab3eaf8c93c748e3 (diff) |
Fix make clean target
If we removed the shared lib first, the symlinks were dangling and
access() would return false. Instead always unlink.
-rwxr-xr-x | src/scripts/cleanup.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/scripts/cleanup.py b/src/scripts/cleanup.py index 8c72d3eb1..29f8e8ede 100755 --- a/src/scripts/cleanup.py +++ b/src/scripts/cleanup.py @@ -16,6 +16,7 @@ import optparse # pylint: disable=deprecated-module import logging import json import shutil +import errno def remove_dir(d): try: @@ -29,13 +30,11 @@ def remove_dir(d): def remove_file(f): try: - if os.access(f, os.R_OK): - logging.debug('Removing file "%s"', f) - os.unlink(f) - else: - logging.debug('File %s was missing', f) - except Exception as e: # pylint: disable=broad-except - logging.error('Failed removing file "%s": %s', f, e) + logging.debug('Removing file "%s"', f) + os.unlink(f) + except OSError as e: + if e.errno != errno.ENOENT: + logging.error('Failed removing file "%s": %s', f, e) def remove_all_in_dir(d): if os.access(d, os.X_OK): |