34 lines
888 B
Python
34 lines
888 B
Python
import argparse
|
|
import os
|
|
from time import sleep
|
|
|
|
def main():
|
|
args = get_args()
|
|
buckets = {}
|
|
with open(args.p, "r") as f:
|
|
f.seek(0, os.SEEK_END)
|
|
while True:
|
|
line = f.readline().strip()
|
|
if not line:
|
|
sleep(0.25)
|
|
continue
|
|
key = line.strip("/").split()[0]
|
|
if not key in buckets:
|
|
buckets[key] = False
|
|
buckets[key] = False if line[0] == "/" else float(line.split()[-1])
|
|
print(
|
|
"[",
|
|
" ".join(sorted([
|
|
"{:2}={}".format(int(100*buckets[i]), i) for i in buckets if buckets[i]
|
|
], reverse=True)),
|
|
"]",
|
|
)
|
|
|
|
def get_args():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt")
|
|
return ap.parse_args()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|