Skip to content

Commit 3c345c4

Browse files
kartbennordicjm
authored andcommitted
[nrf fromtree] scripts: west_commands: canopen: replace progress by tqdm
progress has been unmaintained for years and tqdm is a more modern and faster alternative, which is already used by other commands. Replace progress by tqdm in the canopen_program.py script. Signed-off-by: Benjamin Cabé <[email protected]> (cherry picked from commit 0ed775b)
1 parent 68ea99f commit 3c345c4

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

scripts/requirements-actions.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mock
1717
mypy
1818
natsort
1919
ply>=3.10
20-
progress
2120
psutil>=5.6.6
2221
pyelftools>=0.29
2322
pygithub
@@ -36,6 +35,7 @@ sphinx-lint
3635
tabulate
3736
tomli>=1.1.0
3837
tox
38+
tqdm>=4.67.1
3939
unidiff
4040
vermin
4141
west>=0.14.0

scripts/requirements-actions.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ colorama==0.4.6 \
261261
# pylint
262262
# pytest
263263
# tox
264+
# tqdm
264265
# west
265266
cryptography==45.0.5 \
266267
--hash=sha256:0027d566d65a38497bc37e0dd7c2f8ceda73597d2ac9ba93810204f56f52ebc7 \
@@ -797,10 +798,6 @@ polib==1.2.0 \
797798
--hash=sha256:1c77ee1b81feb31df9bca258cbc58db1bbb32d10214b173882452c73af06d62d \
798799
--hash=sha256:f3ef94aefed6e183e342a8a269ae1fc4742ba193186ad76f175938621dbfc26b
799800
# via sphinx-lint
800-
progress==1.6.1 \
801-
--hash=sha256:5239f22f305c12fdc8ce6e0e47f70f21622a935e16eafc4535617112e7c7ea0b \
802-
--hash=sha256:c1ba719f862ce885232a759eab47971fe74dfc7bb76ab8a51ef5940bad35086c
803-
# via -r requirements-actions.in
804801
psutil==7.0.0 \
805802
--hash=sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25 \
806803
--hash=sha256:1e744154a6580bc968a0195fd25e80432d3afec619daf145b9e5ba16cc1d688e \
@@ -1231,6 +1228,10 @@ tox==4.27.0 \
12311228
--hash=sha256:2b8a7fb986b82aa2c830c0615082a490d134e0626dbc9189986da46a313c4f20 \
12321229
--hash=sha256:b97d5ecc0c0d5755bcc5348387fef793e1bfa68eb33746412f4c60881d7f5f57
12331230
# via -r requirements-actions.in
1231+
tqdm==4.67.1 \
1232+
--hash=sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2 \
1233+
--hash=sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2
1234+
# via -r requirements-actions.in
12341235
typing-extensions==4.14.0 \
12351236
--hash=sha256:8676b788e32f02ab42d9e7c61324048ae4c6d844a399eebace3d4979d75ceef4 \
12361237
--hash=sha256:a1514509136dd0b477638fc68d6a91497af5076466ad0fa6c338e44e359944af

scripts/requirements-base.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pykwalify
1616
# used by west_commands
1717
canopen
1818
packaging
19-
progress
2019
patool>=2.0.0
2120
psutil>=5.6.6
2221
pylink-square

scripts/west_commands/runners/canopen_program.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
try:
1414
import canopen
15-
from progress.bar import Bar
15+
from tqdm import tqdm
1616
MISSING_REQUIREMENTS = False
1717
except ImportError:
1818
MISSING_REQUIREMENTS = True
@@ -284,17 +284,17 @@ def download(self, bin_file):
284284
outfile = self.data_sdo.open('wb', buffering=self.download_buffer_size,
285285
size=size, block_transfer=self.block_transfer)
286286

287-
progress = Bar('%(percent)d%%', max=size, suffix='%(index)d/%(max)dB')
287+
progress = tqdm(total=size, unit='B', unit_scale=True)
288288
while True:
289289
chunk = infile.read(self.download_buffer_size // 2)
290290
if not chunk:
291291
break
292292
outfile.write(chunk)
293-
progress.next(n=len(chunk))
293+
progress.update(len(chunk))
294294
except Exception as err:
295295
raise ValueError('Failed to download program') from err
296296
finally:
297-
progress.finish()
297+
progress.close()
298298
infile.close()
299299
outfile.close()
300300

0 commit comments

Comments
 (0)