I have a function below, that looks at a path, and determines how much of the disk space is used.
def check_disk_space():
import os
cmdparts = ["echo $(df --output=pcent ", ") | tr -d 'Use% '"]
check_used_disk_space_cmd = cmdparts[0] + "a/path" + cmdparts[1]
os.system(check_used_disk_space_cmd)
def main():
used_disk_space = check_disk_space()
print type( used_disk_space )
if int(used_disk_space) > 80:
print "need more"
else:
print "plennnty!"
print type( used_disk_space )
main()
check_disk_space()
is returning 85
.
Update: it appears check_disk_space() is creating a NoneType
object? I'm getting this error:
TypeError: int() argument must be a string or a number, not 'NoneType'
There are couple of things I changed in your code.
import os
can be moved to top of the fileNOTE: I have added braces to print statement.
Sample Run 1 :
Changed
if condition
from>
to<
to check else condition and it works.Sample Run 2 :