forked from coqui-ai/STT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove deprecased tensorflow.contrib.learn.python.learn.datasets.base…
….maybe_download Fixes coqui-ai#1531 Fixes coqui-ai#1477
- Loading branch information
Alexandre Lissy
committed
Oct 2, 2018
1 parent
8f62bec
commit 94b8c5c
Showing
6 changed files
with
47 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import requests | ||
import progressbar | ||
|
||
from os import path, makedirs | ||
|
||
SIMPLE_BAR = ['Progress ', progressbar.Bar(), ' ', progressbar.Percentage(), ' completed'] | ||
|
||
def maybe_download(archive_name, target_dir, archive_url): | ||
# If archive file does not exist, download it... | ||
archive_path = path.join(target_dir, archive_name) | ||
|
||
if not path.exists(target_dir): | ||
print('No path "%s" - creating ...' % target_dir) | ||
makedirs(target_dir) | ||
|
||
if not path.exists(archive_path): | ||
print('No archive "%s" - downloading...' % archive_path) | ||
req = requests.get(archive_url, stream=True) | ||
total_size = int(req.headers.get('content-length', 0)) | ||
done = 0 | ||
with open(archive_path, 'wb') as f: | ||
bar = progressbar.ProgressBar(max_value=total_size, widgets=SIMPLE_BAR) | ||
for data in req.iter_content(1024*1024): | ||
done += len(data) | ||
f.write(data) | ||
bar.update(done) | ||
else: | ||
print('Found archive "%s" - not downloading.' % archive_path) | ||
return archive_path |