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


Python Version.from_system方法代码示例

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


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

示例1: _update_profile

# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_system [as 别名]
    def _update_profile(self, profile_id=None):
        """Get a new profile if we don't have a profile in the registry or the Hub
        has a newer profile for this appliance. If we can't contact the Hub raise
        an error if we don't already have profile."""

        hub_backups = hub.Backups(self.sub_apikey)
        if not profile_id:
            if self.profile:
                profile_id = self.profile.profile_id
            else:
                profile_id = str(Version.from_system())

        if self.profile and self.profile.profile_id == profile_id:
            profile_timestamp = self.profile.timestamp
        else:
            # forced profile is not cached in the self
            profile_timestamp = None

        try:
            new_profile = hub_backups.get_new_profile(profile_id, profile_timestamp)
            if new_profile:
                self.profile = new_profile
                print "Downloaded %s profile" % self.profile.profile_id

        except hub_backups.Error, e:
            errno, errname, desc = e.args
            if errname == "BackupArchive.NotFound":
                raise self.ProfileNotFound(desc)

            if not self.profile or (self.profile.profile_id != profile_id):
                raise

            raise self.CachedProfile("using cached profile because of a Hub error: " + desc)
开发者ID:84danielwhite,项目名称:tklbam,代码行数:35,代码来源:registry.py

示例2: do_compatibility_check

# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_system [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

示例3: _complete_profile_id

# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_system [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

示例4: profile

# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_system [as 别名]
    def profile(self, val=UNDEFINED):
        if val is None:
            return shutil.rmtree(self.path.profile, ignore_errors=True)

        if val is UNDEFINED:
            if not exists(self.path.profile.stamp):
                return None

            timestamp = int(os.stat(self.path.profile.stamp).st_mtime)
            profile_id = self._file_str(self.path.profile.profile_id)
            if profile_id is None:
                profile_id = str(Version.from_system())
            return Profile(self.path.profile, profile_id, timestamp)
        else:
            profile_archive = val

            if not exists(self.path.profile):
                os.makedirs(self.path.profile)

            profile_archive.extract(self.path.profile)
            file(self.path.profile.stamp, "w").close()
            os.utime(self.path.profile.stamp, (0, profile_archive.timestamp))
            self._file_str(self.path.profile.profile_id, profile_archive.profile_id)
开发者ID:84danielwhite,项目名称:tklbam,代码行数:25,代码来源:registry.py

示例5: isinstance

# 需要导入模块: from version import Version [as 别名]
# 或者: from version.Version import from_system [as 别名]
            except hb.Error, e:
                # if the Hub is down we can hope that the cached address
                # is still valid and warn and try to backup anyway.
                #
                # But if we reach the Hub and it tells us the backup is invalid
                # we must invalidate the cached backup record and start over.

                if isinstance(e, hub.InvalidBackupError):
                    warn("old backup record deleted, creating new ... ")
                    registry.hbr = None
                else:
                    warn("using cached backup record: " + str(e))

        if not registry.hbr:
            registry.hbr = hb.new_backup_record(registry.key,
                                                str(Version.from_system()),
                                                get_server_id())

        conf.address = registry.hbr.address

    if opt_resume:
        conf = registry.backup_resume_conf
    else:
        # implicit resume
        if not opt_simulate and not opt_disable_resume and registry.backup_resume_conf == conf:
            print "Implicit --resume: Detected a rerun of an aborted backup session"
            print "                   You can disable this with the --disable-resume option"
            print
            time.sleep(5)

            opt_resume = True
开发者ID:84danielwhite,项目名称:tklbam,代码行数:33,代码来源:cmd_backup.py


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