Added get_stats to fps.py AND modified _gather_cpu_usage to avoid cod…#1
Open
killuhwhale wants to merge 1 commit into
Open
Added get_stats to fps.py AND modified _gather_cpu_usage to avoid cod…#1killuhwhale wants to merge 1 commit into
killuhwhale wants to merge 1 commit into
Conversation
…e duplication on both.
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.
fps.py
def get_stats(self, frames: List[Frame], frameless=False) -> dict:
get_stats() will do the calculations, this will keep the calc logic in one place without duplicating.
It will also take an optional bool, frameless to indicate if we have frames or not. (This helps with backward compatibility)
If frameless is True, _get_recent_frames() will be called which should only be called within the class.
Returns a dict of the values calculated.
cpu.py
web_gather_cpu_usage()
Calls _gather_cpu_usage()
If successful, it get the usage values from the last appened values in the arrays. (Since they were just previously appened)
_gather_cpu_usage()
This will now return True or False and set self.error to the error message
It only updates the values if there are no errors.
It returns true if no errors.
New optional parameter cmdLine=True, if True sys.exit(1) will be called when an error is encountered.
If cmdLine=False, the function will just set self.error with the error message and return False
main.py Might be an app breaking change.
/cpu/
This now returns {error: msg} instead of str(msg) if there was an error.