summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2003-06-23 20:36:14 +0000
committerMike Fulbright <msf@redhat.com>2003-06-23 20:36:14 +0000
commitc9654ad60c634820fdeeb32b475622bd10c4a78f (patch)
tree0302c75897dfabdfb48ff5a586d17d3ce4201e5b /iutil.py
parent92d1ca6f00f2823e7f9b9460b4597d7b5fd226b3 (diff)
downloadanaconda-c9654ad60c634820fdeeb32b475622bd10c4a78f.tar.gz
anaconda-c9654ad60c634820fdeeb32b475622bd10c4a78f.tar.xz
anaconda-c9654ad60c634820fdeeb32b475622bd10c4a78f.zip
slight change in memory sniffing routines. memInstalled() returns amount plugged into the motherboard. Removed unused corrected mode. The function memAvailable() returns amount of RAM left over after allocation to ramfs fs in /tmp.
Diffstat (limited to 'iutil.py')
-rw-r--r--iutil.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/iutil.py b/iutil.py
index 99659361a..bc663b51d 100644
--- a/iutil.py
+++ b/iutil.py
@@ -188,9 +188,34 @@ def copyFile(source, to, pw = None):
if pw:
win.pop()
+# return size of directory (and subdirs) in kilobytes
+def getDirSize(dir):
+ def getSubdirSize(dir):
+ # returns size in bytes
+ dsize = 0
+ for f in os.listdir(dir):
+ curpath = '%s/%s' % (dir, f)
+ sinfo = os.stat(curpath)
+ if stat.S_ISDIR(sinfo[stat.ST_MODE]):
+ dsize += getSubdirSize(curpath)
+ elif stat.S_ISREG(sinfo[stat.ST_MODE]):
+ dsize += sinfo[stat.ST_SIZE]
+ else:
+ pass
+
+ return dsize
+ return getSubdirSize(dir)/1024
+
+# this is in kilobytes - returns amount of RAM not used by /tmp
+def memAvailable():
+ tram = memInstalled()
+
+ ramused = getDirSize("/tmp")
+
+ return tram - ramused
# this is in kilobytes
-def memInstalled(corrected = 1):
+def memInstalled():
if not os.access('/proc/e820info', os.R_OK):
f = open("/proc/meminfo", "r")
mem = f.readlines()[1]
@@ -206,12 +231,12 @@ def memInstalled(corrected = 1):
fields = string.split(line)
if fields[3] == "(usable)":
mem = mem + (string.atol(fields[0], 16) / 1024)
-
+
return int(mem)
# try to keep 2.4 kernel swapper happy!
def swapSuggestion(quiet=0):
- mem = memInstalled(corrected=0)/1024
+ mem = memInstalled()/1024
mem = ((mem/16)+1)*16
if not quiet:
log("Detected %sM of memory", mem)