• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.prt_bytes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中swiftclient.utils.prt_bytes函数的典型用法代码示例。如果您正苦于以下问题:Python prt_bytes函数的具体用法?Python prt_bytes怎么用?Python prt_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了prt_bytes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: stat_container

def stat_container(conn, options, args, thread_manager):
    headers = conn.head_container(args[0])
    if options.verbose > 1:
        path = '%s/%s' % (conn.url, args[0])
        thread_manager.print_items((
            ('URL', path),
            ('Auth Token', conn.token),
        ))
    object_count = prt_bytes(
        headers.get('x-container-object-count', 0),
        options.human).lstrip()
    bytes_used = prt_bytes(headers.get('x-container-bytes-used', 0),
                           options.human).lstrip()
    thread_manager.print_items((
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Container', args[0]),
        ('Objects', object_count),
        ('Bytes', bytes_used),
        ('Read ACL', headers.get('x-container-read', '')),
        ('Write ACL', headers.get('x-container-write', '')),
        ('Sync To', headers.get('x-container-sync-to', '')),
        ('Sync Key', headers.get('x-container-sync-key', '')),
    ))
    thread_manager.print_headers(headers,
                                 meta_prefix='x-container-meta-',
                                 exclude_headers=(
                                     'content-length', 'date',
                                     'x-container-object-count',
                                     'x-container-bytes-used',
                                     'x-container-read',
                                     'x-container-write',
                                     'x-container-sync-to',
                                     'x-container-sync-key'))
开发者ID:chitrangjain,项目名称:python-swiftclient,代码行数:33,代码来源:command_helpers.py


示例2: stat_account

def stat_account(conn, options, thread_manager):
    headers = conn.head_account()
    if options.verbose > 1:
        thread_manager.print_items((
            ('StorageURL', conn.url),
            ('Auth Token', conn.token),
        ))
    container_count = int(headers.get('x-account-container-count', 0))
    object_count = prt_bytes(headers.get('x-account-object-count', 0),
                             options.human).lstrip()
    bytes_used = prt_bytes(headers.get('x-account-bytes-used', 0),
                           options.human).lstrip()
    thread_manager.print_items((
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Containers', container_count),
        ('Objects', object_count),
        ('Bytes', bytes_used),
    ))
    thread_manager.print_headers(headers,
                                 meta_prefix='x-account-meta-',
                                 exclude_headers=(
                                     'content-length', 'date',
                                     'x-account-container-count',
                                     'x-account-object-count',
                                     'x-account-bytes-used'))
开发者ID:chitrangjain,项目名称:python-swiftclient,代码行数:25,代码来源:command_helpers.py


示例3: stat_container

def stat_container(conn, options, container):
    headers = conn.head_container(container)
    items = []
    if options['verbose'] > 1:
        path = '%s/%s' % (conn.url, container)
        items.extend([
            ('URL', path),
            ('Auth Token', conn.token)
        ])
    object_count = prt_bytes(
        headers.get('x-container-object-count', 0),
        options['human']).lstrip()
    bytes_used = prt_bytes(headers.get('x-container-bytes-used', 0),
                           options['human']).lstrip()
    items.extend([
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Container', container),
        ('Objects', object_count),
        ('Bytes', bytes_used),
        ('Read ACL', headers.get('x-container-read', '')),
        ('Write ACL', headers.get('x-container-write', '')),
        ('Sync To', headers.get('x-container-sync-to', '')),
        ('Sync Key', headers.get('x-container-sync-key', ''))
    ])
    return items, headers
开发者ID:HiddenData,项目名称:python-swiftclient,代码行数:25,代码来源:command_helpers.py


示例4: stat_account

def stat_account(conn, options):
    items = []
    req_headers = split_request_headers(options.get('header', []))

    headers = conn.head_account(headers=req_headers)
    if options['verbose'] > 1:
        items.extend([
            ('StorageURL', conn.url),
            ('Auth Token', conn.token),
        ])
    container_count = int(headers.get('x-account-container-count', 0))
    object_count = prt_bytes(headers.get('x-account-object-count', 0),
                             options['human']).lstrip()
    bytes_used = prt_bytes(headers.get('x-account-bytes-used', 0),
                           options['human']).lstrip()
    items.extend([
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Containers', container_count),
        ('Objects', object_count),
        ('Bytes', bytes_used),
    ])

    policies = set()
    for header_key, header_value in headers.items():
        if header_key.lower().startswith(POLICY_HEADER_PREFIX):
            policy_name = header_key.rsplit('-', 2)[0].split('-', 4)[-1]
            policies.add(policy_name)

    for policy in policies:
        container_count_header = (POLICY_HEADER_PREFIX + policy +
                                  '-container-count')
        if container_count_header in headers:
            items.append(
                ('Containers in policy "' + policy + '"',
                 prt_bytes(headers[container_count_header],
                           options['human']).lstrip())
            )
        items.extend((
            ('Objects in policy "' + policy + '"',
             prt_bytes(
                 headers.get(
                     POLICY_HEADER_PREFIX + policy + '-object-count', 0),
                 options['human']
             ).lstrip()),
            ('Bytes in policy "' + policy + '"',
             prt_bytes(
                 headers.get(
                     POLICY_HEADER_PREFIX + policy + '-bytes-used', 0),
                 options['human']
             ).lstrip()),
        ))

    return items, headers
开发者ID:StarfishStorage,项目名称:python-swiftclient,代码行数:53,代码来源:command_helpers.py


示例5: stat_account

def stat_account(conn, options, thread_manager):
    items_to_print = []

    headers = conn.head_account()
    if options.verbose > 1:
        items_to_print.extend((
            ('StorageURL', conn.url),
            ('Auth Token', conn.token),
        ))
    container_count = int(headers.get('x-account-container-count', 0))
    object_count = prt_bytes(headers.get('x-account-object-count', 0),
                             options.human).lstrip()
    bytes_used = prt_bytes(headers.get('x-account-bytes-used', 0),
                           options.human).lstrip()
    items_to_print.extend((
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Containers', container_count),
        ('Objects', object_count),
        ('Bytes', bytes_used),
    ))
    policies = set()
    exclude_policy_headers = []
    ps_header_prefix = 'x-account-storage-policy-'
    for header_key, header_value in headers.items():
        if header_key.lower().startswith(ps_header_prefix):
            policy_name = header_key.rsplit('-', 2)[0].split('-', 4)[-1]
            policies.add(policy_name)
            exclude_policy_headers.append(header_key)
    for policy in policies:
        items_to_print.extend((
            ('Objects in policy "' + policy + '"',
             prt_bytes(headers.get(ps_header_prefix + policy + '-object-count',
                                   0), options.human).lstrip()),
            ('Bytes in policy "' + policy + '"',
             prt_bytes(headers.get(ps_header_prefix + policy + '-bytes-used',
                                   0), options.human).lstrip()),
        ))

    items_to_print.extend(thread_manager.headers_to_items(
        headers, meta_prefix='x-account-meta-',
        exclude_headers=([
            'content-length', 'date',
            'x-account-container-count',
            'x-account-object-count',
            'x-account-bytes-used'] + exclude_policy_headers)))
    # line up the items nicely
    offset = max(len(item) for item, value in items_to_print)
    thread_manager.print_items(items_to_print, offset=offset)
开发者ID:AsherBond,项目名称:python-swiftclient,代码行数:48,代码来源:command_helpers.py


示例6: stat_object

def stat_object(conn, options, args, thread_manager):
    headers = conn.head_object(args[0], args[1])
    if options.verbose > 1:
        path = '%s/%s/%s' % (conn.url, args[0], args[1])
        thread_manager.print_items((
            ('URL', path),
            ('Auth Token', conn.token),
        ))
    content_length = prt_bytes(headers.get('content-length', 0),
                               options.human).lstrip()
    thread_manager.print_items((
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Container', args[0]),
        ('Object', args[1]),
        ('Content Type', headers.get('content-type')),
        ('Content Length', content_length),
        ('Last Modified', headers.get('last-modified')),
        ('ETag', headers.get('etag')),
        ('Manifest', headers.get('x-object-manifest')),
    ), skip_missing=True)
    thread_manager.print_headers(headers,
                                 meta_prefix='x-object-meta-',
                                 exclude_headers=(
                                     'content-type', 'content-length',
                                     'last-modified', 'etag', 'date',
                                     'x-object-manifest'))
开发者ID:chitrangjain,项目名称:python-swiftclient,代码行数:26,代码来源:command_helpers.py


示例7: stat_object

def stat_object(conn, options, container, obj):
    headers = conn.head_object(container, obj)
    items = []
    if options['verbose'] > 1:
        path = '%s/%s/%s' % (conn.url, container, obj)
        items.extend([
            ('URL', path),
            ('Auth Token', conn.token)
        ])
    content_length = prt_bytes(headers.get('content-length', 0),
                               options['human']).lstrip()
    items.extend([
        ('Account', conn.url.rsplit('/', 1)[-1]),
        ('Container', container),
        ('Object', obj),
        ('Content Type', headers.get('content-type')),
        ('Content Length', content_length),
        ('Last Modified', headers.get('last-modified')),
        ('ETag', headers.get('etag')),
        ('Manifest', headers.get('x-object-manifest'))
    ])
    return items, headers
开发者ID:HiddenData,项目名称:python-swiftclient,代码行数:22,代码来源:command_helpers.py


示例8: test_one_byte

 def test_one_byte(self):
     bytes_ = 1
     raw = '1'
     human = '1'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例9: test_ten_meg

 def test_ten_meg(self):
     bytes_ = 10 * 2 ** 20
     human = '10M'
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:4,代码来源:test_utils.py


示例10: test_one_meg

 def test_one_meg(self):
     bytes_ = 2 ** 20
     raw = '1048576'
     human = '1.0M'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例11: test_just_a_hair_less_than_one_meg

 def test_just_a_hair_less_than_one_meg(self):
     bytes_ = (2 ** 20) - (2 ** 10) + 1
     raw = '1047553'
     human = '1.0M'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例12: test_a_bit_less_than_one_meg

 def test_a_bit_less_than_one_meg(self):
     bytes_ = (2 ** 20) - (2 ** 10)
     raw = '1047552'
     human = '1023K'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例13: test_a_decimal_k

 def test_a_decimal_k(self):
     bytes_ = (3 * 2 ** 10) + 512
     raw = '3584'
     human = '3.5K'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例14: test_one_k

 def test_one_k(self):
     bytes_ = 2 ** 10
     raw = '1024'
     human = '1.0K'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例15: test_less_than_one_k

 def test_less_than_one_k(self):
     bytes_ = (2 ** 10) - 1
     raw = '1023'
     human = '1023'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例16: test_zero_bytes

 def test_zero_bytes(self):
     bytes_ = 0
     raw = '0'
     human = '0'
     self.assertEqual(raw, u.prt_bytes(bytes_, False).lstrip())
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:6,代码来源:test_utils.py


示例17: test_overflow

 def test_overflow(self):
     bytes_ = 2 ** 90
     self.assertEqual('1024Y', u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:3,代码来源:test_utils.py


示例18: test_a_yotta

 def test_a_yotta(self):
     bytes_ = 42 * 2 ** 80
     self.assertEqual('42Y', u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:3,代码来源:test_utils.py


示例19: test_just_a_hair_less_than_ten_meg

 def test_just_a_hair_less_than_ten_meg(self):
     bytes_ = (10 * 2 ** 20) - 1
     human = '10.0M'
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:4,代码来源:test_utils.py


示例20: test_bit_less_than_ten_meg

 def test_bit_less_than_ten_meg(self):
     bytes_ = (10 * 2 ** 20) - (100 * 2 ** 10)
     human = '9.9M'
     self.assertEqual(human, u.prt_bytes(bytes_, True).lstrip())
开发者ID:bilcocq,项目名称:python-swiftclient,代码行数:4,代码来源:test_utils.py



注:本文中的swiftclient.utils.prt_bytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cli.CLI类代码示例发布时间:2022-05-27
下一篇:
Python utils.generate_temp_url函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap