Browse Source

Added progress for emoji downloading

sh4nks 10 years ago
parent
commit
53ddfbe5d9
2 changed files with 9 additions and 2 deletions
  1. 1 1
      Makefile
  2. 8 1
      manage.py

+ 1 - 1
Makefile

@@ -12,7 +12,7 @@ clean:
 	    find . -name '*~' -exec rm -f {} +
 	    find . -name '__pycache__' -exec rm -rf {} +
 
-tests:
+test:
 	    py.test --cov=flaskbb --cov-report=term-missing tests
 
 run:

+ 8 - 1
manage.py

@@ -290,6 +290,8 @@ def download_emoji():
 
     response = requests.get(FULL_URL)
 
+    cached_count = 0
+    count = 0
     for image in response.json():
         if not os.path.exists(os.path.abspath(DOWNLOAD_PATH)):
             print("{} does not exist.".format(os.path.abspath(DOWNLOAD_PATH)))
@@ -297,11 +299,16 @@ def download_emoji():
 
         full_path = os.path.join(DOWNLOAD_PATH, image["name"])
         if not os.path.exists(full_path):
+            count += 1
             f = open(full_path, 'wb')
             f.write(requests.get(image["download_url"]).content)
             f.close()
+            if count == cached_count+50:
+                cached_count = count
+                print("{} out of {} Emojis downloaded...".format(
+                      cached_count, len(response.json())))
 
-    print("Finshed downloading emojis.")
+    print("Finished downloading {} Emojis.".format(count))
 
 if __name__ == "__main__":
     manager.run()