diff --git a/vdiscover/Utils.py b/vdiscover/Utils.py index da2b427..1c4ed59 100644 --- a/vdiscover/Utils.py +++ b/vdiscover/Utils.py @@ -16,13 +16,34 @@ Copyright 2014 by G.Grieco """ - +import sys +import time import gzip import subprocess import pickle import csv import random + +def update_progress(progress): + barLength = 30 # Modify this to change the length of the progress bar + status = "" + if isinstance(progress, int): + progress = float(progress) + if not isinstance(progress, float): + progress = 0 + status = "error: progress var must be float\r\n" + if progress < 0: + progress = 0 + status = "Halt...\r\n" + if progress >= 1: + progress = 1 + status = "Done...\r\n" + block = int(round(barLength*progress)) + text = "\rPercent: [{0}] {1}% {2}".format( "#"*block + "-"*(barLength-block), progress*100, status) + sys.stdout.write(text) + sys.stdout.flush() + def file_len(fname): if ".gz" in fname: