Skip to content

Instantly share code, notes, and snippets.

@bortkiewicz
Created August 7, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bortkiewicz/8de1e8c6aa38c5c6c5da7a26800af252 to your computer and use it in GitHub Desktop.
Save bortkiewicz/8de1e8c6aa38c5c6c5da7a26800af252 to your computer and use it in GitHub Desktop.
see the disk usage
import os
import os.path
import sys
sys.setrecursionlimit(2147483647)
def disk_usage(path, ind=0):
total = os.path.getsize(path)
if os.path.isdir(path):
for filename in os.listdir(path):
childpath = os.path.join(path, filename)
try:
i = disk_usage(childpath, ind+1)
print(" "*ind + "%s is %s bytes" % (childpath, i))
total += i
except PermissionError:
print(" "*ind + "Permission was denied to %s. Assuming it was 0 bytes." % childpath)
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment