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


Python Utils.read_file方法代码示例

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


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

示例1: run_text_step

# 需要导入模块: from utils.utils import Utils [as 别名]
# 或者: from utils.utils.Utils import read_file [as 别名]
 def run_text_step(ssh, file_text_step, param=None, interval=None):
     step_list = Utils.read_file(file_text_step)            
     for cmd in step_list:
         cmd = cmd.strip()
         if cmd:
             if param:
                 for key, value in param.iteritems():
                     #Util._logger.info(str(key) + ": " + str(value))
                     if key.startswith('tag_'):
                         value = str(value)
                         cmd = cmd.replace(key, value)
             #print cmd
             ssh.send_expect_prompt(cmd)
             if interval: 
                 time.sleep(interval)
开发者ID:huhe56,项目名称:nj-snic,代码行数:17,代码来源:util.py

示例2: get_node_name_list

# 需要导入模块: from utils.utils import Utils [as 别名]
# 或者: from utils.utils.Utils import read_file [as 别名]
 def get_node_name_list(path_config_file):
     pattern1 = re.compile("\s*\,\s*")
     pattern2 = re.compile("\[(?P<range>[0-9\-]+)\]")
     pattern3 = re.compile(r"-")
     node_list = []
     line_list = Utils.read_file(path_config_file)
     for line in line_list:
         line.strip()
         if line == "": continue
         if line.startswith("#"): continue
         if pattern1.search(line):
             node_list_1 = pattern1.split(line)
             node_list = node_list + node_list_1
         elif pattern2.search(line):
             m = pattern2.search(line)
             rangex = m.group("range")
             hostname_prefix = line.replace("[" + rangex + "]", "")
             range_item_list = pattern3.split(rangex)
             for i in range(int(range_item_list[0]), int(range_item_list[1])+1):
                 hostname = hostname_prefix + str(i).zfill(2)
                 node_list.append(hostname)
         else:
             node_list.append(line)
     return sorted(node_list)
开发者ID:huhe56,项目名称:nj-snic,代码行数:26,代码来源:util.py


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