예제 #1
0
파일: filesystem.py 프로젝트: Qumulo/qutil
def du(conn, credentials, path, verbose=False):
    'Prints out capacity usage for the directory.'
    response = fs.read_dir_aggregates(conn, credentials, path.remote())[0]
    size = metricize(int(response['total_capacity']), 'B')

    mypath = path.remote()
    if path.complete:
        mypath = path.local()

    if verbose:
        print('{0: >10s}    {1}'.format(bold(size), mypath))

        filecount = metricize(int(response['total_files']))
        dircount = metricize(int(response['total_directories']))
        print('    {0} files, {1} directories'.format(filecount, dircount))
    else:
        print('{0: >10s}    {1}'.format(bold(size), mypath))
예제 #2
0
파일: timeseries.py 프로젝트: Qumulo/qutil
def statline(statname, statvalue, abbrev=''):
    'Returns a single formatted statistics line, suitable for statcol()'
    # It would be easier to just ''.format the dots, but ANSI
    # codes change the effective length of the string, which
    # makes everything weird.
    dots = '.' * (13 - len(statname))
    statname = bold(statname) + dots
    statvalue = '{0:.>9s}'.format(metricize(statvalue, abbrev))

    return statname + statvalue