コード例 #1
0
 def verify_checksum(self, calculated, from_metadata, path):
     if calculated != from_metadata:
         raise PulpCodedTaskFailedException(
             DEBSYNC002,
             repo_id=self.get_repo().repo_obj.repo_id,
             feed_url=self.parent.feed_url,
             filename=os.path.basename(path),
             checksum_expected=from_metadata,
             checksum_actual=calculated)
コード例 #2
0
ファイル: sync.py プロジェクト: Kryndex/pulp_deb
 def process_main(self, item=None):
     path_to_unit = self.parent.step_download_units.path_to_unit
     repo = self.get_repo().repo_obj
     for path, unit in sorted(path_to_unit.items()):
         # Verify checksum first
         with open(path, "rb") as fobj:
             csum = unit._compute_checksum(fobj)
         if csum != unit.checksum:
             raise PulpCodedTaskFailedException(
                 DEBSYNC002, repo_id=self.get_repo().repo_obj.repo_id,
                 feed_url=self.parent.feed_url,
                 filename=os.path.basename(path),
                 checksum_expected=unit.checksum,
                 checksum_actual=csum)
         unit.save_and_associate(path, repo)
コード例 #3
0
 def process_main(self, item=None):
     self.parent.apt_repo_meta = repometa = aptrepo.AptRepoMeta(
         release=open(self.parent.release_file, "rb"),
         upstream_url=self.parent.feed_url)
     components = list(repometa.iter_component_arch_binaries())
     if len(components) != 1:
         raise PulpCodedTaskFailedException(
             DEBSYNC001,
             repo_id=self.get_repo().repo_obj.repo_id,
             feed_url=self.parent.feed_url,
             comp_count=len(components))
     dl_reqs = repometa.create_Packages_download_requests(
         self.get_working_dir())
     self.parent.step_download_Packages._downloads = [
         DownloadRequest(x.url, x.destination, data=x.data) for x in dl_reqs
     ]
コード例 #4
0
ファイル: publish_step.py プロジェクト: zjhuntin/pulp
    def process(self):
        """
        The process method is used to perform the work needed for this step.
        It will update the step progress and raise an exception on error.
        """
        if self.canceled:
            return

        if self.is_skipped():
            self.state = reporting_constants.STATE_SKIPPED
            return

        self.state = reporting_constants.STATE_RUNNING

        try:
            try:
                self.total_units = self._get_total()
                self.report_progress()
                self.initialize()
                self.report_progress()
                if self.get_iterator():
                    # We are using a generator and will call _process_block for each item
                    for item in self.get_iterator():
                        try:
                            self._process_block(item=item)
                        except Exception as e:
                            raise_exception = True
                            for exception in self.non_halting_exceptions:
                                if isinstance(e, exception):
                                    raise_exception = False
                                    self._record_failure(e=e)
                                    self.exceptions.append(e)
                                    break
                            if raise_exception:
                                raise
                        # Clen out the progress_details for the individual item
                        self.progress_details = ""
                    if self.exceptions:
                        raise PulpCodedTaskFailedException(
                            error_code=error_codes.PLP0032,
                            task_id=self.status_conduit.task_id)
                else:
                    self._process_block()
                self.progress_details = ""
                # Double check & return if we have been canceled
                if self.canceled:
                    return
            finally:
                # Always call finalize to allow cleanup of file handles
                self.finalize()
            self.post_process()
        except Exception as e:
            tb = sys.exc_info()[2]
            if not isinstance(e, PulpCodedTaskFailedException):
                self._record_failure(e, tb)
            parent = self
            while parent:
                parent.state = reporting_constants.STATE_FAILED
                try:
                    parent.on_error()
                except Exception:
                    # Eat exceptions from the error handler since we
                    # still want to notify up the tree
                    pass
                parent = parent.parent
            raise

        self.state = reporting_constants.STATE_COMPLETE