本文整理汇总了Python中common.Common.get_versions_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Common.get_versions_dict方法的具体用法?Python Common.get_versions_dict怎么用?Python Common.get_versions_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.get_versions_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_files_upgrade
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import get_versions_dict [as 别名]
def copy_files_upgrade(self):
try:
upgrade_modules = self.get_upgrade_modules_list()
backup_all = "-backup" in sys.argv or "-rpm" in sys.argv
ver_dict = Common.get_versions_dict()
backup_dir = "/".join((Common.Paths.LOGMIND_PATH, "backup", "components"))
if not os.path.exists(backup_dir):
os.makedirs(backup_dir)
else:
shutil.rmtree(backup_dir)
os.makedirs(backup_dir)
for module in upgrade_modules:
module = module.strip()
print "Upgrading " + module + " from version '" + str(ver_dict[module]) + "' to version '" + str(Version.VERSION[module]) + "'"
for d in Common.Paths.COMPONENTS_DIRS_DICT[module]:
src = "/".join((os.path.dirname(sys.argv[0]), "logmind", d))
dst = "/".join((Common.Paths.LOGMIND_PATH, d))
if backup_all:
print "Creating backup of", d
#shutil.copytree(dst, "/".join((backup_dir,d)), ignore=shutil.ignore_patterns("log", "service"))
if os.path.isdir(dst):
for sub in os.listdir(dst):
print "backing up:", sub
if not sub in ["log", "logs", "service"]:
sub_src = "/".join((dst, sub))
sub_dst = "/".join((backup_dir, d ,sub))
if not os.path.exists("/".join((backup_dir, d))):
os.makedirs("/".join((backup_dir, d)))
if os.path.isdir(sub_src):
shutil.copytree(sub_src, sub_dst)
else:
shutil.copy(sub_src, sub_dst)
else:
shutil.copy(dst, "/".join((backup_dir,d)))
print "Upgrading", d
if os.path.isdir(dst):
shutil.rmtree(dst)
shutil.copytree(src, dst)
else:
os.remove(dst)
shutil.copy(src, dst)
# Updating global version file.
ver_file = "/".join((os.path.dirname(sys.argv[0]), "logmind", "version"))
shutil.copy(ver_file, Common.Paths.LOGMIND_PATH)
return True
except Exception, e:
print "ERROR: ", e
return False