Skip to content

Added get_stats to fps.py AND modified _gather_cpu_usage to avoid cod…#1

Open
killuhwhale wants to merge 1 commit into
mainfrom
update_stats_fps
Open

Added get_stats to fps.py AND modified _gather_cpu_usage to avoid cod…#1
killuhwhale wants to merge 1 commit into
mainfrom
update_stats_fps

Conversation

@killuhwhale

Copy link
Copy Markdown
Collaborator

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.

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.

1 participant