def run(self):
        log.log(__name__, sys._getframe().f_code.co_name, "Start of thread downloads manager", log.LEVEL_DEBUG)

        self.event.clear()
        log.log(__name__, sys._getframe().f_code.co_name, "Start up => check if there are downloads to do", log.LEVEL_DEBUG)

        self.periodic_check()

        while True:
            downloads_list = ManageDownload.get_all_downloads_to_start()
            for download in downloads_list:
                log.log(__name__, sys._getframe().f_code.co_name,
                        "Create thread for download id %d" % download.id, log.LEVEL_DEBUG)

                download_thread = DownloadThread(download, self.event, self.dict_event_download_mark_as_finished)
                download_thread.start()
                self.download_threads_list.append(download_thread)

            # for thread in self.download_threads_list:
            #     thread.join()
            #     log.log(__name__, sys._getframe().f_code.co_name,
            #             "Remove thread for download id %d" % thread.download.id, log.LEVEL_DEBUG)
            #     self.download_threads_list.remove(thread)
            #     log.log(__name__, sys._getframe().f_code.co_name,
            #             "Download finished => event setted", log.LEVEL_DEBUG)
            #     self.event.set()

            log.log(__name__, sys._getframe().f_code.co_name, "Wait for event to start download ....", log.LEVEL_DEBUG)
            self.event.wait()
            self.event.clear()

            log.log(__name__, sys._getframe().f_code.co_name, "Event reveived !!", log.LEVEL_DEBUG)

            time.sleep(1)
Esempio n. 2
0
    def update(self):
        """
        Try to download new images and update wallpaper.
        """

        print "Updating..."
        download_thread = DownloadThread(self, self.ui_controller, self.config)
        download_thread.start()
    def update(self):
        """
        Try to download new images and update wallpaper.
        """

        WallPaperLog.getInstance().info('Updating...')
        download_thread = DownloadThread(self, self.ui_controller, self.config)
        download_thread.start()
    def update(self):
        """
        Try to download new images and update wallpaper.
        """

        print "Updating..."
        download_thread = DownloadThread(self, self.ui_controller, self.config)
        download_thread.start()
Esempio n. 5
0
    def download_files(self, objects, filesizes, bucket_name):

        c = self.progress_thread_count
        self.progress_thread_count += 1
        self.upload_thread_count += 1

        progress_thread = ProgressWindow((objects, 'All files'),
                                         filesizes,
                                         c,
                                         download=True)
        download_thread = DownloadThread(objects, bucket_name,
                                         self.oci_manager, c)

        download_thread.file_downloaded.connect(progress_thread.next_file)
        download_thread.bytes_downloaded.connect(progress_thread.set_progress)
        download_thread.all_files_downloaded.connect(self.delete_threads)
        progress_thread.cancel_signal.connect(self.thread_cancelled)
        download_thread.download_failed.connect(progress_thread.retry_handler)
        progress_thread.retry.clicked.connect(download_thread.start)

        self.progress_threads[c] = progress_thread
        self.upload_threads[c] = download_thread

        self.progress_threads[c].show()
        self.upload_threads[c].start()
Esempio n. 6
0
    def run(self):
        try:
            self._tcpServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self._tcpServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                       1)
            self._tcpServer.bind((self._config.ip, self._config.port))
        except socket.error:
            self._log.error(
                "There was an error when trying to bind the server")
            exit(2)
        finally:
            self._log.info("Waiting for connections ...")

        while True:
            self._tcpServer.listen(4)
            (conn, (ip, port)) = self._tcpServer.accept()
            newthread = DownloadThread(conn, self._config)
            newthread.start()
            self.threads.append(newthread)