Ejemplo n.º 1
0
    def test_package_1(self):
        test_file_1 = 'jms-mac-0.0.1.zip'
        with ChDir(TEST_DATA_DIR):
            p1 = Package(test_file_1)

        assert p1.name == 'jms'
        assert p1.version == '0.0.1.2.0'
        assert p1.filename == test_file_1
        assert p1.platform == 'mac'
        assert p1.info['status'] is True
Ejemplo n.º 2
0
    def test_package_bad_extension(self):
        test_file_2 = 'pyu-win-0.0.2.bzip2'
        with ChDir(TEST_DATA_DIR):
            p2 = Package(test_file_2)

        assert p2.filename == test_file_2
        assert p2.name is None
        assert p2.version is None
        assert p2.info['status'] is False
        assert p2.info['reason'] == ('Not a supported archive format: '
                                     '{}'.format(test_file_2))
Ejemplo n.º 3
0
    def _get_package_list(self, ignore_errors=True):
        # Adds compatible packages to internal package manifest
        # for futher processing
        # Process all packages in new folder and gets
        # url, hash and some outer info.
        log.info('Getting package list')
        # Clears manifest if sign updates runs more the once without
        # app being restarted
        package_manifest = list()
        patch_manifest = list()
        bad_packages = list()
        with jms_utils.paths.ChDir(self.new_dir):
            # Getting a list of all files in the new dir
            packages = os.listdir(os.getcwd())
            for p in packages:
                # On package initialization we do the following
                # 1. Check for a supported archive
                # 2. get required info: version, platform, hash
                # If any check fails package.info['status'] will be False
                # You can query package.info['reason'] for the reason
                package = Package(p)
                if package.info['status'] is False:
                    # Package failed at something
                    # package.info['reason'] will tell why
                    bad_packages.append(package)
                    continue

                # Add package hash
                package.file_hash = gph(package.filename)
                self.json_data = self._update_file_list(self.json_data,
                                                        package)

                package_manifest.append(package)
                self.config = self._add_package_to_config(package,
                                                          self.config)

                if self.patch_support:
                    # Will check if source file for patch exists
                    # if so will return the path and number of patch
                    # to create. If missing source file None returned
                    path = self._check_make_patch(self.json_data,
                                                  package.name,
                                                  package.platform,
                                                  )
                    if path is not None:
                        log.info('Found source file to create patch')
                        patch_name = package.name + '-' + package.platform
                        src_path = path[0]
                        patch_number = path[1]
                        patch_info = dict(src=src_path,
                                          dst=os.path.abspath(p),
                                          patch_name=os.path.join(self.new_dir,
                                                                  patch_name),
                                          patch_num=patch_number,
                                          package=package.filename)
                        # ready for patching
                        patch_manifest.append(patch_info)
                    else:
                        log.warning('No source file to patch from')

        # ToDo: Expose this & remove "pragma: no cover" once done
        if ignore_errors is False:  # pragma: no cover
            log.warning('Bad package & reason for being naughty:')
            for b in bad_packages:
                log.warning(b.name, b.info['reason'])
        # End ToDo

        return package_manifest, patch_manifest
Ejemplo n.º 4
0
    def _get_package_list(self, ignore_errors=True):
        # Adds compatible packages to internal package manifest
        # for futher processing
        # Process all packages in new folder and gets
        # url, hash and some outer info.
        log.info('Getting package list')
        # Clears manifest if sign updates runs more the once without
        # app being restarted
        package_manifest = list()
        patch_manifest = list()
        bad_packages = list()
        with jms_utils.paths.ChDir(self.new_dir):
            # Getting a list of all files in the new dir
            packages = os.listdir(os.getcwd())
            for p in packages:
                # On package initialization we do the following
                # 1. Check for a supported archive
                # 2. get required info: version, platform, hash
                # If any check fails package.info['status'] will be False
                # You can query package.info['reason'] for the reason
                package = Package(p)
                if package.info['status'] is False:
                    # Package failed at something
                    # package.info['reason'] will tell why
                    bad_packages.append(package)
                    continue

                # Add package hash
                package.file_hash = gph(package.filename)
                self.json_data = self._update_file_list(
                    self.json_data, package)

                package_manifest.append(package)
                self.config = self._add_package_to_config(package, self.config)

                if self.patch_support:
                    # Will check if source file for patch exists
                    # if so will return the path and number of patch
                    # to create. If missing source file None returned
                    path = self._check_make_patch(
                        self.json_data,
                        package.name,
                        package.platform,
                    )
                    if path is not None:
                        log.info('Found source file to create patch')
                        patch_name = package.name + '-' + package.platform
                        src_path = path[0]
                        patch_number = path[1]
                        patch_info = dict(src=src_path,
                                          dst=os.path.abspath(p),
                                          patch_name=os.path.join(
                                              self.new_dir, patch_name),
                                          patch_num=patch_number,
                                          package=package.filename)
                        # ready for patching
                        patch_manifest.append(patch_info)
                    else:
                        log.warning('No source file to patch from')

        # ToDo: Expose this & remove "pragma: no cover" once done
        if ignore_errors is False:  # pragma: no cover
            log.warning('Bad package & reason for being naughty:')
            for b in bad_packages:
                log.warning(b.name, b.info['reason'])
        # End ToDo

        return package_manifest, patch_manifest
Ejemplo n.º 5
0
 def test_package_missing(self):
     test_file_4 = 'jms-nix-0.0.3.tar.gz'
     with ChDir(TEST_DATA_DIR):
         Package(test_file_4)
Ejemplo n.º 6
0
 def test_package_ignored_file(self):
     test_file_3 = '.DS_Store'
     with ChDir(TEST_DATA_DIR):
         Package(test_file_3)
Ejemplo n.º 7
0
 def test_package_bad_platform(self):
     with ChDir(TEST_DATA_DIR):
         p = Package('pyu-wi-1.1.tar.gz')
     assert p.info['reason'] == 'Package platform not formatted correctly'
Ejemplo n.º 8
0
 def test_package_bad_version(self):
     with ChDir(TEST_DATA_DIR):
         p = Package('pyu-win-1.tar.gz')
     assert p.info['reason'] == 'Package version not formatted correctly'
Ejemplo n.º 9
0
 def test_package_ignored_file(self):
     with open('.DS_Store', 'w') as f:
         f.write('')
     p = Package('.DS_Store')
     assert p.info['status'] is False