Example #1
0
class Updater(object):
    
    def __init__(self, localrepopath, gitpath):
        self.repo = localrepopath
        self.gitpath = gitpath
        self.git = LocalRepository(self.repo, self.gitpath)
        self.hash = '0'

    def update_available(self):
        """
        Checks git source if update is available
        return true or false
        """
        self.git.fetch()
        current_branch = self.git.getCurrentBranch().name
        for branch in self.git.getRemoteByName('origin').getBranches():
            local = self.git.getHead()
            remote = branch.getHead()
            if current_branch == branch.name:
                if local.hash[:8] != remote.hash[:8]:
                    self.hash = remote.hash[:8]
                    return True
        return False

    def update(self):
        self.git.pull()

    def respawn(self):
        args = sys.argv[:]
        args.insert(0, sys.executable)
        if sys.platform == 'win32':
            args = ['"%s"' % arg for arg in args]

        os.chdir(self.repo)
        os.execv(sys.executable, args)
Example #2
0
 def __init__(self, localrepopath, gitpath):
     self.repo = localrepopath
     self.gitpath = gitpath
     self.git = LocalRepository(self.repo, self.gitpath)
     self.hash = '0'