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


Python Utilities.file_exists方法代码示例

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


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

示例1: update_ssh_conf

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import file_exists [as 别名]
 def update_ssh_conf(self):
     if not Utilities.file_exists(self.SSH_CONF_FILEPATH):
         print "ssh conf file does not exist at " + self.SSH_CONF_FILEPATH
         return
         
     # TODO: Check whether the entries exist before appending (for each host)
     conf_file = open(self.SSH_CONF_FILEPATH, 'a')
     conf_file.write("    UserKnownHostsFile /dev/null\n")
     conf_file.write("    StrictHostKeyChecking no\n")
     conf_file.close()
开发者ID:avibhandari,项目名称:MicroCloud,代码行数:12,代码来源:managementnodeinstaller.py

示例2: update_vcld_conf

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import file_exists [as 别名]
 def update_vcld_conf(self):
     if not Utilities.file_exists(self.VCLD_CONF_FILEPATH):
         print "vcld conf file does not exist at " + self.VCLD_CONF_FILEPATH
         return        
         
     file_handler, abs_path = mkstemp()
 
     old_file = open(self.VCLD_CONF_FILEPATH)
     temp_file = open(abs_path, 'w')
 
     for line in old_file:
         words = line.split('=')
         if len(words) <= 1:
             temp_file.write(line)
             continue
         
         key, value = line.split('=')
         if key.strip() not in self.parameters:
             temp_file.write(line)
             continue
 
         value = self.parameters[key.strip()]
         temp_file.write("%s=%s\n" % (key.strip(), value))
     
     old_file.close()
     temp_file.close()
     close(file_handler)
     
     # Copy from the temp file to secrets.php (so as not to loose the 
     # file permissions on secrets.php
     conf_file = open(self.VCLD_CONF_FILEPATH, 'w')
     temp_file = open(abs_path)
 
     for line in temp_file:
         conf_file.write(line)
 
     conf_file.close()
开发者ID:avibhandari,项目名称:MicroCloud,代码行数:39,代码来源:managementnodeinstaller.py


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