当前位置: 首页>>代码示例>>Python>>正文


Python Misc.list_to_multiline_string方法代码示例

本文整理汇总了Python中misc.Misc.list_to_multiline_string方法的典型用法代码示例。如果您正苦于以下问题:Python Misc.list_to_multiline_string方法的具体用法?Python Misc.list_to_multiline_string怎么用?Python Misc.list_to_multiline_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc.Misc的用法示例。


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

示例1: report_elb

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:34,代码来源:elb.py

示例2: info_all

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:22,代码来源:elb.py

示例3: info_certs

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:17,代码来源:iam.py

示例4: instance_status

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:18,代码来源:ami.py

示例5: list_user_groups

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:19,代码来源:iam.py

示例6: info

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_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'])
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:22,代码来源:route53.py

示例7: test_list_to_multiline_non_list

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_string [as 别名]
 def test_list_to_multiline_non_list(self):
     list = "test"
     should_be = "t\ne\ns\nt"
     result = Misc.list_to_multiline_string(list=list)
     self.assertEqual(should_be, result)
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:7,代码来源:test_Misc.py

示例8: test_list_to_multiline_default

# 需要导入模块: from misc import Misc [as 别名]
# 或者: from misc.Misc import list_to_multiline_string [as 别名]
 def test_list_to_multiline_default(self):
     list = ["test", "test2"]
     should_be = "test\ntest2"
     result = Misc.list_to_multiline_string(list=list)
     self.assertEqual(should_be, result)
开发者ID:s4mur4i,项目名称:kerrigan,代码行数:7,代码来源:test_Misc.py


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