Repository: CS-SI/eodag (python)

Issue:
progress bar and int id
If product id is an integer, it makes download progress bar crash:
```py
>>> from eodag import EODataAccessGateway                                                                                                                                                                                                    
>>> dag = EODataAccessGateway()                                                                                                                                                                                                              
>>> dag.set_preferred_provider("usgs")                                                                                                                                                                                                       
>>> prods, _ = dag.search(productType="SENTINEL_2A")
>>> prods[0].properties["id"]
18933649                                                                                                                                                                                                                                     
>>> prods[0].download()
                                                                                                                                                                                                                                             
Traceback (most recent call last):                                                                                                                                                                                                           
  File "<stdin>", line 1, in <module>                                                                                                                                                                                                        
  File "/home/sylvain/workspace/eodag/eodag/api/product/_product.py", line 286, in download                                                                                                                                                  
    progress_callback.refresh()
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1361, in refresh
    self.display()
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1509, in display
    self.sp(self.__str__() if msg is None else msg)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1165, in __str__
    return self.format_meter(**self.format_dict)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 475, in format_meter
    bool_prefix_colon_already = (prefix[-2:] == ": ")
TypeError: 'int' object is not subscriptable
```

It should be cast to `str` before set as progress bar prefix.

Pull request:
fix: id cast to str in progress_callback
Fixes #488 


Patch:
diff --git a/eodag/api/product/_product.py b/eodag/api/product/_product.py
index 683870ba..45162a1f 100644
--- a/eodag/api/product/_product.py
+++ b/eodag/api/product/_product.py
@@ -282,7 +282,7 @@ class EOProduct(object):
             # update units as bar may have been previously used for extraction
             progress_callback.unit = "B"
             progress_callback.unit_scale = True
-        progress_callback.desc = self.properties.get("id", "")
+        progress_callback.desc = str(self.properties.get("id", ""))
         progress_callback.refresh()
 
         fs_path = self.downloader.download(


Test patch:
diff --git a/tests/units/test_eoproduct.py b/tests/units/test_eoproduct.py
index 7829c168..045edf0d 100644
--- a/tests/units/test_eoproduct.py
+++ b/tests/units/test_eoproduct.py
@@ -34,6 +34,7 @@ from tests.context import (
     EOProduct,
     HTTPDownload,
     NoDriver,
+    ProgressCallback,
     config,
 )
 from tests.utils import mock
@@ -44,6 +45,12 @@ class TestEOProduct(EODagTestCase):
 
     def setUp(self):
         super(TestEOProduct, self).setUp()
+        self.output_dir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        super(TestEOProduct, self).tearDown()
+        if os.path.isdir(self.output_dir):
+            shutil.rmtree(self.output_dir)
 
     def test_eoproduct_search_intersection_geom(self):
         """EOProduct search_intersection attr must be it's geom when no bbox_or_intersect param given"""  # noqa
@@ -383,3 +390,26 @@ class TestEOProduct(EODagTestCase):
         finally:
             # Teardown (all the created files are within outputs_prefix)
             shutil.rmtree(output_dir)
+
+    def test_eoproduct_download_progress_bar(self):
+        """eoproduct.download must show a progress bar"""
+        product = self._dummy_downloadable_product()
+        product.properties["id"] = 12345
+        progress_callback = ProgressCallback()
+
+        # progress bar did not start
+        self.assertEqual(progress_callback.n, 0)
+
+        # extract=true would replace bar desc with extraction status
+        product.download(
+            progress_callback=progress_callback,
+            outputs_prefix=self.output_dir,
+            extract=False,
+        )
+
+        # should be product id cast to str
+        self.assertEqual(progress_callback.desc, "12345")
+
+        # progress bar finished
+        self.assertEqual(progress_callback.n, progress_callback.total)
+        self.assertGreater(progress_callback.total, 0)