Exemplo n.º 1
0
 def nextId(self):
     """
     Determine the next page in the Wizard to go to.
     """
     self.application.process_events()
     if self.currentId() == FirstTimePage.Download:
         if not self.web_access:
             return FirstTimePage.NoInternet
         else:
             return FirstTimePage.Plugins
     elif self.currentId() == FirstTimePage.Plugins:
         return self.get_next_page_id()
     elif self.currentId() == FirstTimePage.Progress:
         return -1
     elif self.currentId() == FirstTimePage.NoInternet:
         return FirstTimePage.Progress
     elif self.currentId() == FirstTimePage.Themes:
         self.application.set_busy_cursor()
         while not all([
                 is_thread_finished(thread_name)
                 for thread_name in self.theme_screenshot_threads
         ]):
             time.sleep(0.1)
             self.application.process_events()
         # Build the screenshot icons, as this can not be done in the thread.
         self._build_theme_screenshots()
         self.application.set_normal_cursor()
         self.theme_screenshot_threads = []
         return FirstTimePage.Defaults
     else:
         return self.get_next_page_id()
Exemplo n.º 2
0
def test_is_thread_finished_missing(MockRegistry):
    """
    Test that calling the is_thread_finished() function returns True if the thread doesn't exist
    """
    # GIVEN: A mocked thread worker
    MockRegistry.return_value.get.return_value.worker_threads = {}

    # WHEN: get_thread_worker() is called
    result = is_thread_finished('test_thread')

    # THEN: The result should be correct
    assert result is True, 'is_thread_finished should return True when a thread is missing'
Exemplo n.º 3
0
    def check_media(self, path):
        """
        Check if a file can be played
        Uses a separate QMediaPlayer in a thread

        :param path: Path to file to be checked
        :return: True if file can be played otherwise False
        """
        check_media_worker = CheckMediaWorker(path)
        check_media_worker.setVolume(0)
        run_thread(check_media_worker, 'check_media')
        while not is_thread_finished('check_media'):
            self.application.processEvents()
        return check_media_worker.result
Exemplo n.º 4
0
def test_is_thread_finished(MockRegistry):
    """
    Test the is_thread_finished() function
    """
    # GIVEN: A mock thread and worker
    mocked_thread = MagicMock()
    mocked_thread.isFinished.return_value = False
    MockRegistry.return_value.get.return_value.worker_threads = {'test': {'thread': mocked_thread}}

    # WHEN: is_thread_finished() is called
    result = is_thread_finished('test')

    # THEN: The result should be correct
    assert result is False, 'is_thread_finished should have returned False'
Exemplo n.º 5
0
    def reject(self):
        """
        Called when the user clicks the cancel button. Reimplement it to clean up the threads.

        :rtype: None
        """
        self.was_cancelled = True
        for thread_name in self.thumbnail_download_threads:
            worker = get_thread_worker(thread_name)
            if worker:
                worker.cancel_download()
        # Was the thread created.
        if self.thumbnail_download_threads:
            while any([not is_thread_finished(thread_name) for thread_name in self.thumbnail_download_threads]):
                time.sleep(0.1)
        self.application.set_normal_cursor()
        super().reject()
Exemplo n.º 6
0
 def on_cancel_button_clicked(self):
     """
     Process the triggering of the cancel button.
     """
     self.was_cancelled = True
     if self.theme_screenshot_threads:
         for thread_name in self.theme_screenshot_threads:
             worker = get_thread_worker(thread_name)
             if worker:
                 worker.set_download_canceled(True)
     # Was the thread created.
     if self.theme_screenshot_threads:
         while any([
                 not is_thread_finished(thread_name)
                 for thread_name in self.theme_screenshot_threads
         ]):
             time.sleep(0.1)
     self.application.set_normal_cursor()