コード例 #1
0
ファイル: main.py プロジェクト: tonyMartin/CouchPotatoServer
    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get('app_dir'), command = git_command)

        remote_name = 'origin'
        remote = self.repo.getRemoteByName(remote_name)
        if self.old_repo in remote.url:
            log.info('Changing repo to new github organization: %s -> %s', (self.old_repo, self.new_repo))
            new_url = remote.url.replace(self.old_repo, self.new_repo)
            self.repo._executeGitCommandAssertSuccess("remote set-url %s %s" % (remote_name, new_url))
コード例 #2
0
    def __init__(self):

        self.repo = LocalRepository(Env.get('app_dir'))

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

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

        addApiView('updater.info', self.getInfo)
        addApiView('updater.update', self.doUpdateView)
コード例 #3
0
ファイル: main.py プロジェクト: sirchia/CouchPotatoServer
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
コード例 #4
0
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
コード例 #5
0
ファイル: main.py プロジェクト: EchelonFour/CouchPotatoServer
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
コード例 #6
0
ファイル: main.py プロジェクト: ressu/CouchPotatoServer
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
コード例 #7
0
ファイル: main.py プロジェクト: CouchPotato/CouchPotatoServer
    def __init__(self, git_command):
        self.repo = LocalRepository(Env.get('app_dir'), command = git_command)

        remote_name = 'origin'
        remote = self.repo.getRemoteByName(remote_name)
        if self.old_repo in remote.url:
            log.info('Changing repo to new github organization: %s -> %s', (self.old_repo, self.new_repo))
            new_url = remote.url.replace(self.old_repo, self.new_repo)
            self.repo._executeGitCommandAssertSuccess("remote set-url %s %s" % (remote_name, new_url))
コード例 #8
0
ファイル: main.py プロジェクト: geman777/CouchPotatoServer
    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)
コード例 #9
0
ファイル: main.py プロジェクト: dito2102/CouchPotatoServer
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
コード例 #10
0
ファイル: updater.py プロジェクト: mchhaily/CouchPotato
    def start(self):
        self.basePath = cherrypy.config['basePath']
        self.runPath = cherrypy.config['runPath']
        self.cachePath = cherrypy.config['cachePath']
        self.isFrozen = cherrypy.config['frozen']
        self.debug = cherrypy.config['debug']
        self.updatePath = os.path.join(self.cachePath, 'updates')
        self.historyFile = os.path.join(self.updatePath, 'history.txt')

        self.repo = LocalRepository(self.basePath)

        # get back the .git dir
        if self.hasGit() and not self.isRepo():
            try:
                log.info('Updating CP to git version.')
                path = os.path.join(self.cachePath, 'temp_git')
                self.removeDir(path)
                repo = LocalRepository(path)
                repo.clone(self.git)
                self.replaceWith(path)
                self.removeDir(path)
            except Exception, e:
                log.error('Trying to rebuild the .git dir: %s' % e)
コード例 #11
0
ファイル: main.py プロジェクト: daemox/CouchPotatoServer
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
コード例 #12
0
class Updater(Plugin):

    repo_name = 'RuudBurger/CouchPotatoServer'

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

    def __init__(self):

        self.repo = LocalRepository(Env.get('app_dir'))

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

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

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

    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 = output.hash
            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
コード例 #13
0
ファイル: main.py プロジェクト: EchelonFour/CouchPotatoServer
    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'}
        })
コード例 #14
0
ファイル: main.py プロジェクト: dito2102/CouchPotatoServer
 def __init__(self, git_command):
     self.repo = LocalRepository(Env.get('app_dir'), command = git_command)
コード例 #15
0
ファイル: main.py プロジェクト: Kiiv/CouchPotatoServer
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
コード例 #16
0
ファイル: main.py プロジェクト: willko23/CouchPotatoServer
 def __init__(self, git_command):
     self.repo = LocalRepository(Env.get('app_dir'), command = git_command)
コード例 #17
0
ファイル: main.py プロジェクト: willko23/CouchPotatoServer
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 as e:
                log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)
                return 'No GIT'

        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
コード例 #18
0
ファイル: main.py プロジェクト: Adelscott/persomov
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
コード例 #19
0
class GitUpdater(BaseUpdater):

    old_repo = 'RuudBurger/CouchPotatoServer'
    new_repo = 'CouchPotato/CouchPotatoServer'

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

        remote_name = 'origin'
        remote = self.repo.getRemoteByName(remote_name)
        if self.old_repo in remote.url:
            log.info('Changing repo to new github organization: %s -> %s',
                     (self.old_repo, self.new_repo))
            new_url = remote.url.replace(self.old_repo, self.new_repo)
            self.repo._executeGitCommandAssertSuccess("remote set-url %s %s" %
                                                      (remote_name, new_url))

    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