Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion anaconda_project/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
import zipfile
from io import BytesIO
from conda_pack._progress import progressbar
from tqdm import tqdm

from anaconda_project.frontend import _new_error_recorder
from anaconda_project.frontend import NullFrontend, _new_error_recorder
from anaconda_project.internal import logged_subprocess
from anaconda_project.internal.simple_status import SimpleStatus
from anaconda_project.internal.directory_contains import subdirectory_relative_to_directory
Expand Down Expand Up @@ -451,6 +452,8 @@ def _extract_files_zip(zip_path, src_and_dest, frontend):
try:
with zipfile.ZipFile(zip_path, mode='r') as zf:
_extractall_chmod(zf, tmpdir)
if isinstance(frontend.underlying, NullFrontend):
src_and_dest = tqdm(src_and_dest, desc='Extract ')
for (src, dest) in src_and_dest:
frontend.info("Unpacking %s to %s" % (src, dest))
src_path = os.path.join(tmpdir, src)
Expand All @@ -469,6 +472,8 @@ def _extract_files_zip(zip_path, src_and_dest, frontend):

def _extract_files_tar(tar_path, src_and_dest, frontend):
with tarfile.open(tar_path, mode='r') as tf:
if isinstance(frontend.underlying, NullFrontend):
src_and_dest = tqdm(src_and_dest, desc='Extract ')
for (src, dest) in src_and_dest:
frontend.info("Unpacking %s to %s" % (src, dest))
member = tf.getmember(src)
Expand Down
13 changes: 8 additions & 5 deletions anaconda_project/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import re
import tarfile
import zipfile
from tqdm import tqdm

import requests
import binstar_client.utils as binstar_utils
Expand Down Expand Up @@ -182,14 +183,16 @@ def download(self, project, project_dir=None, parent_dir=None):
filename = eval(re.findall("filename=(.+);", res.headers["Content-Disposition"])[0])
if parent_dir:
filename = os.path.join(parent_dir, filename)
print('Downloading {}'.format(project))
print('.', end='')
progress = tqdm(unit='KiB',
total=int(res.headers.get('Content-Length', None)) / 1024,
unit_scale=True,
desc='Download')
with open(filename, 'wb') as f:
for chunk in res.iter_content(chunk_size=4096):
for chunk in res.iter_content(chunk_size=1024):
if chunk:
print('.', end='')
progress.update(len(chunk) / 1024)
f.write(chunk)
print()
progress.close()
self._check_response(res)
return os.path.abspath(filename)

Expand Down