[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a
Garrett Holmstrom
gholms at fedoraproject.org
Sun Jun 16 02:31:09 UTC 2013
The following commit has been merged in the master branch:
commit dba3c704e47fcd1ef2d7c64737e2e06f3bbe3f61
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Thu Apr 25 23:37:31 2013 -0700
Port PutObject to progress bar mixin
diff --git a/euca2ools/commands/bundle/uploadbundle.py b/euca2ools/commands/bundle/uploadbundle.py
index 166ba3f..63bcb4d 100644
--- a/euca2ools/commands/bundle/uploadbundle.py
+++ b/euca2ools/commands/bundle/uploadbundle.py
@@ -108,7 +108,7 @@ class UploadBundle(WalrusRequest, FileTransferProgressBarMixin):
req = PutObject(sources=part_paths, dest=full_prefix,
acl=self.args['acl'],
retries=self.args.get('retries', 1),
- progress=self.args.get('show_progress', False),
+ show_progress=self.args.get('show_progress', False),
config=self.config, service=self.service)
req.main()
@@ -117,7 +117,8 @@ class UploadBundle(WalrusRequest, FileTransferProgressBarMixin):
dest=full_prefix,
acl=self.args['acl'],
retries=self.args.get('retries', 1),
- progress=self.args.get('show_progress', False),
+ show_progress=self.args.get('show_progress',
+ False),
config=self.config, service=self.service)
req.main()
manifest_loc = full_prefix + os.path.basename(self.args['manifest'])
diff --git a/euca2ools/commands/walrus/putobject.py b/euca2ools/commands/walrus/putobject.py
index 434e139..5646417 100644
--- a/euca2ools/commands/walrus/putobject.py
+++ b/euca2ools/commands/walrus/putobject.py
@@ -34,13 +34,14 @@ import mimetypes
import os.path
from requestbuilder import Arg
from requestbuilder.exceptions import ArgumentError, ClientError
+from requestbuilder.mixins import FileTransferProgressBarMixin
import socket
import sys
import threading
import time
-class PutObject(WalrusRequest):
+class PutObject(WalrusRequest, FileTransferProgressBarMixin):
DESCRIPTION = ('Upload objects to the server\n\nNote that uploading a '
'large file to a region other than the one the bucket is '
'may result in "Broken pipe" errors or other connection '
@@ -61,9 +62,7 @@ class PutObject(WalrusRequest):
uploaded'''),
Arg('--retry', dest='retries', action='store_const', const=5,
default=1, route_to=None,
- help='retry interrupted uploads up to 5 times'),
- Arg('--progress', action='store_true', route_to=None,
- help='show upload progress')]
+ help='retry interrupted uploads up to 5 times')]
METHOD = 'PUT'
def __init__(self, **kwargs):
@@ -83,7 +82,7 @@ class PutObject(WalrusRequest):
def main(self):
sources = list(self.args['sources'])
- template = build_progressbar_label_template(sources)
+ label_template = build_progressbar_label_template(sources)
for index, source_filename in enumerate(sources, 1):
if self.args.get('literal_dest', False):
(bucket, __, keyname) = self.args['dest'].partition('/')
@@ -113,29 +112,15 @@ class PutObject(WalrusRequest):
# more cleanly.
upload_thread.daemon = True
upload_thread.start()
- if self.args['progress']:
- import progressbar
- label = template.format(index=index,
- fname=os.path.basename(source_filename))
- widgets = [label, ' ', progressbar.Percentage(),
- ' ', progressbar.Bar(marker='='), ' ',
- progressbar.FileTransferSpeed(), ' ',
- progressbar.ETA()]
- bar = progressbar.ProgressBar(
- maxval=os.path.getsize(source_filename),
- widgets=widgets)
- bar.start()
- while upload_thread.is_alive():
- bar.update(source.tell())
- time.sleep(0.01)
- bar.finish()
- else:
- # If we don't at least do *something* in the main thread
- # then attempts to kill the program with ^C will only be
- # handled when the current upload completes, which could
- # be minutes away or even longer.
- while upload_thread.is_alive():
- time.sleep(0.01)
+ label = label_template.format(index=index,
+ fname=os.path.basename(source_filename))
+ pbar = self.get_progressbar(label=label,
+ maxval=os.path.getsize(source_filename))
+ pbar.start()
+ while upload_thread.is_alive():
+ pbar.update(source.tell())
+ time.sleep(0.01)
+ pbar.finish()
upload_thread.join()
with self._lock:
if self.last_upload_error is not None:
--
managing cloud instances for Eucalyptus
More information about the pkg-eucalyptus-commits
mailing list