diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4b72a..82e70fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ ### Bug fixes +## spacesavers2 v0.12.1 + +### New features + +- adding uid, human_readable_bytes and percent columns to `pdq` output + +### Bug fixes + +- type fix "quite" to "quiet" + ## spacesavers2 v0.12.0 ### New features diff --git a/spacesavers2_catalog b/spacesavers2_catalog index f1836ae..ecb8f09 100755 --- a/spacesavers2_catalog +++ b/spacesavers2_catalog @@ -154,8 +154,8 @@ def main(): ) parser.add_argument( "-q", - "--quite", - dest="quite", + "--quiet", + dest="quiet", required=False, action=argparse.BooleanOptionalAction, help="Do not show progress", @@ -184,7 +184,7 @@ def main(): args = parser.parse_args() tqdm_disable = False - if args.quite: tqdm_disable = True + if args.quiet: tqdm_disable = True global sed sed = dict() diff --git a/spacesavers2_e2e b/spacesavers2_e2e index d574326..ebb9823 100755 --- a/spacesavers2_e2e +++ b/spacesavers2_e2e @@ -59,7 +59,8 @@ spacesavers2_catalog \ --outfile ${outfile_catalog} \ --bottomhash \ --brokenlink \ - --geezers --quite + --geezers \ + --quiet EOF ) echo $cmd @@ -138,4 +139,4 @@ fi done -echo "Done!" \ No newline at end of file +echo "Done!" diff --git a/spacesavers2_pdq b/spacesavers2_pdq index a129eb5..89f0532 100755 --- a/spacesavers2_pdq +++ b/spacesavers2_pdq @@ -16,7 +16,7 @@ from multiprocessing import Pool import argparse from pathlib import Path import json -import os +import pandas as pd def task(f): @@ -82,8 +82,8 @@ def main(): ) parser.add_argument( "-q", - "--quite", - dest="quite", + "--quiet", + dest="quiet", required=False, action=argparse.BooleanOptionalAction, help="Do not show progress", @@ -98,7 +98,7 @@ def main(): dirs = [p] tqdm_disable = False - if args.quite: tqdm_disable = True + if args.quiet: tqdm_disable = True # files = [p] # files2 = p.glob("**/*") # files.extend(files2) @@ -127,6 +127,8 @@ def main(): outdict=dict() outdict[str(p)]=dict() + col_names = ['uid', 'username', 'ninodes', 'nbytes', 'human_readable'] + df = pd.DataFrame(columns = col_names) for uid in bigdict.keys(): username = get_username_groupname(uid) @@ -138,8 +140,27 @@ def main(): outdict[str(p)][str(uid)]['username']=username outdict[str(p)][str(uid)]['ninodes']=ninodes outdict[str(p)][str(uid)]['nbytes']=nbytes - outfh.write(f"{username}\t{ninodes}\t{nbytes}\n") - + my_dict = {'uid':uid, + 'username':username, + 'ninodes':ninodes, + 'nbytes':nbytes, + 'human_readable':get_human_readable_size(nbytes)} + df.loc[len(df)] = my_dict + # outfh.write(f"{username}\t{ninodes}\t{nbytes}\n") + + total_ninodes = df['ninodes'].sum() + total_nbytes = df['nbytes'].sum() + total_humanreadable = get_human_readable_size(total_nbytes) + my_dict = { 'uid':0, + 'username':'allusers', + 'ninodes':total_ninodes , + 'nbytes':total_nbytes, + 'human_readable':total_humanreadable} + df.loc[len(df)] = my_dict + df.sort_values(by=['nbytes'],ascending=False,inplace=True) + df['percent'] = df['nbytes'] * 100.0 / total_nbytes + df['percent'] = df['percent'].apply(lambda x: float("{:.2f}".format(x))) + df.to_csv(outfh,sep="\t",index=False) if args.json: json.dump(outdict,outjson,indent=1) outjson.close() diff --git a/src/VERSION b/src/VERSION index d33c3a2..34a8361 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -0.12.0 \ No newline at end of file +0.12.1