import logging import os.path import sys from wizard import command, scripts def main(argv, baton): options, dirs = parse_args(argv, baton) if not dirs: dir = os.getcwd() else: dir = dirs[0] r = scripts.get_quota_usage_and_limit(dir) if r[0] is None or r[1] is None: sys.exit(1) print "%d %d" % r def parse_args(argv, baton): usage = """usage: %prog quota [DIR] Lists the used quota in bytes for a directory. If a directory is not specified, uses the current working directory. Output format is: USED AVAIL In bytes. Returns an exit code of 1 if quota could not be determined.""" parser = command.WizardOptionParser(usage) options, args = parser.parse_all(argv) if len(args) > 1: parser.error("too many arguments") return options, args