Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch PermissionError when checking for dependencies #433

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

hikir1
Copy link

@hikir1 hikir1 commented Feb 26, 2024

Catch PermissionError when checking for dependencies, and issue a warning.

Fixes this issue

BuildTools and others added 7 commits February 26, 2024 10:41
If a tool or a directory in the PATH environment variable
doesn't have the right permissions, it will trigger a
PermissionError and cause ofrak to crash while testing for
dependencies. Instead, we should catch the error and issue
a warning.
Copy link
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready to merge to me

Copy link
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, needs tests.

@hikir1 hikir1 closed this Mar 18, 2024
@hikir1 hikir1 reopened this Mar 18, 2024
Adding test case for catching PermissionError when searching for tools
in PATH
@hikir1
Copy link
Author

hikir1 commented Mar 18, 2024

Added a test to ofrak_core/test_ofrak/unit/test_ofrak_context.py

Comment on lines 40 to 41
found = [r for r in caplog.records if r.message == expected]
assert len(found) == 1, "Missing error message from component_model"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
found = [r for r in caplog.records if r.message == expected]
assert len(found) == 1, "Missing error message from component_model"
assert any(r.message == expected for r in caplog.records), "Missing error message from component_model"

This way of doing it is a little more concise. Will probably need to re-run the linter after applying the suggestion, though.

Copy link
Member

@rbs-jacob rbs-jacob Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second read, my suggested change is not exactly the same as what the original test does, so feel free to resolve this without accepting the edit.

But this particular test is failing in the CI check, so this will have to be revised in some way before we can merge.

ofrak_core/test_ofrak/unit/test_ofrak_context.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crashes when checking for missing dependencies
2 participants