Пример #1
0
 def test_generate_fifo_queue(self):
     """
     Test threaded bool
     """
     test_queue = Queue.Queue()
     for i in range(10):
         test_queue.put(i)
     # check data is correct
     generator_output = [i for i in generate_fifo_queue(test_queue)]
     self.assertEqual(generator_output, range(10))
     # check ordering is not changed
     generator_output = [i for i in generate_fifo_queue(test_queue)]
     self.assertEqual(generator_output, range(1, 10) + [0])
     last = test_queue.get_nowait()
     test_queue.put(last)
     go_back_fifo_queue(test_queue)
     self.assertEqual(test_queue.get_nowait(), last)
Пример #2
0
 def test_generate_fifo_queue(self):
     """
     Test threaded bool
     """
     test_queue = Queue.Queue()
     for i in range(10):
         test_queue.put(i)
     # check data is correct
     generator_output = [i for i in generate_fifo_queue(test_queue)]
     self.assertEqual(generator_output, range(10))
     # check ordering is not changed
     generator_output = [i for i in generate_fifo_queue(test_queue)]
     self.assertEqual(generator_output, range(1, 10)+[0])
     last = test_queue.get_nowait()
     test_queue.put(last)
     go_back_fifo_queue(test_queue)
     self.assertEqual(test_queue.get_nowait(), last)
Пример #3
0
 def test_canvas_select(self):
     """Check that different canvases can be selected in the rotation"""
     select = self.ol_gui.window.get_frame("canvas_select", "list_box")
     target = select.GetEntry(6).GetText()
     # simulate GUI click (to select)
     select.Select(6, True)
     select.SelectionChanged()  # emit the signal (happens in GUI click)
     # check draw_titles were updated
     draw_titles = [x for x in \
               threading_utils.generate_fifo_queue(self.ol_gui._draw_titles)]
     self.assertTrue(target in draw_titles)
     # simulate GUI click (to unselect)
     select.Select(6, False)
     select.SelectionChanged()
     # check draw_titles were updated
     draw_titles = [x for x in \
               threading_utils.generate_fifo_queue(self.ol_gui._draw_titles)]
     self.assertFalse(target in draw_titles)
Пример #4
0
 def test_canvas_select(self):
     """Check that different canvases can be selected in the rotation"""
     select = self.ol_gui.window.get_frame("canvas_select", "list_box")
     target = select.GetEntry(6).GetText()
     # simulate GUI click (to select)
     select.Select(6, True)
     select.SelectionChanged() # emit the signal (happens in GUI click)
     # check draw_titles were updated
     draw_titles = [x for x in \
               threading_utils.generate_fifo_queue(self.ol_gui._draw_titles)]
     self.assertTrue(target in draw_titles)
     # simulate GUI click (to unselect)
     select.Select(6, False)
     select.SelectionChanged()
     # check draw_titles were updated
     draw_titles = [x for x in \
               threading_utils.generate_fifo_queue(self.ol_gui._draw_titles)]
     self.assertFalse(target in draw_titles)
Пример #5
0
    def _update_canvas_select(self):
        """
        Update the list of canvases in the canvas_select frame
        """
        all_canvas_titles = [wrap.canvas_wrapper.GetCanvas().GetTitle() \
                           for wrap in generate_fifo_queue(self._canvases_read)]

        select_box = self.window.get_frame("canvas_select", "list_box")
        select_box.RemoveAll()
        for i, title in enumerate(all_canvas_titles):
            select_box.AddEntry(title, i)
        for title in generate_fifo_queue(self._draw_titles):
            try:
                index = all_canvas_titles.index(title)
                select_box.Select(index)
            except ValueError: # item was no longer in the select - ignore it
                pass
        go_back_fifo_queue(self._draw_titles)
        # ROOT doesn't like redrawing the histogram titles properly - need to
        # force it
        self.window.get_frame("canvas_select", "list_box").Resize(200, 10)
        self.window.get_frame("canvas_select", "list_box").Resize(200, 200)
Пример #6
0
    def _update_canvas_select(self):
        """
        Update the list of canvases in the canvas_select frame
        """
        all_canvas_titles = [wrap.canvas_wrapper.GetCanvas().GetTitle() \
                           for wrap in generate_fifo_queue(self._canvases_read)]

        select_box = self.window.get_frame("canvas_select", "list_box")
        select_box.RemoveAll()
        for i, title in enumerate(all_canvas_titles):
            select_box.AddEntry(title, i)
        for title in generate_fifo_queue(self._draw_titles):
            try:
                index = all_canvas_titles.index(title)
                select_box.Select(index)
            except ValueError:  # item was no longer in the select - ignore it
                pass
        go_back_fifo_queue(self._draw_titles)
        # ROOT doesn't like redrawing the histogram titles properly - need to
        # force it
        self.window.get_frame("canvas_select", "list_box").Resize(200, 10)
        self.window.get_frame("canvas_select", "list_box").Resize(200, 200)
Пример #7
0
    def _filter_canvases(self, new_canvases):
        """
        Enforce that we only have one copy with a given (collection, title)

        Note that we want to keep the item with the highest input_time if there
        is a choice
        """
        combined_list = [wrap.deepcopy() \
                           for wrap in generate_fifo_queue(self._canvases_read)]
        combined_list += new_canvases
        combined_list.sort(key=lambda wrap: wrap.sort_key())

        if len(combined_list) == 0:
            return []
        filtered_list = []
        for i, item_2 in enumerate(combined_list[1:]):
            item_1 = combined_list[i]
            if item_1.collection == item_2.collection and \
               item_1.canvas_title() == item_2.canvas_title():
                pass
            else:
                filtered_list.append(item_1)
        filtered_list.append(combined_list[-1])
        return filtered_list
Пример #8
0
    def _filter_canvases(self, new_canvases):
        """
        Enforce that we only have one copy with a given (collection, title)

        Note that we want to keep the item with the highest input_time if there
        is a choice
        """
        combined_list = [wrap.deepcopy() \
                           for wrap in generate_fifo_queue(self._canvases_read)]
        combined_list += new_canvases
        combined_list.sort(key=lambda wrap: wrap.sort_key())

        if len(combined_list) == 0:
            return []
        filtered_list = []
        for i, item_2 in enumerate(combined_list[1:]):
            item_1 = combined_list[i]
            if item_1.collection == item_2.collection and \
               item_1.canvas_title() == item_2.canvas_title():
                pass
            else:
                filtered_list.append(item_1)
        filtered_list.append(combined_list[-1])
        return filtered_list
Пример #9
0
 def _get_canvas_list(cls, queue):
     """get a list of canvases in the queue"""
     gen = threading_utils.generate_fifo_queue(queue)
     threading_utils.go_back_fifo_queue(queue)
     return sorted([wrap.sort_key() for wrap in gen])
Пример #10
0
 def _update_canvases_draw(self):
     """update canvases"""
     draw = [wrap.deepcopy() \
                        for wrap in generate_fifo_queue(self._canvases_read)]
     draw.sort(key = lambda wrap: wrap.sort_key())
     return draw
Пример #11
0
 def _get_canvas_list(cls, queue):
     """get a list of canvases in the queue"""
     gen = threading_utils.generate_fifo_queue(queue)
     threading_utils.go_back_fifo_queue(queue)
     return sorted([wrap.sort_key() for wrap in gen])
Пример #12
0
 def _update_canvases_draw(self):
     """update canvases"""
     draw = [wrap.deepcopy() \
                        for wrap in generate_fifo_queue(self._canvases_read)]
     draw.sort(key=lambda wrap: wrap.sort_key())
     return draw