Skip to content
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

Fix system_info.py #677

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions scripts/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
###### BASIC SYSTEM INFO SCRIPT ######
######################################
# Written by Frix_x#0161 #
# @version: 1.0
# @version: 1.1

# CHANGELOG:
# v1.0: first version of the script to get some system info printed in the klippy.log
# v1.1: fix get_ram_info, Fixed an issue where Available RAM was displayed in "Used RAM".


# Be sure to make this script executable using SSH: type 'chmod +x ./system_info.py' when in the folder !
Expand Down Expand Up @@ -72,8 +73,8 @@ def get_os_kernel_info():
def get_ram_info():
try:
total_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[1]
available_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[6]
return total_ram, available_ram
used_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[2]
return total_ram, used_ram
except subprocess.CalledProcessError:
return None, None

Expand Down Expand Up @@ -112,12 +113,13 @@ def print_system_info():
print(f"System information: {get_unknown_board_info()}")


total_ram, available_ram = future_ram_info.result()
if total_ram is None or available_ram is None:
total_ram, used_ram = future_ram_info.result()
if total_ram is None or used_ram is None:
print("RAM information not found...")
else:
print(f"Used RAM: {available_ram}/{total_ram} MB")
print(f"Used RAM: {used_ram}/{total_ram} MB")


if __name__ == "__main__":
print_system_info()