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


Python LocalRepository.getHead方法代码示例

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


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

示例1: Updater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class Updater(Plugin):

    repo_name = 'RuudBurger/CouchPotatoServer'

    version = None
    update_failed = False
    update_version = None
    last_check = 0

    def __init__(self):

        self.repo = LocalRepository(Env.get('app_dir'), command = self.conf('git_command', default = 'git'))

        fireEvent('schedule.interval', 'updater.check', self.check, hours = 6)

        addEvent('app.load', self.check)

        addApiView('updater.info', self.getInfo, docs = {
            'desc': 'Get updater information',
            'return': {
                'type': 'object',
                'example': """{
        'repo_name': "Name of used repository",
        'last_check': "last checked for update",
        'update_version': "available update version or empty",
        'version': current_cp_version
}"""}
        })
        addApiView('updater.update', self.doUpdateView)
        addApiView('updater.check', self.checkView, docs = {
            'desc': 'Check for available update',
            'return': {'type': 'see updater.info'}
        })

    def getInfo(self):

        return jsonified({
            'repo_name': self.repo_name,
            'last_check': self.last_check,
            'update_version': self.update_version,
            'version': self.getVersion()
        })

    def getVersion(self):

        if not self.version:
            try:
                output = self.repo.getHead() # Yes, please
                log.debug('Git version output: %s' % output.hash)
                self.version = {
                    'hash': output.hash[:8],
                    'date': output.getDate(),
                }
            except Exception, e:
                log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s' % e)
                return 'No GIT'

        return self.version
开发者ID:EchelonFour,项目名称:CouchPotatoServer,代码行数:60,代码来源:main.py

示例2: GitUpdater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class GitUpdater(BaseUpdater):
    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get('app_dir'), command=git_command)

    def doUpdate(self):
        try:
            log.debug('Stashing local changes')
            self.repo.saveStash()

            log.info('Updating to latest version')
            info = self.info()
            self.repo.pull()

            # Delete leftover .pyc files
            self.deletePyc()

            # Notify before returning and restarting
            version_date = datetime.fromtimestamp(
                info['update_version']['date'])
            fireEvent(
                'updater.updated',
                'Updated to a new version with hash "%s", this version is from %s'
                % (info['update_version']['hash'], version_date),
                data=info)

            return True
        except:
            log.error('Failed updating via GIT: %s' % traceback.format_exc())

        self.update_failed = True

        return False

    def getVersion(self):

        if not self.version:
            try:
                output = self.repo.getHead()  # Yes, please
                log.debug('Git version output: %s' % output.hash)
                self.version = {
                    'hash': output.hash[:8],
                    'date': output.getDate(),
                    'type': 'git',
                }
            except Exception, e:
                log.error(
                    'Failed using GIT updater, running from source, you need to have GIT installed. %s'
                    % e)
                return 'No GIT'

        return self.version
开发者ID:sirchia,项目名称:CouchPotatoServer,代码行数:53,代码来源:main.py

示例3: Updater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class Updater(Plugin):

    repo_name = 'RuudBurger/CouchPotatoServer'

    version = None
    update_failed = False
    update_version = None
    last_check = 0

    def __init__(self):

        self.repo = LocalRepository(Env.get('app_dir'), command = self.conf('git_command', default = 'git'))

        fireEvent('schedule.interval', 'updater.check', self.check, hours = 6)

        addEvent('app.load', self.check)

        addApiView('updater.info', self.getInfo)
        addApiView('updater.update', self.doUpdateView)
        addApiView('updater.check', self.checkView)

    def getInfo(self):

        return jsonified({
            'repo_name': self.repo_name,
            'last_check': self.last_check,
            'update_version': self.update_version,
            'version': self.getVersion()
        })

    def getVersion(self):

        if not self.version:
            try:
                output = self.repo.getHead() # Yes, please
                log.debug('Git version output: %s' % output.hash)
                self.version = {
                    'hash': output.hash[:8],
                    'date': output.getDate(),
                }
            except Exception, e:
                log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s' % e)
                return 'No GIT'

        return self.version
开发者ID:daemox,项目名称:CouchPotatoServer,代码行数:47,代码来源:main.py

示例4: GitUpdater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class GitUpdater(BaseUpdater):
    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get("app_dir"), command=git_command)

    def doUpdate(self):

        try:
            log.info("Updating to latest version")
            self.repo.pull()

            # Delete leftover .pyc files
            self.deletePyc()

            return True
        except:
            log.error("Failed updating via GIT: %s", traceback.format_exc())

        self.update_failed = True

        return False

    def getVersion(self):

        if not self.version:
            try:
                output = self.repo.getHead()  # Yes, please
                log.debug("Git version output: %s", output.hash)
                self.version = {
                    "repr": "git:(%s:%s % s) %s (%s)"
                    % (
                        self.repo_user,
                        self.repo_name,
                        self.branch,
                        output.hash[:8],
                        datetime.fromtimestamp(output.getDate()),
                    ),
                    "hash": output.hash[:8],
                    "date": output.getDate(),
                    "type": "git",
                }
            except Exception, e:
                log.error("Failed using GIT updater, running from source, you need to have GIT installed. %s", e)
                return "No GIT"

        return self.version
开发者ID:ressu,项目名称:CouchPotatoServer,代码行数:47,代码来源:main.py

示例5: GitUpdater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class GitUpdater(BaseUpdater):

    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get('app_dir'), command = git_command)

    def doUpdate(self):

        try:
            log.debug('Stashing local changes')
            self.repo.saveStash()

            log.info('Updating to latest version')
            self.repo.pull()

            # Delete leftover .pyc files
            self.deletePyc()

            return True
        except:
            log.error('Failed updating via GIT: %s', traceback.format_exc())

        self.update_failed = True

        return False

    def getVersion(self):

        if not self.version:
            try:
                output = self.repo.getHead() # Yes, please
                log.debug('Git version output: %s', output.hash)
                self.version = {
                    'hash': output.hash[:8],
                    'date': output.getDate(),
                    'type': 'git',
                }
            except Exception, e:
                log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)
                return 'No GIT'

        return self.version
开发者ID:dito2102,项目名称:CouchPotatoServer,代码行数:43,代码来源:main.py

示例6: GitUpdater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class GitUpdater(BaseUpdater):

    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get('app_dir'), command = git_command)

    def doUpdate(self):

        try:
            log.info('Updating to latest version')
            self.repo.pull()

            return True
        except:
            log.error('Failed updating via GIT: %s', traceback.format_exc())

        self.update_failed = True

        return False

    def getVersion(self):

        if not self.version:

            hash = None
            date = None
            branch = self.branch

            try:
                output = self.repo.getHead()  # Yes, please
                log.debug('Git version output: %s', output.hash)

                hash = output.hash[:8]
                date = output.getDate()
                branch = self.repo.getCurrentBranch().name
            except Exception as e:
                log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)

            self.version = {
                'repr': 'git:(%s:%s % s) %s (%s)' % (self.repo_user, self.repo_name, branch, hash or 'unknown_hash', datetime.fromtimestamp(date) if date else 'unknown_date'),
                'hash': hash,
                'date': date,
                'type': 'git',
                'branch': branch
            }

        return self.version

    def check(self):

        if self.update_version:
            return True

        log.info('Checking for new version on github for %s', self.repo_name)
        if not Env.get('dev'):
            self.repo.fetch()

        current_branch = self.repo.getCurrentBranch().name

        for branch in self.repo.getRemoteByName('origin').getBranches():
            if current_branch == branch.name:

                local = self.repo.getHead()
                remote = branch.getHead()

                log.debug('Versions, local:%s, remote:%s', (local.hash[:8], remote.hash[:8]))

                if local.getDate() < remote.getDate():
                    self.update_version = {
                        'hash': remote.hash[:8],
                        'date': remote.getDate(),
                    }
                    return True

        self.last_check = time.time()
        return False
开发者ID:Kiiv,项目名称:CouchPotatoServer,代码行数:77,代码来源:main.py

示例7: GitUpdater

# 需要导入模块: from git.repository import LocalRepository [as 别名]
# 或者: from git.repository.LocalRepository import getHead [as 别名]
class GitUpdater(BaseUpdater):
    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get("app_dir"), command=git_command)

    def doUpdate(self):

        try:
            log.info("Updating to latest version")
            self.repo.pull()

            return True
        except:
            log.error("Failed updating via GIT: %s", traceback.format_exc())

        self.update_failed = True

        return False

    def getVersion(self):

        if not self.version:

            hash = None
            date = None
            branch = self.branch

            try:
                output = self.repo.getHead()  # Yes, please
                log.debug("Git version output: %s", output.hash)

                hash = output.hash[:8]
                date = output.getDate()
                branch = self.repo.getCurrentBranch().name
            except Exception as e:
                log.error("Failed using GIT updater, running from source, you need to have GIT installed. %s", e)

            self.version = {
                "repr": "git:(%s:%s % s) %s (%s)"
                % (
                    self.repo_user,
                    self.repo_name,
                    branch,
                    hash or "unknown_hash",
                    datetime.fromtimestamp(date) if date else "unknown_date",
                ),
                "hash": hash,
                "date": date,
                "type": "git",
                "branch": branch,
            }

        return self.version

    def check(self):

        if self.update_version:
            return True

        log.info("Checking for new version on github for %s", self.repo_name)
        if not Env.get("dev"):
            self.repo.fetch()

        current_branch = self.repo.getCurrentBranch().name

        for branch in self.repo.getRemoteByName("origin").getBranches():
            if current_branch == branch.name:

                local = self.repo.getHead()
                remote = branch.getHead()

                log.debug("Versions, local:%s, remote:%s", (local.hash[:8], remote.hash[:8]))

                if local.getDate() < remote.getDate():
                    self.update_version = {"hash": remote.hash[:8], "date": remote.getDate()}
                    return True

        self.last_check = time.time()
        return False
开发者ID:Adelscott,项目名称:persomov,代码行数:80,代码来源:main.py


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