| 1 |
#!/bin/sh |
| 2 |
"""": # -*-python-*- |
| 3 |
bup_exec="$(dirname "$0")/bup-exec" || exit $? |
| 4 |
exec "$bup_exec" "$0" ${1+"$@"} |
| 5 |
""" |
| 6 |
|
| 7 |
from __future__ import absolute_import, print_function |
| 8 |
|
| 9 |
from os.path import getsize, isdir |
| 10 |
from sys import stderr |
| 11 |
import os |
| 12 |
|
| 13 |
from bup.compat import get_argvb |
| 14 |
|
| 15 |
|
| 16 |
def listdir_failure(ex): |
| 17 |
raise ex |
| 18 |
|
| 19 |
def usage(): |
| 20 |
print('Usage: data-size PATH ...', file=sys.stderr) |
| 21 |
|
| 22 |
total = 0 |
| 23 |
for path in get_argvb()[1:]: |
| 24 |
if isdir(path): |
| 25 |
for root, dirs, files in os.walk(path, onerror=listdir_failure): |
| 26 |
total += sum(getsize(os.path.join(root, name)) for name in files) |
| 27 |
else: |
| 28 |
total += getsize(path) |
| 29 |
|
| 30 |
print(total) |