Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python/28161352 |
| 3 | import sys |
| 4 | meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines()) |
| 5 | mem_free = meminfo['MemTotal']/1024./1024. |
| 6 | if mem_free < 2.: |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 7 | print("Insufficient free memory({:.3f}): requires > 2 GB".format(mem_free)) |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 8 | sys.exit(1) |
| 9 | else: |
| 10 | print("Free memory: {:.3f} GB".format(mem_free)) |