Esempio n. 1
0
    def extract_info(self, package):
        """Gets version number, platform & hash for package.

        Args:

            package (str): filename
        """
        if not os.path.exists(package):
            msg = '{} does not exists'.format(package)
            log.debug(msg)
            self.info['reason'] = msg
            return
        if package in self.ignored_files:
            msg = 'Ignored file: {}'.format(package)
            log.debug(msg)
            self.info['reason'] = msg
            return
        if os.path.splitext(package)[1].lower() not in \
                self.supported_extensions:
            msg = 'Not a supported archive format: {}'.format(package)
            self.info['reason'] = msg
            log.warning(msg)
            return

        log.info('Extracting update archive info for: %s', package)
        try:
            v = Version(package)
            self.channel = v.channel
            self.version = str(v)
        except (UtilsError, VersionError):
            msg = 'Package version not formatted correctly'
            self.info['reason'] = msg
            log.error(msg)
            return
        log.debug('Got version info')

        try:
            self.platform = parse_platform(package)
        except UtilsError:
            msg = 'Package platform not formatted correctly'
            self.info['reason'] = msg
            log.error(msg)
            return
        log.debug('Got platform info')

        self.name = self._parse_package_name(package)
        log.debug('Got name of update: %s', self.name)
        self.info['status'] = True
        log.info('Info extraction complete')
Esempio n. 2
0
    def extract_info(self, package):
        """Gets version number, platform & hash for package.

        Args:

            package (str): filename
        """
        if not os.path.exists(package):
            msg = '{} does not exists'.format(package)
            log.debug(msg)
            self.info['reason'] = msg
            return
        if package in self.ignored_files:
            msg = 'Ignored file: {}'.format(package)
            log.debug(msg)
            self.info['reason'] = msg
            return
        if os.path.splitext(package)[1].lower() not in \
                self.supported_extensions:
            msg = 'Not a supported archive format: {}'.format(package)
            self.info['reason'] = msg
            log.warning(msg)
            return

        log.info('Extracting update archive info for: %s', package)
        try:
            v = Version(package)
            self.channel = v.channel
            self.version = str(v)
        except (UtilsError, VersionError):
            msg = 'Package version not formatted correctly'
            self.info['reason'] = msg
            log.error(msg)
            return
        log.debug('Got version info')

        try:
            self.platform = parse_platform(package)
        except UtilsError:
            msg = 'Package platform not formatted correctly'
            self.info['reason'] = msg
            log.error(msg)
            return
        log.debug('Got platform info')

        self.name = self._parse_package_name(package)
        log.debug('Got name of update: %s', self.name)
        self.info['status'] = True
        log.info('Info extraction complete')
Esempio n. 3
0
 def test_parse_platform_fail(self):
     with pytest.raises(UtilsError):
         parse_platform('app-nex-1.0.0.tar.gz')
Esempio n. 4
0
 def test_parse_platform(self):
     assert parse_platform('app-mac-0.1.0.tar.gz') == 'mac'
     assert parse_platform('app-win-1.0.0.zip') == 'win'
     assert parse_platform('Email Parser-mac-0.2.0.tar.gz') == 'mac'
Esempio n. 5
0
 def test_parse_platform_fail(self):
     with pytest.raises(UtilsError):
         parse_platform('app-nex-1.0.0.tar.gz')
Esempio n. 6
0
 def test_parse_platform(self):
     assert parse_platform('app-mac-0.1.0.tar.gz') == 'mac'
     assert parse_platform('app-win-1.0.0.zip') == 'win'
     assert parse_platform('Email Parser-mac-0.2.0.tar.gz') == 'mac'