Skip to content

Commit e77f323

Browse files
committed
[datatransfer] updated upload to use rich progress bar
1 parent 5956e05 commit e77f323

File tree

1 file changed

+8
-9
lines changed
  • src/instrumentman/datatransfer

1 file changed

+8
-9
lines changed

src/instrumentman/datatransfer/app.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from io import BufferedWriter, TextIOWrapper
22

33
from serial import SerialTimeoutException
4-
from click_extra import echo, progressbar
4+
from rich.progress import Progress, TextColumn
5+
from click_extra import echo
56
from geocompy.communication import open_serial
67

78
from ..utils import echo_green, echo_red, echo_yellow
@@ -68,15 +69,13 @@ def main_upload(
6869
for _ in range(skip):
6970
next(file)
7071

71-
count = 0
72-
with progressbar(
73-
file,
74-
label="Uploading data",
75-
item_show_func=lambda x: f"{count} line(s)"
76-
) as bar:
77-
for line in bar:
72+
with Progress(
73+
*Progress.get_default_columns(),
74+
TextColumn("{task.completed} line(s)")
75+
) as progress:
76+
for line in progress.track(file, description="Uploading..."):
7877
com.send(line)
79-
count += 1
78+
8079
except Exception as e:
8180
echo_red(f"Upload interrupted by error ({e})")
8281
return

0 commit comments

Comments
 (0)