コード例 #1
0
ファイル: Queue.py プロジェクト: MartinSavko/mxcube3
def queue_stop():
    """
    Stop execution of the queue.

    :returns: Response object status code set to:
              200: On success
              409: Queue could not be stopped
    """

    if mxcube.queue.queue_hwobj._root_task is not None:
        mxcube.queue.queue_hwobj.stop()
    else:
        qe = mxcube.queue.queue_hwobj.get_current_entry()
        # check if a node/tas is executing and stop that one
        try:
            qe.stop()
        except Exception as ex:
            print 'exception...', ex

        logging.getLogger('user_level_log').info('Queue execution was aborted, ' + str(qe.get_data_model()))

        mxcube.queue.queue_hwobj.set_pause(False)
        # the next two is to avoid repeating the task
        # TODO: if you now run the queue it will be enabled and run
        qe.get_data_model().set_executed(True)
        qe.get_data_model().set_enabled(False)
        qe._execution_failed = True

        mxcube.queue.queue_hwobj._is_stopped = True
        signals.queue_execution_stopped()
        signals.collect_oscillation_failed()

    return Response(status=200)
コード例 #2
0
ファイル: Queue.py プロジェクト: meguiraun/mxcube3
def queue_stop():
    """
    Stop execution of the queue.

    :returns: Response object status code set to:
              200: On success
              409: Queue could not be stopped
    """
    if mxcube.queue.queue_hwobj._root_task is not None:
        mxcube.queue.queue_hwobj.stop()
    else:
        qe = mxcube.queue.queue_hwobj.get_current_entry()
        # check if a node/tas is executing and stop that one
        try:
            qe.stop()
        except Exception as ex:
            print str(ex)

        logging.getLogger('user_level_log').info(
            'Queue execution was aborted, ' + str(qe.get_data_model()))

        mxcube.queue.queue_hwobj.set_pause(False)
        # the next two is to avoid repeating the task
        # TODO: if you now run the queue it will be enabled and run
        qe.get_data_model().set_executed(True)
        qe.get_data_model().set_enabled(False)
        qe._execution_failed = True

        mxcube.queue.queue_hwobj._is_stopped = True
        signals.queue_execution_stopped()
        signals.collect_oscillation_failed()

    return Response(status=200)
コード例 #3
0
    def get_entry_with_model(self, model, root_queue_entry=None):
        """
        Find the entry with the data model model.

        :param model: The model to look for.
        :type model: TaskNode

        :returns: The QueueEntry with the model <model>
        :rtype: QueueEntry
        """
        if not root_queue_entry:
            root_queue_entry = self

        for queue_entry in root_queue_entry._queue_entry_list:
            if queue_entry.get_data_model() is model:
                return queue_entry
            else:
                result = self.get_entry_with_model(model, queue_entry)

                if result:
                    return result
コード例 #4
0
    def get_entry_with_model(self, model, root_queue_entry = None):
        """
        Find the entry with the data model model.

        :param model: The model to look for.
        :type model: TaskNode

        :returns: The QueueEntry with the model <model>
        :rtype: QueueEntry
        """
        if not root_queue_entry:
            root_queue_entry = self

        for queue_entry in root_queue_entry._queue_entry_list:
            if queue_entry.get_data_model() is model:
                return queue_entry
            else:
                result = self.get_entry_with_model(model, queue_entry)

                if result:
                    return result
コード例 #5
0
    def queue_entry_execution_finished(self, queue_entry, status):

        print "queue_entry_execution_finished... ", queue_entry, status
        view_item = queue_entry.get_view()
        item_model = queue_entry.get_data_model()

        item_type = None
        item_icon = None
        if isinstance(view_item, Qt4_queue_item.DataCollectionQueueItem):
            if item_model.is_helical():
                item_type = "Helical"
                item_icon = "Line"
            elif item_model.is_mesh():
                item_type = "Mesh"
                item_icon = "Grid"
            else:
                item_type = "OSC"
                item_icon = "Point"
        elif isinstance(view_item, Qt4_queue_item.EnergyScanQueueItem):
            item_type = "Energy scan"
            item_icon = "EnergyScan2"
        elif isinstance(view_item, Qt4_queue_item.XRFSpectrumQueueItem):
            item_type = "XRF spectrum"
            item_icon = "LineGraph"

        if item_type:
            info_str_list = QtCore.QStringList()
            info_str_list.append(datetime.now().strftime("%H:%M:%S"))
            info_str_list.append(item_type)
            info_str_list.append(status)

            temp_treewidget_item = QtGui.QTreeWidgetItem(info_str_list)
            if status != "Successful": 
                temp_treewidget_item.setBackgroundColor(0, Qt4_widget_colors.LIGHT_RED)
                temp_treewidget_item.setBackgroundColor(1, Qt4_widget_colors.LIGHT_RED)
                temp_treewidget_item.setBackgroundColor(2, Qt4_widget_colors.LIGHT_RED)
            if item_icon:
                temp_treewidget_item.setIcon(0, Qt4_Icons.load_icon(item_icon))
            self.history_tree_widget.insertTopLevelItem(0, temp_treewidget_item)