Esempio n. 1
0
    def start_sync(self):
        self.log_btn.show()
        self.log.setRowCount(0)
        self.log.show()

        self.worker_thread = QThread(self)

        book_ids = self.valid_book_ids
        if self.limits['total_books']:
            book_ids = book_ids[:self.limits['total_books']]

        self.total = len(book_ids)

        self.worker = UploadManager(
            self.db, self.logger, book_ids,
            self.sync_selected_radio.isChecked()
            and self.reupload_checkbox.isChecked())
        self.worker.finished.connect(self.finish_sync)
        self.worker.finished.connect(self.worker_thread.quit)
        self.worker.progress.connect(self.update_progress)
        self.worker.uploadProgress.connect(self.update_upload_progress)
        self.worker.started.connect(self.log_start)
        self.worker.skipped.connect(self.log_skip)
        self.worker.failed.connect(self.log_fail)
        self.worker.uploaded.connect(self.log_upload)
        self.worker.updated.connect(self.log_update)
        self.worker.aborted.connect(self.abort)
        self.worker.moveToThread(self.worker_thread)

        self.worker_thread.started.connect(self.worker.start)
        self.worker_thread.start()
Esempio n. 2
0
 def startScan(self, ipRanges, portsStr, threadNumber, timeout):
     timeout = 3 if not timeout else int(timeout)
     addresses = None
     parser_args = {'port_field': portsStr, 'address_field': ipRanges}
     fields = self.parser.parse_fields(*get_converted_arguments(
         self.parser.parse_fields, parser_args, convert_table))
     self.scanner = CoreModel(timeout)
     if CoreModel.INDEPENDENT_THREAD_MANAGEMENT:
         addresses = self.parser.get_all_addresses(ipRanges)
         self.ip_generator = PlugAddressGenerator(addresses, ports)
         threadNumber = 1
     else:
         self.ip_generator = IpGenerator()
         self.ip_generator.set_parsed_fields(*get_converted_arguments(
             self.ip_generator.set_parsed_fields, fields, convert_table))
         threadNumber = int(threadNumber)
         print("thread %i number set" % threadNumber)
     for i in range(threadNumber):
         print(i)
         scan_worker = ScanWorker(self.ip_generator, self.scanner,
                                  self.storage)
         scan_thread = QThread()
         scan_worker.log_signal.connect(self.log_text)
         scan_worker.moveToThread(scan_thread)
         scan_worker.exit_signal.connect(scan_thread.exit)
         scan_worker.exit_signal.connect(self.on_worker_exit)
         scan_thread.started.connect(scan_worker.work)
         self.threads.append((scan_worker, scan_thread))
     for thread in self.threads:
         scan_worker, scan_thread = thread
         print("starting")
         scan_thread.start()
     self.changeThreadLabel(threadNumber)
 def start_docker_service(self, env=None):
     self._docker_service.init_env(env=env)
     thread = QThread()
     thread.setObjectName("Docker Service for %s" % env.name)
     self._docker_service.moveToThread(thread)
     thread.started.connect(self._docker_service.run)
     thread.start()
     self.threads.append(thread)
Esempio n. 4
0
def using_q_thread():
    app = QCoreApplication([])
    thread = MainApp()
    th = QThread()
    thread.finished.connect(app.exit)
    thread.moveToThread(th)
    thread.start()
    sys.exit(app.exec_())
Esempio n. 5
0
 def __init__(self,
              serial1=Bearing_Serial('COM1', 9600, 'modbus'),
              serial2=Bearing_Serial('COM2', 9600, 'serial')):
     super(Read_Thread, self).__init__()
     self._thread = QThread()
     self.moveToThread(self._thread)
     self._serial1 = serial1
     self._serial2 = serial2
     self._stop = 0
Esempio n. 6
0
 def __init__(self):
     QThread.__init__(self)
     self.qscm = QtSlamClient(server_adress=('127.0.0.1', 2207))
     self.th = QThread()
     self.qscm.connect()
     self.qscm.moveToThread(self.th)
     self.qscm.start()
     self.semaphore_image = True
     self.semaphore_trajectory = True
     self.response_data = ' '
     self.qscm.image_response[bytes].connect(self.semaphore_image_off)
     self.qscm.trajectory_response[bytes].connect(
         self.semaphore_trajectory_off)
Esempio n. 7
0
 def start_manager(self):
     self.manager_thread = QThread()
     env = {
         'DOCKER_CERT_PATH': '',
         'DOCKER_HOST': 'tcp://10.0.0.17:2375',
         'DOCKER_TLS_VERIFY': ''
     }
     self.manager_worker = Manager(env=env)
     self.manager_thread.setObjectName("Manager Thread")
     self.manager_worker.signals().status_change.connect(
         self.manager_status_change)
     self.signal_stop_worker.connect(self.manager_worker.abort)
     self.manager_worker.moveToThread(self.manager_thread)
     self.manager_thread.started.connect(self.manager_worker.run)
     self.manager_thread.start()
Esempio n. 8
0
    def __init__(self,parent = None):
        super(Compress,self).__init__(parent)
        self.createList()
        
        self._process = QProcess(self)
        self._thread = QThread()
        self.moveToThread(self._thread)
        self._thread.start()

        self._fileName = ""
        self._outPath = ""

        self.startRunning.connect(self.startCompress)
        self._process.readyReadStandardOutput.connect(self.readMsg)
        self._process.readyReadStandardError.connect(self.readError)
        self._process.finished.connect(self.finished)
Esempio n. 9
0
    def start(self):
        if self.sync_selected_radio.isChecked(
        ) and self.reupload_checkbox.isChecked():
            reply = QMessageBox.question(
                self, 'BookFusion Sync',
                'Re-uploading book files can potentially result in previous highlights or bookmarks no longer working.\n\nPreviously uploaded files will be overwritten. Are you sure you want to re-upload?',
                QMessageBox.No | QMessageBox.Yes, QMessageBox.Yes)
            if reply != QMessageBox.Yes:
                return

        self.worker = None
        self.valid_book_ids = None
        self.book_log_map = {}
        self.book_progress_map = {}

        if self.sync_selected_radio.isChecked():
            book_ids = list(self.selected_book_ids)
        else:
            book_ids = list(self.db.all_book_ids())

        self.logger.info('Start sync: sync_selected={}; book_ids={}'.format(
            self.sync_selected_radio.isChecked(), book_ids))

        self.in_progress = True
        self.total = len(book_ids)
        self.update_progress(None)
        self.start_btn.hide()
        self.cancel_btn.show()
        self.config_btn.setEnabled(False)
        self.sync_all_radio.setEnabled(False)
        self.sync_selected_radio.setEnabled(False)

        self.worker_thread = QThread(self)

        self.worker = CheckWorker(self.db, self.logger, book_ids)
        self.worker.finished.connect(self.finish_check)
        self.worker.finished.connect(self.worker_thread.quit)
        self.worker.progress.connect(self.update_progress)
        self.worker.limitsAvailable.connect(self.apply_limits)
        self.worker.resultsAvailable.connect(self.apply_results)
        self.worker.aborted.connect(self.abort)
        self.worker.moveToThread(self.worker_thread)

        self.worker_thread.started.connect(self.worker.start)
        self.worker_thread.start()
Esempio n. 10
0
    def start(self):
        self.readyForNext.connect(self.sync)

        for index in range(prefs['threads']):
            thread = QThread(self)
            self.finished.connect(thread.quit)

            worker = UploadWorker(index, self.reupload, self.db, self.logger)
            worker.readyForNext.connect(self.sync)
            worker.uploadProgress.connect(self.uploadProgress)
            worker.uploaded.connect(self.uploaded)
            worker.updated.connect(self.updated)
            worker.skipped.connect(self.skipped)
            worker.failed.connect(self.failed)
            worker.aborted.connect(self.abort)
            thread.started.connect(worker.start)
            thread.start()
            self.workers.append([worker, thread])

        self.count = 0
Esempio n. 11
0
	def __init__(
			self,
			image_file : Optional[str] = None,
			clues_file : Optional[str] = None,
			entries_file : Optional[str] = None,
			output_file : Optional[str] = None,
			fft : Optional[bool] = False,
			force_number : Optional[bool] = False,
	):
		# state variables
		self.board = None # type: Optional[Board]
		self.clues = None # type: Optional[str]
		self.entries = None # type: Optional[str]

		# file name variables
		self._image_file = image_file
		self._clues_file = clues_file
		self._entries_file = entries_file
		self._output_file = output_file
		self._force_number = force_number

		# settings
		self.board_extract_method = 'fft' if fft else None

		# board solving variables
		self.iterations = 30
		self.weight_for_unknown = 100
		self.weight_func = lambda x: x ** 2

		# clipboard variables
		self.app = get_application()
		self.clip = self.app.clipboard()
		self.clip.dataChanged.connect(self.check_clipboard)
		logging.info('Started clipboard event handler. Copy an image or text to start.')
		self.queue = queue.Queue() # type: queue.Queue[QueueItem]
		self.thread = QThread()
		self.signal = Signal()
		self.signal.closeApp.connect(self.exit)
		self.thread.run = self.handle
		self.thread.start()
		logging.info('Started crossword solver worker thread.')
Esempio n. 12
0
 def startScan(self, ipRanges, portsStr, threadNumber, timeout):
     timeout = 3 if not timeout else int(timeout)
     addresses = self.parser.parse_address_field(ipRanges)
     ports = self.parser.parse_port_field(portsStr)
     self.ip_generator = IpGenerator(addresses, ports)
     self.scanner = CoreModel(timeout)
     threadNumber = int(threadNumber)
     for i in range(threadNumber):
         scan_worker = ScanWorker(self.ip_generator, self.scanner,
                                  self.storage)
         scan_thread = QThread()
         scan_worker.log_signal.connect(self.log_text)
         scan_worker.moveToThread(scan_thread)
         scan_worker.exit_signal.connect(scan_thread.exit)
         scan_worker.exit_signal.connect(self.on_worker_exit)
         scan_thread.started.connect(scan_worker.work)
         self.threads.append((scan_worker, scan_thread))
     self.changeThreadLabel(threadNumber)
     for thread in self.threads:
         scan_worker, scan_thread = thread
         scan_thread.start()
Esempio n. 13
0
 def __init__(self):
     super(Handle_Data, self).__init__()
     self._all_data = AllData()
     self._thread = QThread()
     self.moveToThread(self._thread)
Esempio n. 14
0
 def __init__(self, serial):
     super(Motor, self).__init__()
     self._thread = QThread()
     self.moveToThread(self._thread)
     self.command = []
     self.serial = serial