本文整理汇总了Python中misc.Misc.join_list_to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.join_list_to_string方法的具体用法?Python Misc.join_list_to_string怎么用?Python Misc.join_list_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.Misc
的用法示例。
在下文中一共展示了Misc.join_list_to_string方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report_elb
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def report_elb(self):
'''
This function is a wrapper for parsing arguments and printing for elb attribute reports
Tested
:return:
'''
logger.info("Started report generation command")
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='report generation about elbs', usage='''kerrigan.py elb report_elb [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--columns', action='store', default=a.service_supported_columns(service="elb"),
help="Which columns to display")
parser.add_argument('--filters', action='store', default=None,
help="The filters that should be used, example: key1:value1,key2:value2")
args = parser.parse_args(sys.argv[3:])
columns = Misc.parse_service_columns(columns=args.columns, service="elb")
if args.filters:
filters = Misc.format_boto3_filter(filters=args.filters)
else:
filters = None
result = a.information_elbs(columns=columns, filters=filters)
for res in result:
if self.account_information['logger_arguments']['table']:
res['AvailabilityZones'] = Misc.list_to_multiline_string(list=res['AvailabilityZones'])
res['SecurityGroups'] = Misc.list_to_multiline_string(list=res['SecurityGroups'])
res['Instances'] = Misc.list_to_multiline_string(list=res['Instances'])
else:
res['AvailabilityZones'] = Misc.join_list_to_string(list=res['AvailabilityZones'])
res['SecurityGroups'] = Misc.join_list_to_string(list=res['SecurityGroups'])
res['Instances'] = Misc.join_list_to_string(list=res['Instances'])
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例2: info_all
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def info_all(self):
# FIXME implement possbility to scope to env
logger.info("Gathering all elbs")
parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py elb info_all [<args>]]
''' + self.global_options)
args = parser.parse_args(sys.argv[3:])
e = awsrequests()
res = e.elb_info_all()
for r in res:
if self.cli['csv']:
r['Availability Zones'] = Misc.join_list_to_string(list=r['Availability Zones'])
r['Securitygroups'] = Misc.join_list_to_string(list=r['Securitygroups'])
r['InstanceIds'] = Misc.join_list_to_string(list=r['InstanceIds'])
r['From-To-Protocol'] = Misc.join_list_to_string(list=r['From-To-Protocol'])
elif self.cli['table']:
r['Availability Zones'] = Misc.list_to_multiline_string(r['Availability Zones'])
r['InstanceIds'] = Misc.list_to_multiline_string(r['InstanceIds'])
r['Securitygroups'] = Misc.list_to_multiline_string(r['Securitygroups'])
r['From-To-Protocol'] = Misc.list_to_multiline_string(r['From-To-Protocol'])
logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
示例3: info_certs
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def info_certs(self):
logger.info("Going to list all certs")
parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py iam info_all [<args>]]
''' + self.global_options)
args = parser.parse_args(sys.argv[3:])
a = awsrequests()
res = a.server_certificates_info_all()
for r in res:
if self.cli['csv']:
r['ELB'] = Misc.join_list_to_string(list=r['ELB'])
elif self.cli['table']:
r['ELB'] = Misc.list_to_multiline_string(r['ELB'])
else:
logger.error('There is an unhandled printing. Need to investigate')
logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
示例4: instance_status
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def instance_status(self):
logger.info("Started instance status command")
a = awsrequests(session=self.account_information['session'])
parser = argparse.ArgumentParser(description='instance status about ami', usage='''kerrigan.py ami instance_Status [<args>]]
''' + self.global_options, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="kerrigan")
parser.add_argument('--imageid', action='store', default=None,
help="Only imageIds that should be queried")
args = parser.parse_args(sys.argv[3:])
result = a.image_instance_status(imageid=args.imageid)
for res in result:
if self.account_information['logger_arguments']['table']:
res['Instances'] = Misc.list_to_multiline_string(list=res['Instances'])
else:
res['Instances'] = Misc.join_list_to_string(list=res['Instances'])
logger.output(data=result, csvvar=self.account_information['logger_arguments']['csv'],
tablevar=self.account_information['logger_arguments']['table'])
示例5: list_user_groups
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def list_user_groups(self):
logger.info("Going to list groups")
parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py iam list_user_groups [<args>]]
''' + self.global_options)
parser.add_argument('--username', action='store', default=None,
help="Should intermediate certificate be uploaded")
args = parser.parse_args(sys.argv[3:])
a = awsrequests()
res = a.list_user_groups(username=args.username)
out = []
for r in res:
if self.cli['csv']:
res[r] = Misc.join_list_to_string(list=res[r])
elif self.cli['table']:
res[r] = Misc.list_to_multiline_string(res[r])
out.append({'Username': r, 'Groups': res[r]})
logger.output(data=out, csvvar=self.cli['csv'], tablevar=self.cli['table'])
示例6: info
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def info(self):
logger.info("Starting to gather information")
a = awsrequests()
parser = argparse.ArgumentParser(description='ec2 tool for devops', usage='''kerrigan.py route53 info [<args>]]
''' + self.global_options)
parser.add_argument('--env', action='store', help="Environment to gather information about")
args = parser.parse_args(sys.argv[3:])
res = a.route53_info(env=args.env)
for r in res:
if self.cli['csv']:
r['Values'] = Misc.join_list_to_string(list=r['Values'])
elif self.cli['table']:
r['Values'] = Misc.list_to_multiline_string(r['Values'])
else:
logger.error('There is an unhandled printing. Need to investigate')
# Add information if not present:
if 'Weight' not in r:
r['Weight'] = '-'
r['SetIdentifier'] = '-'
logger.output(data=res, csvvar=self.cli['csv'], tablevar=self.cli['table'])
示例7: test_join_string_to_list_invalid_list
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def test_join_string_to_list_invalid_list(self):
list = "abs"
should_be = "a_b_s"
result = Misc.join_list_to_string(list=list, join_with="_")
self.assertEqual(should_be, result)
示例8: test_join_string_to_list_special_char
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def test_join_string_to_list_special_char(self):
list = ['a', 'b']
should_be = "a_b"
result = Misc.join_list_to_string(list=list, join_with="_")
self.assertEqual(should_be, result)
示例9: test_join_string_to_list_default
# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import join_list_to_string [as 别名]
def test_join_string_to_list_default(self):
list = ['a', 'b']
should_be = "a,b"
result = Misc.join_list_to_string(list=list)
self.assertEqual(should_be, result)