Ejemplo n.º 1
0
    def _update_check(self, name, version, channel, strict):
        valid_channels = ["alpha", "beta", "stable"]
        if channel not in valid_channels:
            log.debug("Invalid channel. May need to check spelling")
            channel = "stable"
        self.name = name

        # Version object used for comparison
        version = _Version(version)
        self.version = str(version)

        # Will be set to true if we are updating the currently
        # running app and not an app's asset
        app = False

        if self.ready is False:
            # No json data is loaded.
            # User may need to call refresh
            log.debug("No update manifest found")
            return None

        # Checking if version file is verified before
        # processing data contained in the version file.
        # This was done by self._get_update_manifest
        if self.verified is False:
            log.debug("Failed version file verification")
            return None

        # If we are an app we will need restart functionality, so we'll
        # user AppUpdate instead of LibUpdate
        if self.FROZEN is True and self.name == self.app_name:
            app = True

        log.debug("Checking for %s updates...", name)
        latest = get_highest_version(
            name, self.platform, channel, self.easy_data, strict
        )
        if latest is None:
            # If None is returned get_highest_version could
            # not find the supplied name in the version file
            log.debug("Could not find the latest version")
            return None

        # Change str to version object for easy comparison
        latest = _Version(latest)
        log.debug("Current version: %s", str(version))
        log.debug("Latest version: %s", str(latest))

        update_needed = latest > version
        log.debug("Update Needed: %s", update_needed)
        if latest <= version:
            log.debug("%s already updated to the latest version", name)
            return None

        # Config data to initialize update object
        data = {
            "strict": strict,
            "update_urls": self.update_urls,
            "name": self.name,
            "version": self.version,
            "easy_data": self.easy_data,
            "json_data": self.json_data,
            "data_dir": self.data_dir,
            "platform": self.platform,
            "channel": channel,
            "app_name": self.app_name,
            "verify": self.verify,
            "max_download_retries": self.max_download_retries,
            "progress_hooks": list(set(self.progress_hooks)),
            "urllib3_headers": self.urllib3_headers,
            "downloader": self.downloader,
        }

        data.update(self._gen_file_downloader_options())

        # Return update object with which handles downloading,
        # extracting updates
        if app is True:
            # AppUpdate is a subclass of LibUpdate that add methods
            # to restart the application
            return AppUpdate(data)
        else:
            return LibUpdate(data)
Ejemplo n.º 2
0
    def _update_check(self, name, version, channel):
        valid_channels = ['alpha', 'beta', 'stable']
        if channel not in valid_channels:
            log.error('Invalid channel. May need to check spelling')
            channel = 'stable'
        self.name = name
        version = Version(version)
        self.version = str(version)

        # Will be set to true if we are updating an app and not a lib
        app = False

        # No json data is loaded.
        # User may need to call refresh
        if self.ready is False:
            log.warning('No update manifest found')
            return None

        # If we are an app we will need restart functionality.
        # AppUpdate instead of LibUpdate
        if self.FROZEN is True and self.name == self.app_name:
            app = True
        # Checking if version file is verified before
        # processing data contained in the version file.
        # This was done by self._get_update_manifest()
        if self.verified is False:
            log.error('Failed version file verification')
            return None
        log.info('Checking for %s updates...', name)

        # If None is returned get_highest_version could
        # not find the supplied name in the version file
        latest = get_highest_version(name, self.platform,
                                     channel, self.easy_data)
        if latest is None:
            log.debug('Could not find the latest version')
            return None
        latest = Version(latest)
        log.debug('Current vesion: %s', str(version))
        log.debug('Latest version: %s', str(latest))
        needed = latest > version
        log.debug('Update Needed: %s', needed)
        if latest <= version:
            log.info('%s already updated to the latest version', name)
            return None
        # Hey, finally made it to the bottom!
        # Looks like its time to do some updating
        data = {
            'update_urls': self.update_urls,
            'name': self.name,
            'version': self.version,
            'easy_data': self.easy_data,
            'json_data': self.json_data,
            'data_dir': self.data_dir,
            'platform': self.platform,
            'channel': channel,
            'app_name': self.app_name,
            'verify': self.verify,
            # Ensure single occurrence of each callbackc
            'progress_hooks': list(set(self.progress_hooks)),
            }
        # Return update object with which handles downloading,
        # extracting updates
        if app is True:
            # AppUpdate objects also has methods to restart
            # the app with the new version
            return AppUpdate(data)
        else:
            return LibUpdate(data)
Ejemplo n.º 3
0
    def _update_check(self, name, version, channel, strict):
        valid_channels = ['alpha', 'beta', 'stable']
        if channel not in valid_channels:
            log.debug('Invalid channel. May need to check spelling')
            channel = 'stable'
        self.name = name

        # Version object used for comparison
        version = _Version(version)
        self.version = str(version)

        # Will be set to true if we are updating the currently
        # running app and not an app's asset
        app = False

        if self.ready is False:
            # No json data is loaded.
            # User may need to call refresh
            log.debug('No update manifest found')
            return None

        # Checking if version file is verified before
        # processing data contained in the version file.
        # This was done by self._get_update_manifest
        if self.verified is False:
            log.debug('Failed version file verification')
            return None

        # If we are an app we will need restart functionality, so we'll
        # user AppUpdate instead of LibUpdate
        if self.FROZEN is True and self.name == self.app_name:
            app = True

        log.debug('Checking for %s updates...', name)
        latest = _get_highest_version(name, self.platform, channel,
                                      self.easy_data, strict)
        if latest is None:
            # If None is returned get_highest_version could
            # not find the supplied name in the version file
            log.debug('Could not find the latest version')
            return None

        # Change str to version object for easy comparison
        latest = _Version(latest)
        log.debug('Current version: %s', str(version))
        log.debug('Latest version: %s', str(latest))

        update_needed = latest > version
        log.debug('Update Needed: %s', update_needed)
        if latest <= version:
            log.debug('%s already updated to the latest version', name)
            return None

        # Config data to initialize update object
        data = {
            'strict': strict,
            'update_urls': self.update_urls,
            'name': self.name,
            'version': self.version,
            'easy_data': self.easy_data,
            'json_data': self.json_data,
            'data_dir': self.data_dir,
            'platform': self.platform,
            'channel': channel,
            'app_name': self.app_name,
            'verify': self.verify,
            'max_download_retries': self.max_download_retries,
            'progress_hooks': list(set(self.progress_hooks)),
            'urllib3_headers': self.urllib3_headers,
        }

        # Return update object with which handles downloading,
        # extracting updates
        if app is True:
            # AppUpdate is a subclass of LibUpdate that add methods
            # to restart the application
            return AppUpdate(data)
        else:
            return LibUpdate(data)
Ejemplo n.º 4
0
    def _update_check(self, name, version):
        self.name = name
        version = Version(version)
        self.version = str(version)

        # Will be set to true if we are updating an app and not a lib
        app = False

        # No json data is loaded.
        # User may need to call refresh
        if self.ready is False:
            log.warning('No update manifest found')
            return None

        # If we are an app we will need restart functionality.
        # AppUpdate instead of LibUpdate
        if self.FROZEN is True and self.name == self.app_name:
            app = True
        # Checking if version file is verified before
        # processing data contained in the version file.
        # This was done by self._get_update_manifest()
        if self.verified is False:
            log.error('Failed version file verification')
            return None
        log.info('Checking for {} updates...'.format(name))

        # If None is returned get_highest_version could
        # not find the supplied name in the version file
        latest = get_highest_version(name, self.platform, self.easy_data)
        if latest is None:
            log.debug('Could not find the latest version')
            return None
        latest = Version(latest)
        log.debug('Current vesion: {}'.format(str(version)))
        log.debug('Latest version: {}'.format(str(latest)))
        log.debug('Update Truth: {}'.format(latest >= version))
        if latest <= version:
            log.info('{} already updated to the latest version'.format(name))
            return None
        # Hey, finally made it to the bottom!
        # Looks like its time to do some updating
        log.info('Update available')
        data = {
            'update_urls': self.update_urls,
            'name': self.name,
            'version': self.version,
            'easy_data': self.easy_data,
            'json_data': self.json_data,
            'data_dir': self.data_dir,
            'platform': self.platform,
            'app_name': self.app_name,
            'verify': self.verify,
            'progress_hooks': self.progress_hooks,
        }
        # Return update object with which handles downloading,
        # extracting updates
        if app is True:
            # AppUpdate objects also has methods to restart
            # the app with the new version
            return AppUpdate(data)
        else:
            return LibUpdate(data)