本文整理汇总了Python中version.Version.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Version.from_string方法的具体用法?Python Version.from_string怎么用?Python Version.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类version.Version
的用法示例。
在下文中一共展示了Version.from_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_compatibility_check
# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_string [as 别名]
def do_compatibility_check(backup_turnkey_version, interactive=True):
backup_codename = Version.from_string(backup_turnkey_version).codename
local_codename = Version.from_system().codename
if local_codename == backup_codename:
return
def fmt(s):
return s.upper().replace("-", " ")
backup_codename = fmt(backup_codename)
local_codename = fmt(local_codename)
print "WARNING: INCOMPATIBLE APPLIANCE BACKUP"
print "======================================"
print
print "Restoring a %s backup to a %s appliance is not recommended." % (backup_codename, local_codename)
print "For best results, restore to a fresh %s installation instead." % backup_codename
if not interactive:
sys.exit(ExitCode.INCOMPATIBLE)
print
print "(Use --force to suppress this check)"
print
while True:
answer = raw_input("Do you want to continue? [yes/no] ")
if answer:
break
if answer.lower() not in ('y', 'yes'):
fatal("You didn't answer 'yes'. Aborting!")
示例2: update_profile
# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_string [as 别名]
def update_profile(self, profile_id=None):
try:
# look for exact match first
self._update_profile(profile_id)
except self.ProfileNotFound, first_exception:
if profile_id and not Version.from_string(profile_id).is_complete():
completed_profile_id = _complete_profile_id(profile_id)
try:
self._update_profile(completed_profile_id)
except:
pass
raise first_exception
示例3: _complete_profile_id
# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_string [as 别名]
def _complete_profile_id(partial):
if not re.match(r"^turnkey-", partial):
partial = "turnkey-" + partial
partial = Version.from_string(partial)
system = Version.from_system()
if partial.arch is None:
partial.arch = system.arch
if partial.release is None or system.release.startswith(partial.release):
partial.release = system.release
return str(partial)