Skip to content

Logging: No longer mark log messages from nvda.pyw as coming from external code when running from sources#13827

Merged
seanbudd merged 2 commits into
nvaccess:masterfrom
lukaszgo1:noBackslashAfterDP0
Jun 27, 2022
Merged

Logging: No longer mark log messages from nvda.pyw as coming from external code when running from sources#13827
seanbudd merged 2 commits into
nvaccess:masterfrom
lukaszgo1:noBackslashAfterDP0

Conversation

@lukaszgo1

Copy link
Copy Markdown
Contributor

Link to issue number:

None

Summary of the issue:

When starting NVDA from sources messages logged from nvda.pyw are shown as external. Example message:

INFO - external:__main__ (17:20:02.477) - MainThread (4316):
Starting NVDA version source-master-b817b03

This is clearly wrong. The problem is caused by the trailing backslash added in bat scripts (%~dp0 is already terminated with one and adding a second backslash causes logHandler.isPathExternalToNVDA to think that the path is external).

Description of user facing changes

Log messages from nvda.pyw are no longer marked as external.

Description of development approach

All usages of %~dp0 are inspected and trailing backslash is no longer added to the paths. To make logHandler.isPathExternalToNVDA more resilient to invalid paths the path is normalized before checking if it is the same as sys.path.

Testing strategy:

  • Tested that messages logged from nvda.pyw are no longer marked as external.
  • Smoke tested modified scripts.

Known issues with pull request:

None known

Change log entries:

None needed - affects only logging from source copies.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English

@lukaszgo1 lukaszgo1 requested a review from a team as a code owner June 21, 2022 15:44
@lukaszgo1 lukaszgo1 requested a review from seanbudd June 21, 2022 15:44
Comment thread source/logHandler.py
@lukaszgo1 lukaszgo1 force-pushed the noBackslashAfterDP0 branch from ab9dce6 to c4b6508 Compare June 22, 2022 17:09
@lukaszgo1

Copy link
Copy Markdown
Contributor Author

@seanbudd I agree that these extra backslashes in scripts make the code more readable, however they are also shown in the console when running these bat files, + paths with multiple backslashes are non standard. I've modified the code so that the extra backslash is stripped from the paths - let me know if this makes things better.

Comment thread runlint.bat
call "%~dp0\venvUtils\venvCmd.bat" py "%~dp0\tests\lint\genDiff.py" %1 "%~dp0\tests\lint\_lint.diff"
set hereOrig=%~dp0
set here=%hereOrig%
if #%hereOrig:~-1%# == #\# set here=%hereOrig:~0,-1%

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this doing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It strips the backslash from the path of the current directory if it ends with one.

@seanbudd seanbudd merged commit ebb05fe into nvaccess:master Jun 27, 2022
@nvaccessAuto nvaccessAuto added this to the 2022.3 milestone Jun 27, 2022
@lukaszgo1 lukaszgo1 deleted the noBackslashAfterDP0 branch June 27, 2022 09:24
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.

3 participants