示例#1
0
        def on_process():
            try:
                result = self._process(*self.current_pair)

                if result["error"] is not None:
                    self.current_error = result["error"]

                self.was_processed.emit(result)
            except Exception:
                exc_type, exc_msg, exc_tb = sys.exc_info()
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration as e:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                exc_type, exc_msg, exc_tb = sys.exc_info()
                self.current_pair = (None, None)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            util.defer(10, on_next)
示例#2
0
        def on_next():
            self.log.debug("Looking for next pair to process")
            try:
                self.current_pair = next(self.pair_generator)
                if isinstance(self.current_pair, IterationBreak):
                    raise self.current_pair

            except IterationBreak:
                self.log.debug("Iteration break was raised")
                self.is_running = False
                self.was_stopped.emit()
                return

            except StopIteration:
                self.log.debug("Iteration stop was raised")
                self.is_running = False
                # All pairs were processed successfully!
                return util.defer(500, on_finished)

            except Exception as exc:
                self.log.warning(
                    "Unexpected exception during `on_next` happened",
                    exc_info=True)
                exc_msg = str(exc)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            self.about_to_process.emit(*self.current_pair)
            util.defer(100, on_process)
示例#3
0
文件: control.py 项目: jrsndl/pype
        def on_next():
            try:
                self.current_pair = next(self.pair_generator)
                if isinstance(self.current_pair, IterationBreak):
                    raise self.current_pair

            except IterationBreak:
                self.is_running = False
                self.was_stopped.emit()
                return

            except StopIteration:
                self.is_running = False
                # All pairs were processed successfully!
                return util.defer(500, on_finished)

            except Exception:
                # This is a bug
                exc_type, exc_msg, exc_tb = sys.exc_info()
                traceback.print_exception(exc_type, exc_msg, exc_tb)
                self.is_running = False
                self.was_stopped.emit()
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            self.about_to_process.emit(*self.current_pair)
            util.defer(100, on_process)
示例#4
0
    def act(self, plugin, action):
        context = self.context

        def on_next():
            result = pyblish.plugin.process(plugin, context, None, action.id)
            self.was_acted.emit(result)

        util.defer(100, on_next)
示例#5
0
    def act(self, plugin, action):
        context = self.context

        def on_next():
            result = pyblish.plugin.process(plugin, context, None, action.id)
            self.was_acted.emit(result)

        util.defer(100, on_next)
示例#6
0
    def iterate_and_process(self, on_finished=lambda: None):
        """ Iterating inserted plugins with current context.
        Collectors do not contain instances, they are None when collecting!
        This process don't stop on one
        """
        def on_next():
            try:
                self.current_pair = next(self.pair_generator)
                if isinstance(self.current_pair, IterationBreak):
                    raise self.current_pair

            except IterationBreak:
                self.is_running = False
                self.was_stopped.emit()
                return

            except StopIteration:
                self.is_running = False
                # All pairs were processed successfully!
                return util.defer(500, on_finished)

            except Exception:
                # This is a bug
                exc_type, exc_msg, exc_tb = sys.exc_info()
                traceback.print_exception(exc_type, exc_msg, exc_tb)
                self.is_running = False
                self.was_stopped.emit()
                return util.defer(
                    500, lambda: on_unexpected_error(error=exc_msg)
                )

            self.about_to_process.emit(*self.current_pair)
            util.defer(100, on_process)

        def on_process():
            try:
                result = self._process(*self.current_pair)
                if result["error"] is not None:
                    self.errored = True

                self.was_processed.emit(result)

            except Exception:
                # TODO this should be handled much differently
                exc_type, exc_msg, exc_tb = sys.exc_info()
                traceback.print_exception(exc_type, exc_msg, exc_tb)
                return util.defer(
                    500, lambda: on_unexpected_error(error=exc_msg)
                )

            util.defer(10, on_next)

        def on_unexpected_error(error):
            util.u_print(u"An unexpected error occurred:\n %s" % error)
            return util.defer(500, on_finished)

        self.is_running = True
        util.defer(10, on_next)
示例#7
0
文件: control.py 项目: jrsndl/pype
    def act(self, plugin, action):
        def on_next():
            result = pyblish.plugin.process(plugin, self.context, None,
                                            action.id)
            self.is_running = False
            self.was_acted.emit(result)

        self.is_running = True
        util.defer(100, on_next)
示例#8
0
    def iterate_and_process(self, plugins, on_finished=lambda: None):
        """ Iterating inserted plugins with current context.
        Collectors do not contain instances, they are None when collecting!
        This process don't stop on one
        """
        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished_)
            self.about_to_process.emit(*self.current_pair)
            util.defer(100, on_process)

        def on_process():
            try:
                result = self._process(*self.current_pair)

                if result["error"] is not None:
                    self.current_error = result["error"]

                self.was_processed.emit(result)
            except Exception:
                exc_type, exc_msg, exc_tb = sys.exc_info()
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration as e:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                exc_type, exc_msg, exc_tb = sys.exc_info()
                self.current_pair = (None, None)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            util.defer(10, on_next)

        def on_unexpected_error(error):
            util.u_print(u"An unexpected error occurred:\n %s" % error)
            return util.defer(500, on_finished_)

        def on_finished_():
            ''' if `self.is_running` is False then processing was stopped by
            Stop button so we do not want to execute on_finish method!
            '''
            if self.is_running:
                on_finished()

        self.is_running = True
        self.pair_generator = self._pair_yielder(plugins)
        self.current_pair = next(self.pair_generator, (None, None))
        util.defer(10, on_next)
示例#9
0
 def on_unexpected_error(error):
     # TODO this should be handled much differently
     # TODO emit crash signal to show message box with traceback?
     self.is_running = False
     self.was_stopped.emit()
     util.u_print(u"An unexpected error occurred:\n %s" % error)
     return util.defer(500, on_finished)
示例#10
0
文件: control.py 项目: jrsndl/pype
        def on_process():
            try:
                result = self._process(*self.current_pair)
                if result["error"] is not None:
                    self.errored = True

                self.was_processed.emit(result)

            except Exception:
                # TODO this should be handled much differently
                exc_type, exc_msg, exc_tb = sys.exc_info()
                traceback.print_exception(exc_type, exc_msg, exc_tb)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            util.defer(10, on_next)
示例#11
0
        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished)

            # The magic number 0.5 is the range between
            # the various CVEI processing stages;
            # e.g.
            #  - Collection is 0 +- 0.5 (-0.5 - 0.5)
            #  - Validation is 1 +- 0.5 (0.5  - 1.5)
            #
            # TODO(marcus): Make this less magical
            #
            if self.current_pair[0].order > (until + 0.5):
                return util.defer(100, on_finished)

            self.about_to_process.emit(*self.current_pair)

            util.defer(10, on_process)
示例#12
0
        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished_)

            # The magic number 0.5 is the range between
            # the various CVEI processing stages;
            # e.g.
            #  - Collection is 0 +- 0.5 (-0.5 - 0.5)
            #  - Validation is 1 +- 0.5 (0.5  - 1.5)
            #
            # TODO(marcus): Make this less magical
            #
            order = self.current_pair[0].order
            if order > (until + 0.5):
                return util.defer(100, on_finished_)

            self.about_to_process.emit(*self.current_pair)

            util.defer(10, on_process)
示例#13
0
        def on_process():
            try:
                self.log.debug("Processing pair: {}".format(
                    str(self.current_pair)))
                result = self._process(*self.current_pair)
                if result["error"] is not None:
                    self.log.debug("Error happened")
                    self.errored = True

                self.log.debug("Pair processed")
                self.was_processed.emit(result)

            except Exception as exc:
                self.log.warning(
                    "Unexpected exception during `on_process` happened",
                    exc_info=True)
                exc_msg = str(exc)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            util.defer(10, on_next)
示例#14
0
        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished_)

            # The magic number 0.5 is the range between
            # the various CVEI processing stages;
            # e.g.
            #  - Collection is 0 +- 0.5 (-0.5 - 0.5)
            #  - Validation is 1 +- 0.5 (0.5  - 1.5)
            #
            # TODO(marcus): Make this less magical
            #
            order = self.current_pair[0].order
            if order > (until + 0.5):
                return util.defer(100, on_finished_)

            # The instance may have been disabled, check because the iterator will
            # have already provided it
            if self._current_pair_is_active():
                self.about_to_process.emit(*self.current_pair)

            util.defer(10, on_process)
示例#15
0
        def on_process():
            try:
                if self._current_pair_is_active():
                    result = self._process(*self.current_pair)

                    if result["error"] is not None:
                        self.current_error = result["error"]

                    self.was_processed.emit(result)

            except Exception as e:
                stack = traceback.format_exc()
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            # Now that processing has completed, and context potentially
            # modified with new instances, produce the next pair.
            #
            # IMPORTANT: This *must* be done *after* processing of
            # the current pair, otherwise data generated at that point
            # will *not* be included.
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                stack = traceback.format_exc()
                self.current_pair = (None, None)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            util.defer(10, on_next)
示例#16
0
        def on_process():
            try:
                result = self._process(*self.current_pair)

                if result["error"] is not None:
                    self.current_error = result["error"]

                self.was_processed.emit(result)

            except Exception as e:
                stack = traceback.format_exc(e)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            # Now that processing has completed, and context potentially
            # modified with new instances, produce the next pair.
            #
            # IMPORTANT: This *must* be done *after* processing of
            # the current pair, otherwise data generated at that point
            # will *not* be included.
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                stack = traceback.format_exc(e)
                self.current_pair = (None, None)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            util.defer(10, on_next)
示例#17
0
    def iterate_and_process(self, on_finished=lambda: None):
        """ Iterating inserted plugins with current context.
        Collectors do not contain instances, they are None when collecting!
        This process don't stop on one
        """
        def on_next():
            self.log.debug("Looking for next pair to process")
            try:
                self.current_pair = next(self.pair_generator)
                if isinstance(self.current_pair, IterationBreak):
                    raise self.current_pair

            except IterationBreak:
                self.log.debug("Iteration break was raised")
                self.is_running = False
                self.was_stopped.emit()
                return

            except StopIteration:
                self.log.debug("Iteration stop was raised")
                self.is_running = False
                # All pairs were processed successfully!
                return util.defer(500, on_finished)

            except Exception as exc:
                self.log.warning(
                    "Unexpected exception during `on_next` happened",
                    exc_info=True)
                exc_msg = str(exc)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            self.about_to_process.emit(*self.current_pair)
            util.defer(100, on_process)

        def on_process():
            try:
                self.log.debug("Processing pair: {}".format(
                    str(self.current_pair)))
                result = self._process(*self.current_pair)
                if result["error"] is not None:
                    self.log.debug("Error happened")
                    self.errored = True

                self.log.debug("Pair processed")
                self.was_processed.emit(result)

            except Exception as exc:
                self.log.warning(
                    "Unexpected exception during `on_process` happened",
                    exc_info=True)
                exc_msg = str(exc)
                return util.defer(500,
                                  lambda: on_unexpected_error(error=exc_msg))

            util.defer(10, on_next)

        def on_unexpected_error(error):
            # TODO this should be handled much differently
            # TODO emit crash signal to show message box with traceback?
            self.is_running = False
            self.was_stopped.emit()
            util.u_print(u"An unexpected error occurred:\n %s" % error)
            return util.defer(500, on_finished)

        self.is_running = True
        util.defer(10, on_next)
示例#18
0
 def on_unexpected_error(error):
     util.u_print(u"An unexpected error occurred:\n %s" % error)
     return util.defer(500, on_finished_)
示例#19
0
 def on_next():
     if self.current_pair == (None, None):
         return util.defer(100, on_finished_)
     self.about_to_process.emit(*self.current_pair)
     util.defer(100, on_process)
示例#20
0
    def _run(self, until=float("inf"), on_finished=lambda: None):
        """Process current pair and store next pair for next process

        Arguments:
            until (pyblish.api.Order, optional): Keep fetching next()
                until this order, default value is infinity.
            on_finished (callable, optional): What to do when finishing,
                defaults to doing nothing.

        """

        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished_)

            # The magic number 0.5 is the range between
            # the various CVEI processing stages;
            # e.g.
            #  - Collection is 0 +- 0.5 (-0.5 - 0.5)
            #  - Validation is 1 +- 0.5 (0.5  - 1.5)
            #
            # TODO(marcus): Make this less magical
            #
            order = self.current_pair[0].order
            if order > (until + 0.5):
                return util.defer(100, on_finished_)

            self.about_to_process.emit(*self.current_pair)

            util.defer(10, on_process)

        def on_process():
            try:
                result = self._process(*self.current_pair)

                if result["error"] is not None:
                    self.current_error = result["error"]

                self.was_processed.emit(result)

            except Exception as e:
                stack = traceback.format_exc(e)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            # Now that processing has completed, and context potentially
            # modified with new instances, produce the next pair.
            #
            # IMPORTANT: This *must* be done *after* processing of
            # the current pair, otherwise data generated at that point
            # will *not* be included.
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                stack = traceback.format_exc(e)
                self.current_pair = (None, None)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            util.defer(10, on_next)

        def on_unexpected_error(error):
            util.u_print(u"An unexpected error occurred:\n %s" % error)
            return util.defer(500, on_finished_)

        def on_finished_():
            on_finished()
            self.was_finished.emit()

        self.is_running = True
        util.defer(10, on_next)
示例#21
0
 def on_unexpected_error(error):
     util.u_print(u"An unexpected error occurred:\n %s" % error)
     return util.defer(500, on_finished_)
示例#22
0
    def _run(self, until=float("inf"), on_finished=lambda: None):
        """Process current pair and store next pair for next process

        Arguments:
            until (pyblish.api.Order, optional): Keep fetching next()
                until this order, default value is infinity.
            on_finished (callable, optional): What to do when finishing,
                defaults to doing nothing.

        """

        def on_next():
            if self.current_pair == (None, None):
                return util.defer(100, on_finished_)

            # The magic number 0.5 is the range between
            # the various CVEI processing stages;
            # e.g.
            #  - Collection is 0 +- 0.5 (-0.5 - 0.5)
            #  - Validation is 1 +- 0.5 (0.5  - 1.5)
            #
            # TODO(marcus): Make this less magical
            #
            order = self.current_pair[0].order
            if order > (until + 0.5):
                return util.defer(100, on_finished_)

            self.about_to_process.emit(*self.current_pair)

            util.defer(10, on_process)

        def on_process():
            try:
                result = self._process(*self.current_pair)

                if result["error"] is not None:
                    self.current_error = result["error"]

                self.was_processed.emit(result)

            except Exception as e:
                stack = traceback.format_exc()
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            # Now that processing has completed, and context potentially
            # modified with new instances, produce the next pair.
            #
            # IMPORTANT: This *must* be done *after* processing of
            # the current pair, otherwise data generated at that point
            # will *not* be included.
            try:
                self.current_pair = next(self.pair_generator)

            except StopIteration:
                # All pairs were processed successfully!
                self.current_pair = (None, None)
                return util.defer(500, on_finished_)

            except Exception as e:
                # This is a bug
                stack = traceback.format_exc()
                self.current_pair = (None, None)
                return util.defer(
                    500, lambda: on_unexpected_error(error=stack))

            util.defer(10, on_next)

        def on_unexpected_error(error):
            util.u_print(u"An unexpected error occurred:\n %s" % error)
            return util.defer(500, on_finished_)

        def on_finished_():
            on_finished()
            self.was_finished.emit()

        self.is_running = True
        util.defer(10, on_next)
示例#23
0
 def on_unexpected_error(error):
     self.warning("An unexpected error occurred; "
                  "see Terminal for more.")
     return util.defer(500, on_finished)
示例#24
0
 def on_next():
     result = pyblish.plugin.process(plugin, context, None, action.id)
     self.was_processed.emit(result)
     util.defer(500, self.was_acted.emit)
示例#25
0
 def on_unexpected_error(error):
     self.warning("An unexpected error occurred; "
                  "see Terminal for more.")
     return util.defer(500, on_finished_)