fix(DevHooks): replace hardcoded Desktop log path with APPDATA, swallow write errors#3376
Open
Copilot wants to merge 3 commits into
Open
fix(DevHooks): replace hardcoded Desktop log path with APPDATA, swallow write errors#3376Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/pyrevitlabs/pyRevit/sessions/bfee59ef-7657-4a20-bb19-051648af1343 Co-authored-by: jmcouffin <[email protected]>
Copilot created this pull request from a session on behalf of
jmcouffin
May 14, 2026 15:43
View session
Contributor
|
Fixes #3338 |
Replace exists()+makedirs() with unconditional makedirs() wrapped in its own OSError guard. The outer except now only catches real write failures, preventing a race-created directory from masking permission errors or other genuine IOErrors.
Contributor
|
@jmcouffin from first glance, it looks to be agood practice, I know @sanzoghenzo is not a fan of |
sanzoghenzo
reviewed
May 14, 2026
Contributor
sanzoghenzo
left a comment
There was a problem hiding this comment.
Ok for not using pathlib, but I still got something to say 😅
| f.write(record_str + '\n') | ||
| try: | ||
| try: | ||
| os.makedirs(op.dirname(HOOK_LOGS)) |
Contributor
There was a problem hiding this comment.
Why use os.dirname instead of storing and using the directory directly? Something like HOOK_LOGS_DIR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hooks_logger.pyhardcodes%userprofile%\desktop\hooks.log. On machines where Desktop is redirected to OneDrive, that path doesn't exist — every hook fire throws an unhandledIOError, and becauseprogress-changedfires continuously during model load, this produces a cascade of error dialogs that leaks memory until Revit is unusable.Changes
%userprofile%\desktop\hooks.log→%APPDATA%\pyRevit\hooks.log(always-valid, writable location)os.makedirsensures thepyRevitsubdirectory exists before first write_write_recordnow catchesIOError/OSErrorand passes, so any future path issue never surfaces as a dialog