Revision 852a22e7 kamaki/cli/commands/pithos_cli.py
b/kamaki/cli/commands/pithos_cli.py | ||
---|---|---|
502 | 502 |
self).main(container___path, path_is_optional=False) |
503 | 503 |
try: |
504 | 504 |
f = open(local_path, 'r') |
505 |
progress_bar = self.arguments['progress_bar'] |
|
505 | 506 |
try: |
506 |
progress_bar = self.arguments['progress_bar'] |
|
507 | 507 |
upload_cb = progress_bar.get_generator('Appending blocks') |
508 | 508 |
except Exception: |
509 | 509 |
upload_cb = None |
... | ... | |
511 | 511 |
source_file=f, |
512 | 512 |
upload_cb=upload_cb) |
513 | 513 |
except ClientError as err: |
514 |
progress_bar.finish() |
|
514 | 515 |
raiseCLIError(err) |
516 |
finally: |
|
517 |
progress_bar.finish() |
|
515 | 518 |
|
516 | 519 |
|
517 | 520 |
@command(pithos_cmds) |
... | ... | |
541 | 544 |
self).main(container___path, path_is_optional=False) |
542 | 545 |
try: |
543 | 546 |
f = open(local_path, 'r') |
547 |
progress_bar = self.arguments['progress_bar'] |
|
544 | 548 |
try: |
545 |
progress_bar = self.arguments['progress_bar'] |
|
546 | 549 |
upload_cb = progress_bar.get_generator('Overwritting blocks') |
547 | 550 |
except Exception: |
548 | 551 |
upload_cb = None |
... | ... | |
552 | 555 |
source_file=f, |
553 | 556 |
upload_cb=upload_cb) |
554 | 557 |
except ClientError as err: |
558 |
progress_bar.finish() |
|
555 | 559 |
raiseCLIError(err) |
560 |
finally: |
|
561 |
progress_bar.finish() |
|
556 | 562 |
|
557 | 563 |
|
558 | 564 |
@command(pithos_cmds) |
... | ... | |
629 | 635 |
sharing=self.get_argument('sharing'), |
630 | 636 |
public=self.get_argument('public')) |
631 | 637 |
try: |
638 |
progress_bar = self.arguments['progress_bar'] |
|
639 |
hash_bar = progress_bar.clone() |
|
632 | 640 |
with open(local_path) as f: |
633 | 641 |
if self.get_argument('unchunked'): |
634 | 642 |
self.client.upload_object_unchunked(remote_path, f, |
... | ... | |
636 | 644 |
withHashFile=self.get_argument('use_hashes'), |
637 | 645 |
**params) |
638 | 646 |
else: |
639 |
progress_bar = self.arguments['progress_bar'] |
|
640 |
hash_cb = progress_bar.get_generator(\ |
|
647 |
hash_cb = hash_bar.get_generator(\ |
|
641 | 648 |
'Calculating block hashes') |
642 | 649 |
upload_cb = progress_bar.get_generator('Uploading') |
643 | 650 |
self.client.upload_object(remote_path, f, |
644 |
hash_cb=hash_cb, |
|
645 |
upload_cb=upload_cb, |
|
646 |
**params) |
|
651 |
hash_cb=hash_cb, |
|
652 |
upload_cb=upload_cb, |
|
653 |
**params) |
|
654 |
progress_bar.finish() |
|
655 |
hash_bar.finish() |
|
647 | 656 |
except ClientError as err: |
657 |
progress_bar.finish() |
|
658 |
hash_bar.finish() |
|
648 | 659 |
raiseCLIError(err) |
649 | 660 |
except IOError as err: |
650 |
raise CLIError(message='Failed to read form file %s' % local_path, |
|
661 |
progress_bar.finish() |
|
662 |
hash_bar.finish() |
|
663 |
raise CLIError( |
|
664 |
message='Failed to read form file %s' % local_path, |
|
651 | 665 |
importance=2, |
652 | 666 |
details=unicode(err)) |
653 | 667 |
print 'Upload completed' |
... | ... | |
731 | 745 |
raise CLIError(message='Cannot write to file %s - %s'\ |
732 | 746 |
% (local_path, unicode(err)), |
733 | 747 |
importance=1) |
734 |
progress_bar = self.arguments['progress_bar'] |
|
735 |
download_cb = progress_bar.get_generator('Downloading') |
|
736 | 748 |
poolsize = self.get_argument('poolsize') |
737 | 749 |
if poolsize is not None: |
738 | 750 |
self.client.POOL_SIZE = int(poolsize) |
739 | 751 |
|
740 | 752 |
try: |
753 |
progress_bar = self.arguments['progress_bar'] |
|
754 |
download_cb = progress_bar.get_generator('Downloading') |
|
741 | 755 |
self.client.download_object(self.path, out, |
742 | 756 |
download_cb=download_cb, |
743 | 757 |
range=self.get_argument('range'), |
... | ... | |
747 | 761 |
if_none_match=self.get_argument('if_none_match'), |
748 | 762 |
if_modified_since=self.get_argument('if_modified_since'), |
749 | 763 |
if_unmodified_since=self.get_argument('if_unmodified_since')) |
764 |
progress_bar.finish() |
|
750 | 765 |
except ClientError as err: |
766 |
progress_bar.finish() |
|
751 | 767 |
raiseCLIError(err) |
752 | 768 |
except KeyboardInterrupt: |
753 | 769 |
from threading import enumerate as activethreads |
... | ... | |
759 | 775 |
stdout.write('.') |
760 | 776 |
except RuntimeError: |
761 | 777 |
continue |
778 |
progress_bar.finish() |
|
762 | 779 |
print('\ndownload canceled by user') |
763 | 780 |
if local_path is not None: |
764 | 781 |
print('to resume, re-run with --resume') |
782 |
except Exception as e: |
|
783 |
progress_bar.finish() |
|
784 |
raise e |
|
765 | 785 |
|
766 | 786 |
|
767 | 787 |
|
Also available in: Unified diff