Skip to content

Commit

Permalink
deleted-libraries.py: fix exception handling and miss-counting
Browse files Browse the repository at this point in the history
EnvironmentError exceptions deprecated since Python 3.3 and are now longer used. I have this changes
running since over a year now and have never encountered any other exceptions than FileNotFoundError
or ProcessLookupError.
Also due to an indentation error the metric values could never reach anything above 1 even if the
outdated library is used more than once.

Signed-off-by: Christian Pointner <[email protected]>
  • Loading branch information
equinox0815 committed Jul 18, 2023
1 parent 34dd42e commit a31d7c2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions deleted_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ def main():
if path not in processes_linking_deleted_libraries:
processes_linking_deleted_libraries[path] = {}

if library in processes_linking_deleted_libraries[path]:
processes_linking_deleted_libraries[path][library] += 1
else:
processes_linking_deleted_libraries[path][library] = 1
except EnvironmentError as e:
if library in processes_linking_deleted_libraries[path]:
processes_linking_deleted_libraries[path][library] += 1
else:
processes_linking_deleted_libraries[path][library] = 1
except FileNotFoundError:
# Ignore non-existent files, since the files may have changed since
# we globbed.
if e.errno != errno.ENOENT:
sys.exit('Failed to open file: {0}'.format(path))
pass
except ProcessLookupError:
# If process vanishes while collecting the linked libs reading lines from
# the map file yields this error.
pass

num_processes_per_library = {}

Expand Down

0 comments on commit a31d7c2

Please sign in to comment.