diff options
author | Clay Gerrard <clay.gerrard@gmail.com> | 2013-10-09 12:03:50 -0700 |
---|---|---|
committer | Clay Gerrard <clay.gerrard@gmail.com> | 2013-10-09 14:31:47 -0700 |
commit | d687060a44763cfe944343bc2c8b2d2d543eb26f (patch) | |
tree | cda056285723d35ac14dfd2ed1f6b0b5f5bacdc5 /swiftclient/multithreading.py | |
parent | 0cded7cfed9c2840b8a9538b03ccb2b72065aafc (diff) | |
download | python-swiftclient-d687060a44763cfe944343bc2c8b2d2d543eb26f.tar.gz |
Add verbose output to all stat commands
When you stat a container or object with the verbose flag the full path of the
reousrce will be displayed with the token similarlly to how an account stat
displays the auth url and token.
* move some logic out of bin/swift.st_stat to test it
* new module swiftclient.commnad_helpers for code you want to test
* moved prt_bytes into swiftclient.utils to test it
* fixed IndexError with prt_bytes on sizes >= 1024Y
Change-Id: Iaaa96e0308b08c554205b0055b8a04de581fefa4
Diffstat (limited to 'swiftclient/multithreading.py')
-rw-r--r-- | swiftclient/multithreading.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/swiftclient/multithreading.py b/swiftclient/multithreading.py index 890a789..512c6e1 100644 --- a/swiftclient/multithreading.py +++ b/swiftclient/multithreading.py @@ -12,6 +12,7 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +from itertools import chain import sys from time import sleep from Queue import Queue @@ -224,6 +225,29 @@ class MultiThreadingManager(object): msg = msg % fmt_args self.printer.queue.put(msg) + def print_items(self, items, offset=14, skip_missing=False): + lines = [] + template = '%%%ds: %%s' % offset + for k, v in items: + if skip_missing and not v: + continue + lines.append((template % (k, v)).rstrip()) + self.print_msg('\n'.join(lines)) + + def print_headers(self, headers, meta_prefix='', exclude_headers=None, + offset=14): + exclude_headers = exclude_headers or [] + meta_headers = [] + other_headers = [] + template = '%%%ds: %%s' % offset + for key, value in headers.items(): + if key.startswith(meta_prefix): + meta_key = 'Meta %s' % key[len(meta_prefix):].title() + meta_headers.append(template % (meta_key, value)) + elif key not in exclude_headers: + other_headers.append(template % (key.title(), value)) + self.print_msg('\n'.join(chain(meta_headers, other_headers))) + def error(self, msg, *fmt_args): if fmt_args: msg = msg % fmt_args |