def create_worker(self):
        threads = []
        downloadWorker = DownloadWorker(self.__waterfall_commands, self.__download_status)
        threads.append(threadHelper.create_thread(downloadWorker.execute))
        if self.__modules is not None:
            moduleWorker = ModuleWorker(self.__waterfall_modules_commands, self.__download_status)
            threads.append(threadHelper.create_thread(moduleWorker.execute))

        return threads
Пример #2
0
    def extract(self):
        client = SatnogNetworkClient()
        diff_days = dateHelper.diff_days(
            self.__cmd.start_date, self.__cmd.end_date)
        if diff_days < 8:
            # no thread needed
            url_params = self.__url_param_builder(
                self.__cmd.start_date, self.__cmd.end_date)
            pageScanner = PageScanWorker(
                client, self.__cmd, self.__repos, self.OBSERVATION_URL, url_params, 1)
            pageScanner.scan()
        else:
            threads = []
            job = 1
            for from_datetime, to_datetime in dateHelper.split_date(self.__cmd.start_date, self.__cmd.end_date, 4):
                print(str(from_datetime) + " " + str(to_datetime))
                url_params = self.__url_param_builder(
                    from_datetime, to_datetime)
                pageScanner = PageScanWorker(
                    client, self.__cmd, self.__repos, self.OBSERVATION_URL, url_params, job)
                t = threadHelper.create_thread(pageScanner.scan)
                threads.append(t)
                job += 1

            threadHelper.wait(threads)
        print('\ndownloading started (Ctrl + C to stop)...\t~(  ^o^)~')
        self.__register_end_command()
        self.__create_workers_and_wait()
    def create_worker(self):
        threads = []
        downloadWorker = DownloadWorker(
            self.__frame_commands, self.__download_status, None)
        threads.append(threadHelper.create_thread(downloadWorker.execute))
        if self.__modules is not None:
            moduleWorker = ModuleWorker(
                self.__frame_modules_commands, self.__download_status, self.__download_end_status)
            threads.append(threadHelper.create_thread(moduleWorker.execute))

        if self.__end_modules is not None:
            endWorker = EndModuleWorker(
                self.__frame_end_modules_commands, self.__download_end_status)
            threads.append(threadHelper.create_thread(endWorker.execute()))

        return threads
    def create_worker(self):
        threads = []
        downloadWorker = DownloadWorker(
            self.__archive_commands, self.__download_status, self.__is_download_finished if self.__modules is None else None)
        threads.append(threadHelper.create_thread(downloadWorker.execute))
        if self.__modules is not None:
            moduleWorker = ModuleWorker(
                self.__archive_modules_commands, self.__download_status, self.__is_download_finished)
            threads.append(threadHelper.create_thread(moduleWorker.execute))

        if self.__end_modules is not None:
            endWorker = EndModuleWorker(
                self.__archive_end_modules_commands, self.__is_download_finished)
            threads.append(threadHelper.create_thread(endWorker.execute()))

        return threads