Skip to content

Commit e88028b

Browse files
author
gaa-cifasis
committed
added progress bar code
1 parent 3d1cf7d commit e88028b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

vdiscover/Utils.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,34 @@
1616
1717
Copyright 2014 by G.Grieco
1818
"""
19-
19+
import sys
20+
import time
2021
import gzip
2122
import subprocess
2223
import pickle
2324
import csv
2425
import random
2526

27+
28+
def update_progress(progress):
29+
barLength = 30 # Modify this to change the length of the progress bar
30+
status = ""
31+
if isinstance(progress, int):
32+
progress = float(progress)
33+
if not isinstance(progress, float):
34+
progress = 0
35+
status = "error: progress var must be float\r\n"
36+
if progress < 0:
37+
progress = 0
38+
status = "Halt...\r\n"
39+
if progress >= 1:
40+
progress = 1
41+
status = "Done...\r\n"
42+
block = int(round(barLength*progress))
43+
text = "\rPercent: [{0}] {1}% {2}".format( "#"*block + "-"*(barLength-block), progress*100, status)
44+
sys.stdout.write(text)
45+
sys.stdout.flush()
46+
2647
def file_len(fname):
2748

2849
if ".gz" in fname:

0 commit comments

Comments
 (0)