add function to read RAM amount

This commit is contained in:
Andreas Zweili 2021-12-19 18:58:31 +01:00
parent aa98d610b0
commit 2e278d85bb
1 changed files with 8 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import os
import subprocess
@ -10,6 +11,12 @@ def _run_command(command):
return result
def _get_system_memory():
mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
mem_gib = mem_bytes / (1024.**3)
return round(mem_gib)
def read_disks():
output = _run_command(["lsblk", "-dpno", "name"])
disks = []
@ -45,6 +52,7 @@ def main():
create_menu(disks)
disk_to_format = disks[get_disk_to_format()]
format_disk(disk_to_format)
print(_get_system_memory())
if __name__ == "__main__":