Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of progress listener #46

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 18 additions & 14 deletions b2/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ def _setup_parser(cls, parser):
def run(self, args):
progress_listener = make_progress_listener(args.localFileName, args.noProgress)
download_dest = DownloadDestLocalFile(args.localFileName)
self.api.download_file_by_id(args.fileId, download_dest, progress_listener)
with progress_listener:
self.api.download_file_by_id(args.fileId, download_dest, progress_listener)
self.console_tool._print_download_info(download_dest)
return 0

Expand Down Expand Up @@ -669,7 +670,8 @@ def run(self, args):
bucket = self.api.get_bucket_by_name(args.bucketName)
progress_listener = make_progress_listener(args.localFileName, args.noProgress)
download_dest = DownloadDestLocalFile(args.localFileName)
bucket.download_file_by_name(args.b2FileName, download_dest, progress_listener)
with progress_listener:
bucket.download_file_by_name(args.b2FileName, download_dest, progress_listener)
self.console_tool._print_download_info(download_dest)
return 0

Expand Down Expand Up @@ -1442,18 +1444,20 @@ def run(self, args):
self.api.services.upload_manager.set_thread_pool_size(args.threads)

bucket = self.api.get_bucket_by_name(args.bucketName)
file_info = bucket.upload_local_file(
local_file=args.localFilePath,
file_name=args.b2FileName,
content_type=args.contentType,
file_infos=file_infos,
sha1_sum=args.sha1,
min_part_size=args.minPartSize,
progress_listener=make_progress_listener(args.localFilePath, args.noProgress),
)
if not args.quiet:
self._print("URL by file name: " + bucket.get_download_url(args.b2FileName))
self._print("URL by fileId: " + self.api.get_download_url_for_fileid(file_info.id_))
progress_listener = make_progress_listener(args.localFilePath, args.noProgress)
with progress_listener:
file_info = bucket.upload_local_file(
local_file=args.localFilePath,
file_name=args.b2FileName,
content_type=args.contentType,
file_infos=file_infos,
sha1_sum=args.sha1,
min_part_size=args.minPartSize,
progress_listener=progress_listener,
)
if not args.quiet:
self._print("URL by file name: " + bucket.get_download_url(args.b2FileName))
self._print("URL by fileId: " + self.api.get_download_url_for_fileid(file_info.id_))
self._print_json(file_info)
return 0

Expand Down
5 changes: 3 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def unit(session):
'pytest', '--cov=b2', '--cov-branch', '--cov-report=xml', '--doctest-modules',
*session.posargs, 'test/unit'
)
session.notify('cover')
if not session.posargs:
session.notify('cover')


@nox.session(python=PYTHON_VERSIONS)
Expand All @@ -138,7 +139,7 @@ def test(session):
def cover(session):
"""Perform coverage analysis."""
session.install('coverage')
session.run('coverage', 'report', '--fail-under=75', '--show-missing')
session.run('coverage', 'report', '--fail-under=75', '--show-missing', '--skip-covered')
session.run('coverage', 'erase')


Expand Down