Esempio n. 1
0
    def _execute(self, *args):
        """
        Execute all phases on the image.

        :return: None
        """
        for p in (x for x in
                  self.__phases[self.__starting_step:self.__ending_step]):
            r = run_worker(p, self.__image_steps, config=self._args)
            self.__image_steps.append(r)

            if self.__altered_path:
                if (self._args.get('folder_altered')):
                    path = self._args['folder_altered']
                else:
                    path = self.__altered_path

                write_image(r, os.path.join(path, "{}.png".format(p.__name__)))

                Conf.log.debug("{} Step Image Of {} Execution".format(
                    os.path.join(path, "{}.png".format(p.__name__)),
                    camel_case_to_str(p.__name__),
                ))

        write_image(self.__image_steps[-1], self.__output_path)
        Conf.log.info("{} Created".format(self.__output_path))
        Conf.log.debug("{} Result Image Of {} Execution".format(
            self.__output_path, camel_case_to_str(self.__class__.__name__)))

        return self.__image_steps[-1]
Esempio n. 2
0
    def _execute(self, *args):
        """
        Execute all phases on the image.

        :return: None
        """
        # todo: refactor me, please!
        # with this we force the auto-resize for dreamtime, but it is far from ideal
        if self.__starting_step == 5:
            r = run_worker(self.__phases[0], self.__image_steps, config=self._args)
            self.__image_steps.append(r)

        for step,p in enumerate(x for x in self.__phases[self.__starting_step:self.__ending_step]):
            r = run_worker(p, self.__image_steps, config=self._args)
            self.__image_steps.append(r)

            # todo: refactor me, please!
            if self._args.get('export_step'):
                if self._args.get('export_step') == (step-1):
                    step_path = self._args.get('export_step_path') or os.path.abspath(os.path.join(self.__output_path, '..', 'export.png'))

                    write_image(r, step_path)

                    Conf.log.debug("Export Step Image Of {} Execution: {}".format(
                        camel_case_to_str(p.__name__),
                        step_path
                    ))

            if self.__altered_path:
                if (self._args.get('folder_altered')):
                    path = self._args['folder_altered']
                else:
                    path = self.__altered_path

                write_image(r, os.path.join(path, "{}.png".format(p.__name__)))

                Conf.log.debug("{} Step Image Of {} Execution".format(
                    os.path.join(path, "{}.png".format(p.__name__)),
                    camel_case_to_str(p.__name__),
                ))

        write_image(self.__image_steps[-1], self.__output_path)
        Conf.log.info("{} Created".format(self.__output_path))
        Conf.log.debug("{} Result Image Of {} Execution"
                       .format(self.__output_path, camel_case_to_str(self.__class__.__name__)))

        return self.__image_steps[-1]