コード例 #1
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        if not self.install_requirements(self.current_branch):
            return False

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

        __, __, exit_status = self._git_cmd(
            self._git_path,
            'pull -f {} {}'.format(sickrage.app.config.git_remote,
                                   self.current_branch))
        if exit_status == 0:
            sickrage.app.log.info("Updating SiCKRAGE from GIT servers")
            sickrage.app.alerts.message(
                _('Updater'), _('Updating SiCKRAGE from GIT servers'))
            Notifiers.mass_notify_version_update(self.get_newest_version)
            return True

        return False
コード例 #2
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        if sickrage.app.config.git_reset:
            self.reset()

        if not self.upgrade_pip():
            return False

        if not self.install_requirements(self.current_branch):
            return False

        __, __, exit_status = self._git_cmd(
            self._git_path,
            'pull -f {} {}'.format(sickrage.app.config.git_remote,
                                   self.current_branch))
        if exit_status == 0:
            sickrage.app.log.info("Updating SiCKRAGE from GIT servers")
            sickrage.app.alerts.message(
                _('Updater'), _('Updating SiCKRAGE from GIT servers'))
            Notifiers.mass_notify_version_update(self.get_newest_version)
            return True

        return False
コード例 #3
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.gz?ref={}'.format(('master', 'develop')['dev' in self.version])

        try:
            if not self.install_requirements(self.current_branch):
                return False

            with tempfile.TemporaryFile() as update_tarfile:
                sickrage.app.log.info("Downloading update from " + repr(tar_download_url))
                update_tarfile.write(WebSession().get(tar_download_url).content)
                update_tarfile.seek(0)

                with tempfile.TemporaryDirectory(prefix='sr_update_', dir=sickrage.app.data_dir) as unpack_dir:
                    sickrage.app.log.info("Extracting SiCKRAGE update file")
                    try:
                        tar = tarfile.open(fileobj=update_tarfile, mode='r:gz')
                        tar.extractall(unpack_dir)
                        tar.close()
                    except tarfile.ReadError:
                        sickrage.app.log.warning("Invalid update data, update failed: not a gzip file")
                        return False

                    # find update dir name
                    update_dir_contents = [x for x in os.listdir(unpack_dir) if os.path.isdir(os.path.join(unpack_dir, x))]
                    if len(update_dir_contents) != 1:
                        sickrage.app.log.warning("Invalid update data, update failed: " + str(update_dir_contents))
                        return False

                    # walk temp folder and move files to main folder
                    content_dir = os.path.join(unpack_dir, update_dir_contents[0])
                    sickrage.app.log.info("Moving files from " + content_dir + " to " + sickrage.MAIN_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.MAIN_DIR, dirname, curfile)

                            if os.path.isfile(new_path) and os.path.exists(new_path):
                                os.remove(new_path)

                            try:
                                shutil.move(old_path, new_path)
                            except IOError:
                                os.makedirs(os.path.dirname(new_path))
                                shutil.move(old_path, new_path)
        except Exception as e:
            sickrage.app.log.error("Error while trying to update: {}".format(e))
            return False

        # Notify update successful
        Notifiers.mass_notify_version_update(self.get_newest_version)

        return True
コード例 #4
0
    def update(self):
        """
        Performs pip upgrade
        """
        __, __, exit_status = self._pip_cmd(self._pip3_path, 'install -U --no-cache-dir sickrage')
        if exit_status == 0:
            sickrage.app.log.info("Updating SiCKRAGE from PyPi servers")
            sickrage.app.alerts.message(_('Updater'), _('Updating SiCKRAGE from PyPi servers'))
            Notifiers.mass_notify_version_update(self.get_newest_version)
            return True

        return False
コード例 #5
0
    def update(self):
        """
        Performs pip upgrade
        """
        __, __, exit_status = self._pip2_cmd(self._pip2_path, 'install -U --no-cache-dir sickrage')
        if exit_status == 0:
            sickrage.app.log.info("Updating SiCKRAGE from PyPi servers")
            sickrage.app.alerts.message(_('Updater'), _('Updating SiCKRAGE from PyPi servers'))
            Notifiers.mass_notify_version_update(self.get_newest_version)
            return True

        return False
コード例 #6
0
    def update(self):
        """
        Calls git pull origin <branch> in order to update SiCKRAGE. Returns a bool depending
        on the call's success.
        """

        if not self.install_requirements(self.current_branch):
            return False

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

        __, __, exit_status = self._git_cmd(self._git_path, 'pull -f {} {}'.format(sickrage.app.config.git_remote,
                                                                                   self.current_branch))
        if exit_status == 0:
            sickrage.app.log.info("Updating SiCKRAGE from GIT servers")
            sickrage.app.alerts.message(_('Updater'),
                                        _('Updating SiCKRAGE from GIT servers'))
            Notifiers.mass_notify_version_update(self.get_newest_version)
            return True

        return False
コード例 #7
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.app.data_dir, 'sr-update')

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

            sickrage.app.log.info("Creating update folder " + sr_update_dir +
                                  " before extracting")
            try:
                os.makedirs(sr_update_dir)
            except OSError as e:
                sickrage.app.log.warning("Unable to create update folder " +
                                         sr_update_dir + ': ' + str(e))
                return False

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

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

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

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

            # delete .tar.gz
            sickrage.app.log.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.app.log.warning(
                    "Invalid update data, update failed: " +
                    str(update_dir_contents))
                return False

            # walk temp folder and move files to main folder
            content_dir = os.path.join(sr_update_dir, update_dir_contents[0])
            sickrage.app.log.info("Moving files from " + content_dir + " to " +
                                  sickrage.MAIN_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.MAIN_DIR, dirname,
                                            curfile)

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

            # install requirements
            if not self.install_requirements():
                return False
        except Exception as e:
            sickrage.app.log.error(
                "Error while trying to update: {}".format(e))
            return False

        # Notify update successful
        Notifiers.mass_notify_version_update(self.get_newest_version)

        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.gz?ref={}'.format(
            ('master', 'develop')['dev' in self.version])

        try:
            if not self.upgrade_pip():
                return False

            if not self.install_requirements(self.current_branch):
                return False

            with tempfile.TemporaryFile() as update_tarfile:
                sickrage.app.log.info("Downloading update from " +
                                      repr(tar_download_url))
                resp = WebSession().get(tar_download_url)
                if not resp or not resp.content:
                    sickrage.app.log.warning(
                        'Failed to download SiCKRAGE update')
                    return False

                update_tarfile.write(resp.content)
                update_tarfile.seek(0)

                with tempfile.TemporaryDirectory(
                        prefix='sr_update_',
                        dir=sickrage.app.data_dir) as unpack_dir:
                    sickrage.app.log.info("Extracting SiCKRAGE update file")
                    try:
                        tar = tarfile.open(fileobj=update_tarfile, mode='r:gz')
                        tar.extractall(unpack_dir)
                        tar.close()
                    except tarfile.TarError:
                        sickrage.app.log.warning(
                            "Invalid update data, update failed: not a gzip file"
                        )
                        return False

                    if len(os.listdir(unpack_dir)) != 1:
                        sickrage.app.log.warning(
                            "Invalid update data, update failed")
                        return False

                    update_dir = os.path.join(
                        *[unpack_dir,
                          os.listdir(unpack_dir)[0], 'sickrage'])
                    sickrage.app.log.info("Sync folder {} to {}".format(
                        update_dir, sickrage.PROG_DIR))
                    dirsync.sync(update_dir,
                                 sickrage.PROG_DIR,
                                 'sync',
                                 purge=True)
        except Exception as e:
            sickrage.app.log.error(
                "Error while trying to update: {}".format(e))
            return False

        # Notify update successful
        Notifiers.mass_notify_version_update(self.get_newest_version)

        return True
コード例 #9
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:
            if not self.install_requirements(self.current_branch):
                return False

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

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

            sickrage.app.log.info("Creating update folder " + sr_update_dir + " before extracting")
            try:
                os.makedirs(sr_update_dir)
            except OSError as e:
                sickrage.app.log.warning("Unable to create update folder " + sr_update_dir + ': ' + str(e))
                return False

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

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

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

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

            # delete .tar.gz
            sickrage.app.log.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.app.log.warning("Invalid update data, update failed: " + str(update_dir_contents))
                return False

            # walk temp folder and move files to main folder
            content_dir = os.path.join(sr_update_dir, update_dir_contents[0])
            sickrage.app.log.info("Moving files from " + content_dir + " to " + sickrage.MAIN_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.MAIN_DIR, dirname, curfile)

                    if os.path.isfile(new_path) and os.path.exists(new_path):
                        os.remove(new_path)

                    try:
                        shutil.move(old_path, new_path)
                    except IOError:
                        os.makedirs(os.path.dirname(new_path))
                        shutil.move(old_path, new_path)
        except Exception as e:
            sickrage.app.log.error("Error while trying to update: {}".format(e))
            return False

        # Notify update successful
        Notifiers.mass_notify_version_update(self.get_newest_version)

        return True