本文整理汇总了Python中pulp.common.bundle.Bundle.read方法的典型用法代码示例。如果您正苦于以下问题:Python Bundle.read方法的具体用法?Python Bundle.read怎么用?Python Bundle.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.common.bundle.Bundle
的用法示例。
在下文中一共展示了Bundle.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_consumer_id
# 需要导入模块: from pulp.common.bundle import Bundle [as 别名]
# 或者: from pulp.common.bundle.Bundle import read [as 别名]
def load_consumer_id(context):
"""
Returns the consumer's ID if it is registered.
@return: consumer id if registered; None when not registered
@rtype: str, None
"""
filesystem_section = context.config.get('filesystem', None)
if filesystem_section is None:
return None
consumer_cert_path = filesystem_section.get('id_cert_dir', None)
consumer_cert_filename = filesystem_section.get('id_cert_filename', None)
if None in (consumer_cert_path, consumer_cert_filename):
return None
full_filename = os.path.join(consumer_cert_path, consumer_cert_filename)
bundle = Bundle(full_filename)
if not bundle.valid():
return None
content = bundle.read()
x509 = X509.load_cert_string(content)
subject = _subject(x509)
return subject['CN']
示例2: load_consumer_id
# 需要导入模块: from pulp.common.bundle import Bundle [as 别名]
# 或者: from pulp.common.bundle.Bundle import read [as 别名]
def load_consumer_id(context):
"""
Returns the consumer's ID if it is registered.
@return: consumer id if registered; None when not registered
@rtype: str, None
"""
consumer_cert_path = context.config['filesystem']['id_cert_dir']
consumer_cert_filename = context.config['filesystem']['id_cert_filename']
full_filename = os.path.join(consumer_cert_path, consumer_cert_filename)
bundle = Bundle(full_filename)
if bundle.valid():
content = bundle.read()
x509 = X509.load_cert_string(content)
subject = _subject(x509)
return subject['CN']
else:
return None
示例3: testRead
# 需要导入模块: from pulp.common.bundle import Bundle [as 别名]
# 或者: from pulp.common.bundle.Bundle import read [as 别名]
def testRead(self):
b = Bundle(CRTFILE)
b.write(BUNDLE)
s = b.read()
self.assertEqual(BUNDLE.strip(), s.strip())