summaryrefslogtreecommitdiff
path: root/swiftclient/multithreading.py
diff options
context:
space:
mode:
authorYuan Zhou <yuan.zhou@intel.com>2014-07-31 19:51:50 +0800
committerYuan Zhou <yuan.zhou@intel.com>2014-08-06 16:07:17 +0800
commit776133bd299adfb644f2274143b9fba72672428d (patch)
tree2d76f05f20192657353e2445fe1f082aedcb4d6c /swiftclient/multithreading.py
parentfd1594937d777c0047051ae470e2de5523522171 (diff)
downloadpython-swiftclient-776133bd299adfb644f2274143b9fba72672428d.tar.gz
Clean up raw policy stats in account stat
Storage policy stats was not well parsed in account stat. This patch parses the stats and print out the stats in a format like below: $swift -A http://swift_cluster/auth/v1.0 -U test:tester -K testing stat Account: AUTH_test Containers: 5 Objects: 1 Bytes: 2097152 Objects in policy "golden": 1 Bytess in policy "golden": 2097152 Objects in policy "silver": 0 Bytes in policy "silver": 0 X-Timestamp: 1404697760.88809 X-Trans-Id: txec519e24b44a413abb705-0053da2dcb Content-Type: text/plain; charset=utf-8 Accept-Ranges: bytes Change-Id: I7ad0ee6d88f8393e3a93e90cd52b9b592da7072d
Diffstat (limited to 'swiftclient/multithreading.py')
-rw-r--r--swiftclient/multithreading.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/swiftclient/multithreading.py b/swiftclient/multithreading.py
index 2f498c9..d187091 100644
--- a/swiftclient/multithreading.py
+++ b/swiftclient/multithreading.py
@@ -193,6 +193,7 @@ class MultiThreadingManager(object):
The swift command-line tool uses this to exit non-zero if any error strings
were printed.
"""
+ DEFAULT_OFFSET = 14
def __init__(self, print_stream=sys.stdout, error_stream=sys.stderr):
"""
@@ -231,7 +232,7 @@ class MultiThreadingManager(object):
msg = msg % fmt_args
self.printer.queue.put(msg)
- def print_items(self, items, offset=14, skip_missing=False):
+ def print_items(self, items, offset=DEFAULT_OFFSET, skip_missing=False):
lines = []
template = '%%%ds: %%s' % offset
for k, v in items:
@@ -241,7 +242,7 @@ class MultiThreadingManager(object):
self.print_msg('\n'.join(lines))
def print_headers(self, headers, meta_prefix='', exclude_headers=None,
- offset=14):
+ offset=DEFAULT_OFFSET):
exclude_headers = exclude_headers or []
meta_headers = []
other_headers = []
@@ -254,6 +255,18 @@ class MultiThreadingManager(object):
other_headers.append(template % (key.title(), value))
self.print_msg('\n'.join(chain(meta_headers, other_headers)))
+ def headers_to_items(self, headers, meta_prefix='', exclude_headers=None):
+ exclude_headers = exclude_headers or []
+ meta_items = []
+ other_items = []
+ for key, value in headers.items():
+ if key.startswith(meta_prefix):
+ meta_key = 'Meta %s' % key[len(meta_prefix):].title()
+ meta_items.append((meta_key, value))
+ elif key not in exclude_headers:
+ other_items.append((key.title(), value))
+ return meta_items + other_items
+
def error(self, msg, *fmt_args):
if fmt_args:
msg = msg % fmt_args