clean up free space
This commit is contained in:
parent
6465c8eede
commit
0712da0fd0
|
@ -385,22 +385,14 @@ def get_path_size(path):
|
||||||
dir_size += os.path.getsize(filename)
|
dir_size += os.path.getsize(filename)
|
||||||
return dir_size
|
return dir_size
|
||||||
|
|
||||||
def free_space()
|
def free_space(path):
|
||||||
"""returns free space in each partition"""
|
"""returns free space"""
|
||||||
"""example: {PARTITION: [TOTAL, AVAIL]}"""
|
|
||||||
space = {}
|
|
||||||
if windows_check():
|
if windows_check():
|
||||||
import win32api
|
import win32api
|
||||||
drive = get_default_download_dir().split(":")[0]
|
drive = path.split(":")[0]
|
||||||
free = win32api.GetDiskFreeSpaceEx(drive)[0]
|
free = win32api.GetDiskFreeSpaceEx(drive)[0]
|
||||||
total = win32api.GetDiskFreeSpaceEx(drive)[1]
|
return fsize(free)
|
||||||
space[drive] = [total, free]
|
|
||||||
else:
|
else:
|
||||||
from subprocess import Popen, PIPE
|
disk_data = os.statvfs(path)
|
||||||
import re
|
block_size = disk_data.f_bsize
|
||||||
whitespace_spliter = re.compile("\s+")
|
return fsize(disk_data.f_bavail * block_size)
|
||||||
output = Popen(["df", "-hP", "--exclude-type=iso9660", "--exclude-type=udf", \
|
|
||||||
"--exclude-type=tmpfs", get_default_download_dir], stdout=PIPE).communicate()[0]
|
|
||||||
modified = whitespace_spliter.split(output.split("\n")[1])
|
|
||||||
space[modified[0]] = [modified[1], modified[3]]
|
|
||||||
return space
|
|
||||||
|
|
Loading…
Reference in New Issue