Skip to content

Commit

Permalink
trying to make simple speed bar
Browse files Browse the repository at this point in the history
  • Loading branch information
davedavemckay committed Oct 31, 2024
1 parent 866c6ba commit 270494f
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions csd3-side/scripts/backup_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,37 @@
if 'Folders: ' in line and ' Files: ' in line:
total = int(line.split()[3].strip())
break
with tqdm.tqdm(total=total, desc='Upload Progress (file count)') as pbar:
progress = 0
prev_len = 0
while True:
with open(logcsv, 'r') as logc:
if len(logc.readlines()) - 1 > prev_len:
logc.seek(0)
prev_len = len(logc.readlines()) - 1
logc.seek(0)
else:
continue
prog = 0
for line in logc:
if 'collated_' in line:
prog += len(line.split('"')[-2].split(','))
elif 'LOCAL_FOLDER' not in line:
prog += 1
pbar.update(prog - progress)
progress = prog

progress = 0
prev_len = 0
prev_total_size = 0
started = False

while True:
if prev_len > 0 and prev_total_size > 0 and not started:
pbar_count = tqdm.tqdm(total=total, desc='Upload Progress (file count)', position=tqdm._get_free_pos())
pbar_size = tqdm.tqdm(total=0, desc='Upload Progress (file size / MiB)', position=tqdm._get_free_pos())
started = True
with open(logcsv, 'r') as logc:
if len(logc.readlines()) - 1 > prev_len:
logc.seek(0)
prev_len = len(logc.readlines()) - 1
logc.seek(0)
else:
continue
prog = 0
total_size = 0
for line in logc:
if 'collated_' in line:
prog += len(line.split('"')[-2].split(','))
elif not 'LOCAL_FOLDER' in line:
prog += 1
if not 'LOCAL_FOLDER' in line:
total_size += int(line.split(',')[2])
if total_size > prev_total_size:
prev_total_size = total_size
if started:
pbar_count.update(prog - progress)
pbar_size.update((total_size - prev_total_size) / (1024 * 1024))
progress = prog
prev_total_size = total_size

0 comments on commit 270494f

Please sign in to comment.