add function to read RAM amount
This commit is contained in:
parent
aa98d610b0
commit
2e278d85bb
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +11,12 @@ def _run_command(command):
|
||||||
return result
|
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():
|
def read_disks():
|
||||||
output = _run_command(["lsblk", "-dpno", "name"])
|
output = _run_command(["lsblk", "-dpno", "name"])
|
||||||
disks = []
|
disks = []
|
||||||
|
@ -45,6 +52,7 @@ def main():
|
||||||
create_menu(disks)
|
create_menu(disks)
|
||||||
disk_to_format = disks[get_disk_to_format()]
|
disk_to_format = disks[get_disk_to_format()]
|
||||||
format_disk(disk_to_format)
|
format_disk(disk_to_format)
|
||||||
|
print(_get_system_memory())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue