aboutsummaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py')
-rwxr-xr-xmeta-python/recipes-devtools/python/python3-cryptography/check-memfree.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py b/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py
new file mode 100755
index 0000000000..c9ddddcd31
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+# https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python/28161352
+import sys
+meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
+mem_free = meminfo['MemTotal']/1024./1024.
+if mem_free < 2.:
+ raise("Insufficient free memory({:.3f}): requires > 2 GB".format(mem_free))
+ sys.exit(1)
+else:
+ print("Free memory: {:.3f} GB".format(mem_free))