mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
add free space of default save_path
This commit is contained in:
parent
dc49a43e70
commit
6465c8eede
1 changed files with 20 additions and 0 deletions
|
@ -384,3 +384,23 @@ def get_path_size(path):
|
||||||
filename = os.path.join(p, file)
|
filename = os.path.join(p, file)
|
||||||
dir_size += os.path.getsize(filename)
|
dir_size += os.path.getsize(filename)
|
||||||
return dir_size
|
return dir_size
|
||||||
|
|
||||||
|
def free_space()
|
||||||
|
"""returns free space in each partition"""
|
||||||
|
"""example: {PARTITION: [TOTAL, AVAIL]}"""
|
||||||
|
space = {}
|
||||||
|
if windows_check():
|
||||||
|
import win32api
|
||||||
|
drive = get_default_download_dir().split(":")[0]
|
||||||
|
free = win32api.GetDiskFreeSpaceEx(drive)[0]
|
||||||
|
total = win32api.GetDiskFreeSpaceEx(drive)[1]
|
||||||
|
space[drive] = [total, free]
|
||||||
|
else:
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
import re
|
||||||
|
whitespace_spliter = re.compile("\s+")
|
||||||
|
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…
Add table
Add a link
Reference in a new issue