def stats(): """ Get repository statistics. """ def fsize_fmt(num, suffix='b'): """ Format an integer into 1024-block file size format. Adapted from Python 2 code on https://stackoverflow.com/a/1094933/3758232 :param int num: Size value in bytes. :param string suffix: Suffix label (defaults to `B`). @return string Formatted size to largest fitting unit. """ for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']: if abs(num) < 1024.0: return "{:3.1f} {}{}".format(num, unit, suffix) num /= 1024.0 return "{:.1f} {}{}".format(num, 'Y', suffix) repo_stats = admin_api.stats() return render_template('stats.html', fsize_fmt=fsize_fmt, **repo_stats)
def stats(): """ Get repository statistics. """ repo_stats = admin_api.stats() return render_template( 'stats.html', fsize_fmt=fsize_fmt, **repo_stats)
def stats(human=False): """ Print repository statistics. @param human (bool) Whether to output the data in human-readable format. """ stat_data = admin_api.stats() if human: click.echo( 'This option is not supported yet. Sorry.\nUse the `/admin/stats`' ' endpoint in the web UI for a pretty printout.') else: click.echo(json.dumps(stat_data))