Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer committed Oct 10, 2023
1 parent 098cfb8 commit 73ff925
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions backend/src/backend/user_session/routers/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
START_TIME_CONTAINER = datetime.datetime.now()


def _convert_psutil_object(psutil_object: NamedTuple) -> Dict[str, Union[str, Dict[str, str]]]:
return {
key: getattr(psutil_object, key) if key == "percent" else getattr(psutil_object, key)
for key in psutil_object._fields
}
def _convert_psutil_object_to_dict(psutil_object: NamedTuple) -> Dict[str, Union[str, Dict[str, str]]]:
return {key: getattr(psutil_object, key) for key in psutil_object._fields}


@router.get("/user_session_container")
Expand All @@ -33,8 +30,8 @@ async def user_session_container(
return {
"username": authenticated_user.get_username(),
"startTimeContainer": START_TIME_CONTAINER,
"rootDiskSystem": _convert_psutil_object(psutil.disk_usage("/")),
"memorySystem": _convert_psutil_object(psutil.virtual_memory()),
"memoryPythonProcess": _convert_psutil_object(psutil.Process().memory_info()),
"rootDiskSystem": _convert_psutil_object_to_dict(psutil.disk_usage("/")),
"memorySystem": _convert_psutil_object_to_dict(psutil.virtual_memory()),
"memoryPythonProcess": _convert_psutil_object_to_dict(psutil.Process().memory_info()),
"cpuPercent": psutil.cpu_percent(),
}

0 comments on commit 73ff925

Please sign in to comment.