コード例 #1
0
ファイル: package_handler.py プロジェクト: timeyyy/PyUpdater
 def _add_patches_to_packages(self, package_manifest, patches):
     # ToDo: Increase the efficiency of this double for
     #       loop. Not sure if it can be done though
     if patches is not None and len(patches) >= 1:
         log.info('Adding patches to package list')
         for p in patches:
             # Not adding patch that are not complete
             if hasattr(p, 'ready') is False:
                 continue
             # Not adding patch that are not complete
             if hasattr(p, 'ready') and p.ready is False:
                 continue
             for pm in package_manifest:
                 #
                 if p.dst_filename == pm.filename:
                     pm.patch_info['patch_name'] = \
                         os.path.basename(p.patch_name)
                     # Don't try to get hash on a ghost file
                     if not os.path.exists(p.patch_name):
                         p_name = ''
                     else:
                         p_name = gph(p.patch_name)
                     pm.patch_info['patch_hash'] = p_name
                     # No need to keep searching
                     # We have the info we need for this patch
                     break
                 else:
                     log.debug('No patch match found')
     else:
         if self.patch_support is True:
             log.warning('No patches found')
     return package_manifest
コード例 #2
0
 def _add_patches_to_packages(self, package_manifest, patches):
     # ToDo: Increase the efficiency of this double for
     #       loop. Not sure if it can be done though
     if patches is not None and len(patches) >= 1:
         log.info('Adding patches to package list')
         for p in patches:
             # Not adding patch that are not complete
             if hasattr(p, 'ready') is False:
                 continue
             # Not adding patch that are not complete
             if hasattr(p, 'ready') and p.ready is False:
                 continue
             for pm in package_manifest:
                 #
                 if p.dst_filename == pm.filename:
                     pm.patch_info['patch_name'] = \
                         os.path.basename(p.patch_name)
                     # Don't try to get hash on a ghost file
                     if not os.path.exists(p.patch_name):
                         p_name = ''
                     else:
                         p_name = gph(p.patch_name)
                     pm.patch_info['patch_hash'] = p_name
                     # No need to keep searching
                     # We have the info we need for this patch
                     break
                 else:
                     log.debug('No patch match found')
     else:
         if self.patch_support is True:
             log.warning('No patches found')
     return package_manifest
コード例 #3
0
ファイル: package_handler.py プロジェクト: timeyyy/PyUpdater
    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
コード例 #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