Пример #1
0
    def update(self):
        """
        Performs pip upgrade
        """
        _, _, exit_status = self._run_pip(self._find_working_pip, 'install -U --no-cache-dir sickrage')
        if exit_status == 0:
            sickrage.srCore.srLogger.info("Updating SiCKRAGE from PyPi servers")
            if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
                srNotifiers.notify_version_update(self.get_newest_version)
            return True

        return False
Пример #2
0
    def update(self):
        """
        Performs pip upgrade
        """
        _, _, exit_status = self._run_pip(self._find_working_pip, 'install -U --no-cache-dir sickrage')
        if exit_status == 0:
            sickrage.srCore.srLogger.info("Updating SiCKRAGE from PyPi servers")
            if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
                srNotifiers.notify_version_update(sickrage.srCore.NEWEST_VERSION_STRING)
            return True

        return False
Пример #3
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        # remove untracked files and performs a hard reset on git branch to avoid update issues
        if sickrage.srCore.srConfig.GIT_RESET:
            # self.clean() # This is removing user data and backups
            self.reset()

        _, _, exit_status = self._run_git(self._find_working_git, 'pull -f origin ' + self.current_branch)
        if exit_status == 0:
            if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
                srNotifiers.notify_version_update(sickrage.srCore.NEWEST_VERSION_STRING)
            return True

        return False
Пример #4
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        # remove untracked files and performs a hard reset on git branch to avoid update issues
        if sickrage.srCore.srConfig.GIT_RESET:
            # self.clean() # This is removing user data and backups
            self.reset()

        _, _, exit_status = self._run_git(self._find_working_git, 'pull -f origin ' + self.current_branch)
        if exit_status == 0:
            if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
                srNotifiers.notify_version_update(sickrage.srCore.NEWEST_VERSION_STRING)
            self.install_requirements()
            return True

        return False
Пример #5
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        # remove untracked files and performs a hard reset on git branch to avoid update issues
        if sickrage.srCore.srConfig.GIT_RESET:
            # self.clean() # This is removing user data and backups
            self.reset()

        _, _, exit_status = self._run_git(self._git_path, 'pull -f {} {}'.format(sickrage.srCore.srConfig.GIT_REMOTE, self.current_branch))
        if exit_status == 0:
            sickrage.srCore.srLogger.info("Updating SiCKRAGE from GIT servers")
            if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
                srNotifiers.notify_version_update(self.get_newest_version)
            self.install_requirements()
            return True

        return False
Пример #6
0
    def update(self):
        """
        Performs pip upgrade
        """
        # Notify update successful
        sickrage.srCore.srLogger.info("Updating SiCKRAGE from PyPi servers")
        srNotifiers.notify_version_update(sickrage.srCore.NEWEST_VERSION_STRING)

        from pip.commands.install import InstallCommand
        options = InstallCommand().parse_args([])[0]
        options.use_user_site = all([not sickrage.isElevatedUser(), not sickrage.isVirtualEnv()])
        options.cache_dir = None
        options.upgrade = True
        options.quiet = 1

        options.ignore_dependencies = True
        InstallCommand().run(options, ['sickrage'])
        options.ignore_dependencies = False
        InstallCommand().run(options, ['sickrage'])

        return True
Пример #7
0
    def update(self):
        """
        Performs pip upgrade
        """
        # Notify update successful
        sickrage.srCore.srLogger.info("Updating SiCKRAGE from PyPi servers")
        srNotifiers.notify_version_update(sickrage.srCore.NEWEST_VERSION_STRING)

        from pip.commands.install import InstallCommand
        options = InstallCommand().parse_args([])[0]
        options.use_user_site = all([not sickrage.isElevatedUser(), not sickrage.isVirtualEnv()])
        options.cache_dir = None
        options.upgrade = True
        options.quiet = 1

        options.ignore_dependencies = True
        InstallCommand().run(options, ['sickrage'])
        options.ignore_dependencies = False
        InstallCommand().run(options, ['sickrage'])

        return True
Пример #8
0
    def update(self):
        """
        Downloads the latest source tarball from server and installs it over the existing version.
        """

        tar_download_url = 'https://git.sickrage.ca/SiCKRAGE/sickrage/repository/archive.tar?ref=master'

        try:
            # prepare the update dir
            sr_update_dir = os.path.join(sickrage.PROG_DIR, 'sr-update')

            if os.path.isdir(sr_update_dir):
                sickrage.srCore.srLogger.info("Clearing out update folder " + sr_update_dir + " before extracting")
                shutil.rmtree(sr_update_dir)

            sickrage.srCore.srLogger.info("Creating update folder " + sr_update_dir + " before extracting")
            os.makedirs(sr_update_dir)

            # retrieve file
            sickrage.srCore.srLogger.info("Downloading update from " + repr(tar_download_url))
            tar_download_path = os.path.join(sr_update_dir, 'sr-update.tar')
            sickrage.srCore.srWebSession.download(tar_download_url, tar_download_path)

            if not os.path.isfile(tar_download_path):
                sickrage.srCore.srLogger.warning(
                    "Unable to retrieve new version from " + tar_download_url + ", can't update")
                return False

            if not tarfile.is_tarfile(tar_download_path):
                sickrage.srCore.srLogger.error(
                    "Retrieved version from " + tar_download_url + " is corrupt, can't update")
                return False

            # extract to sr-update dir
            sickrage.srCore.srLogger.info("Extracting file " + tar_download_path)
            tar = tarfile.open(tar_download_path)
            tar.extractall(sr_update_dir)
            tar.close()

            # delete .tar.gz
            sickrage.srCore.srLogger.info("Deleting file " + tar_download_path)
            os.remove(tar_download_path)

            # find update dir name
            update_dir_contents = [x for x in os.listdir(sr_update_dir) if
                                   os.path.isdir(os.path.join(sr_update_dir, x))]
            if len(update_dir_contents) != 1:
                sickrage.srCore.srLogger.error("Invalid update data, update failed: " + str(update_dir_contents))
                return False
            content_dir = os.path.join(sr_update_dir, update_dir_contents[0])

            # walk temp folder and move files to main folder
            sickrage.srCore.srLogger.info("Moving files from " + content_dir + " to " + sickrage.PROG_DIR)
            for dirname, _, filenames in os.walk(content_dir):
                dirname = dirname[len(content_dir) + 1:]
                for curfile in filenames:
                    old_path = os.path.join(content_dir, dirname, curfile)
                    new_path = os.path.join(sickrage.PROG_DIR, dirname, curfile)

                    # Avoid DLL access problem on WIN32/64
                    # These files needing to be updated manually
                    # or find a way to kill the access from memory
                    if curfile in ('unrar.dll', 'unrar64.dll'):
                        try:
                            os.chmod(new_path, stat.S_IWRITE)
                            os.remove(new_path)
                            os.renames(old_path, new_path)
                        except Exception as e:
                            sickrage.srCore.srLogger.debug("Unable to update " + new_path + ': ' + e.message)
                            os.remove(old_path)  # Trash the updated file without moving in new path
                        continue

                    if os.path.isfile(new_path):
                        os.remove(new_path)
                    os.renames(old_path, new_path)

        except Exception as e:
            sickrage.srCore.srLogger.error("Error while trying to update: {}".format(e.message))
            sickrage.srCore.srLogger.debug("Traceback: " + traceback.format_exc())
            return False

        # Notify update successful
        if sickrage.srCore.srConfig.NOTIFY_ON_UPDATE:
            srNotifiers.notify_version_update(self.get_newest_version)

        return True