本文整理汇总了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()
示例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()