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
pids: case insensitive string comparison for process names #52564
Conversation
This comment has been minimized.
This comment has been minimized.
Fixed "AttributeError: 'NoneType' object has no attribute 'lower'" error for "Empty" or None strings passed as process name.
@Akasurde It seems the tests have again generated an "AttributeError" error. Can you kindly review the code? I am not able to find the bug. I have alreday put a check 'bool(name)' in place to avoid the call to "NoneType".lower(). |
@CodeAbyss Want to try this - return [p.info['pid'] for p in psutil.process_iter(attrs=['pid', 'name']) if p.info and p.info.get('name', None) and p.info['name'].lower() == name.lower()] |
Fixed "AttributeError" for object 'NoneType' while calling lower() on the returned process info from psutil's process_iter. Thanks to @Akasurde for suggestion :)
@CodeAbyss This PR contains |
Added check on p.info and p.info['name'] to check if they are Empty or None, and then calling lower() on them. The older commit message contained the mentions, so commiting new with changed commit message.
This comment has been minimized.
This comment has been minimized.
Removed whitespaces. Added them earlier to amend the previous commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@CodeAbyss Can you please squash your commits to get rid of the The reason for this is GitHub will send him an email every time someone merges this |
@gundalow I might sound naive, but I don't know how to squash the commits. I searched, but all of them are telling cmd line params for git. Can you guide me on how to do this on GitHub? |
@CodeAbyss You need to following
You can read about interactive rebase here - https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history and https://git-scm.com/book/en/v2/Git-Branching-Rebasing |
@CodeAbyss Any news ? Let me know if you want me to take over this PR and get it merged. Thanks. |
@Akasurde I have followed the steps as per your instructions & below are the details. Kindly have a look::
Is that it or do I have to create a new PR? |
SUMMARY
"Fixes #52563"
ISSUE TYPE
COMPONENT NAME
pids
ADDITIONAL INFORMATION
This fix will compare the user input process name and psutil returned process name with case insensitiveness. This will make the pids component more robust and usable.