# Name: memsize.py # # Determines the amount of physical memory in the system by executing the # command "sysctl -n hw.memsize" using subprocess.check_output, # taking the result, which is a string that gives the amount of # memory in bytes, converting the string to an integer, and then # converting that number to GB. # # Created: 2013-10-24 # Version: 0.1 import subprocess def hwmemsize(): memory = int(subprocess.check_output(["sysctl", "-n", "hw.memsize"])) return memory print hwmemsize() / 1024 / 1024 / 1024, "GB"