當前位置: 首頁>>代碼示例>>Python>>正文


Python Version.from_string方法代碼示例

本文整理匯總了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!")
開發者ID:84danielwhite,項目名稱:tklbam,代碼行數:36,代碼來源:cmd_restore.py

示例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
開發者ID:84danielwhite,項目名稱:tklbam,代碼行數:15,代碼來源:registry.py

示例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)
開發者ID:84danielwhite,項目名稱:tklbam,代碼行數:16,代碼來源:registry.py


注:本文中的version.Version.from_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。