def testQThreadReceiversExtern(self):
        #QThread.receivers() - Inherited protected method

        obj = QThread()
        self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0)
        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
Example #2
0
 def handle_start(self):
     self.thread = QThread()
     self.worker = Worker(self.query_list, self.ui.delaySpinBox.text())
     self.worker.moveToThread(self.thread)
     self.thread.started.connect(self.worker.run)
     self.worker.finished.connect(self.thread.quit)
     self.worker.finished.connect(self.worker.deleteLater)
     self.thread.finished.connect(self.thread.deleteLater)
     self.worker.progress.connect(self.ui.progressBar.setValue)
     self.thread.start()
     self.ui.buttonFrame.setEnabled(False)
     self.ui.inputFrame.setEnabled(False)
     self.thread.finished.connect(self.handle_finished)
Example #3
0
    def __init__(self):
        super(EvoLisaWidget, self).__init__()
        self.__image = QImage('evolisa.png')
        self.__thread = QThread()
        self.__worker = EvoLisaWorker()
        self.__worker.moveToThread(self.__thread)
        self.__thread.started.connect(self.__worker.run)
        self.__thread.finished.connect(self.__thread.quit)
        self.__worker.progress.connect(self.__report_progress)

        self.__pixmap = None

        self.setWindowTitle('EvoLisa')
Example #4
0
    def __init__(self, project_id: ProjectID, parent: QObject = None):
        super().__init__(parent=parent)

        self.project_id = project_id
        self.buffer = collections.deque()
        projects_logger_handler.buffers[project_id] = self.buffer  # register our buffer

        self.stopped = threading.Event()
        self.can_flush_log = threading.Event()

        self.thread = QThread(parent=self)
        self.moveToThread(self.thread)
        self.thread.started.connect(self.routine)
        self.thread.start()
Example #5
0
 def __init__(self, bot, item, limit, mode, max):
     QThread.__init__(self)
     self.api = bot.api
     self.item = item
     self.limit = limit
     self.mode = mode
     self.max = max
     self.me = self.api.me()
     self.db = sqlite3.connect('database', check_same_thread=False)
     cursor = self.db.cursor()
     cursor.execute('''
                         CREATE TABLE IF NOT EXISTS followed_users(id TEXT, screen_name TEXT)''')
     self.db.commit()
     self.to_follow = []
Example #6
0
class WeatherDownloader(QObject):
    downloadComplete = Signal()
    downloadFailed = Signal()

    def __init_(self, parent=None):
        super().__init__(self, parent)

    @Slot
    def downloadForecast(self):
        logging.info("Request to download the forecast from YR.NO")
        self._thread = QThread()
        self._worker = Worker()
        self._worker.moveToThread(self._thread)

        # setup signals-slots
        self._worker.downloadComplete.connect(self.when_complete)
        self._worker.downloadFailed.connect(self.when_failed)
        self._thread.started(self._worker.do_work)
        self._thread.finished(self._thread.deleteLater)

    def when_complete(self):
        logging.info("Download complete, freeing resources")
        self._thread.quit()

        # emit the result
        self.downloadComplete.emit()

    def when_failed(self):
        logging.warning("Download failed, freeing resources")
        self._thread.quit()

        # emit the result
        self.downloadFailed.emit()
Example #7
0
 def __init__(self):
     QWidget.__init__(self)
     layout = QVBoxLayout(self)
     self.text = QPlainTextEdit()
     layout.addWidget(self.text)
     self.setLayout(layout)
     self.ds = DataSource()
     self.worker = UpdateUserWorker()
     self.worker_thread = QThread()
     self.worker_thread.started.connect(self.worker.run)
     self.worker.finished.connect(self.worker_thread.quit)
     self.worker.moveToThread(self.worker_thread)
     self.worker_thread.start()
     self.worker.processed.connect(self.processed)
Example #8
0
    def __init__(self, db_mngr, listener):
        """Initializes the fetcher object.

        Args:
            db_mngr (SpineDBManager)
            listener (SpineDBEditor)
        """
        super().__init__()
        self._db_mngr = db_mngr
        self._listener = listener
        self._thread = QThread()
        # NOTE: by moving this to another thread, all the slots defined below are called on that thread too
        self.moveToThread(self._thread)
        self._thread.start()
        self.connect_signals()
def snapshot_in_bkgroud():
    # Step 2: Create a QThread object
    thread = QThread()
    # Step 3: Create a worker object
    worker = Worker()
    # Step 4: Move worker to the thread
    worker.moveToThread(thread)
    # Step 5: Connect signals and slots
    thread.started.connect(worker.run)
    worker.finished.connect(thread.quit)
    worker.finished.connect(worker.deleteLater)
    thread.finished.connect(thread.deleteLater)
    # worker.progress.connect(reportProgress)
    # Step 6: Start the thread
    thread.start()
Example #10
0
 def __init__(self, mainw):
     super().__init__()
     self.setupUi(mainw)
     self.CONFIG = ''
     self.template = ''
     self.xlsx_rows_list = ''
     self.parent = mainw
     self.pushButton_open_list_and_template.clicked.connect(
         self.open_xls_and_template)
     self.pushButton_ask_and_send.clicked.connect(self.send_msg)
     self.pushButton_cancel_send.clicked.connect(self.abort_workers)
     QThread.currentThread().setObjectName(
         'main')  # threads can be named, useful for log output
     self.__workers_done = None
     self.__threads = None
Example #11
0
class Bridge(QObject):
    def __init__(self, widget, index, login, password, proxy, key):
        QObject.__init__(self)

        self.thread = QThread()
        self.user = User(index, login, password, proxy, key)
        self.user.moveToThread(self.thread)
        self.init_signal_connections(widget)
        self.thread.started.connect(self.user.run)
        self.thread.start()

    def init_signal_connections(self, widget):
        self.user.signal_update_column_color.connect(widget.change_column_color)
        self.user.signal_update_column_text.connect(widget.change_column_text)
        self.user.signal_update_chart.connect(widget.update_chart)
Example #12
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.manager = Manager(self)
        self.__threadRun = QThread()
        self.__threadRun.start()
        self.manager.moveToThread(self.__threadRun)

        self.ui.openFile_button.clicked.connect(self.openFileButtonClicked)
        self.ui.start_button.clicked.connect(self.startButtonClicked)
        self.startBut.connect(self.manager.startButtonClicked)

        self.manager.sendMessageConsole.connect(self.setMessage)
Example #13
0
 def start(self):
     if not self.arduino_process_started or not self._arduino_process_is_alive(
     ):
         for proc in psutil.process_iter():
             # check whether the process name matches
             if 'arduino_monitor.py' in proc.cmdline():
                 proc.kill()
         if os.path.exists('arduino_monitor.py'):
             self.arduino_process = subprocess.Popen(
                 ['python', 'arduino_monitor.py'])
         else:
             self.arduino_process = subprocess.Popen(
                 ['Juice_Ardiuno_Monitor'])
         self.arduino_process_started = True
     QThread.start(self)
Example #14
0
    def start(self, app_start_ts, args):
        '''
        Performs application initialization and launch

        @raise SystemExit
        '''
        logger.debug("Launching service with args (%s)...", args)

        clear_old_logs(logger)
        # Load configuration file
        self._cfg = config.load_config()
        set_max_log_size_mb(logger, max(self._cfg.max_log_size, 0.02))
        if self._cfg.copies_logging:
            copies_logger = logging.getLogger('copies_logger')
            set_max_log_size_mb(copies_logger, max(self._cfg.max_log_size,
                                                   0.02))

        if 'sync_directory' in args and args['sync_directory']:
            self._cfg.set_settings(
                {'sync_directory': args['sync_directory'].decode('utf-8')})

        if 'wipe_internal' in args and args['wipe_internal']:
            try:
                wipe_internal(self._cfg.sync_directory)
            except Exception as e:
                logger.warning("Can't wipe internal info. Reason: %s", e)

            raise SystemExit(0)

        if self._cfg.tracking_address:
            self._tracker = Tracker('service_stats.db',
                                    self._cfg.sync_directory,
                                    self._cfg.tracking_address)
            init_crash_handler(self._tracker)
            self._tracker_thread = QThread()
            self._tracker.moveToThread(self._tracker_thread)
            self._tracker_thread.started.connect(self._tracker.start.emit)
            self._tracker_thread.start(QThread.IdlePriority)
        else:
            init_crash_handler(logger=logger)

        self._worker = ApplicationWorker(self._cfg, self._tracker,
                                         app_start_ts, args)
        self._worker.exited.connect(self._on_exit, Qt.QueuedConnection)

        self._worker.start_work()
        self.exec_()
        logger.debug("Service exiting...")
Example #15
0
    def __init__(self, db_mngr, listener, *db_maps):
        """Initializes the fetcher object.

        Args:
            db_mngr (SpineDBManager)
            listener (DataStoreForm)
            db_maps (DiffDatabaseMapping)
        """
        super().__init__()
        self.db_mngr = db_mngr
        self.listener = listener
        self.db_maps = db_maps
        self._thread = QThread()
        self.moveToThread(self._thread)
        self._thread.start()
        self.connect_signals()
Example #16
0
    def __init__(self, GUI):
        """PlotThread adds a pyqtGraph to the GUI. 
        input the layout object which has the addWidget method. 
        The method runs on a seperate thread at the moment though run is called on
        its own."""
        QThread.__init__(self)
        self.GUI = GUI
        self.signal = signals()

        #setup of graphing widget
        self.graphWidget = pg.ImageView()
        self.graphWidget.show()
        self.GUI.addWidget(self.graphWidget, 0, 0, 1, 3)

        #flags & queues
        self.stopped = False
Example #17
0
 def create_thread(self, socketDescriptor):
     worker = Worker(socketDescriptor)
     thread = QThread()
     self.onWrite.connect(worker.write_message)
     worker.signal.callFunc.connect(self.call_func_parent)
     worker.messageReceived.connect(self.message_received)
     worker.signal.getStatus.connect(self.getStatus)
     worker.signal.setStatus.connect(self.setStatus)
     self.signal.getStatus.connect(worker.getStatus)
     thread.started.connect(worker.start)
     worker.signal.updateNr.connect(self.update_nr_clients)
     worker.finished.connect(self.test)
     worker.moveToThread(thread)
     thread.worker = worker
     thread.start()
     return thread
Example #18
0
    def registerThread(self):
        """
        This slot shall be called from each activated nexxT thread with a direct connection.

        :return:
        """
        t = QThread.currentThread()
        logger.internal("registering thread %s", t.objectName())
        with self._lockThreadSpecific:
            if not t in self._threadSpecificProfiling:
                self._threadSpecificProfiling[t] = ThreadSpecificProfItem()
                self._threadSpecificProfiling[t].timer = QTimer(
                    parent=self.sender())
                self._threadSpecificProfiling[t].timer.timeout.connect(
                    self._generateRecord, Qt.DirectConnection)
                self._threadSpecificProfiling[t].timer.setInterval(
                    int(ThreadSpecificProfItem.THREAD_PROFILING_PERIOD_SEC *
                        1e3))
                self.stopTimers.connect(
                    self._threadSpecificProfiling[t].timer.stop)
                self.startTimers.connect(
                    self._threadSpecificProfiling[t].timer.start)
                if self._loadMonitoringEnabled:
                    self._threadSpecificProfiling[t].timer.start()

            tmain = QCoreApplication.instance().thread()
            if self._mi is None and not tmain in self._threadSpecificProfiling:
                self._mi = MethodInvoker(
                    dict(object=self, method="registerThread", thread=tmain),
                    Qt.QueuedConnection)
Example #19
0
 def __init__(self, backup, item, debug=False):
     QThread.__init__(self)
     self.backup = backup
     self.item = item
     try:
         self.repo = Repo(
             Utils.get_backend(backup),
             callback=lambda message: self.updated.emit(self.item, message),
             thread_count=backup.thread_count,
             compression_level=backup.compression_level,
             logger=setup_logger(self.backup.name,
                                 get_log_file_path(self.backup.name),
                                 logging.DEBUG if debug else logging.INFO))
     except Exception as e:
         print(e)
         self.error.emit(e)
    def __init__(self, grid: MultiCircuit, options: TransientStabilityOptions,
                 pf_res: PowerFlowResults):
        """
        TimeSeries constructor
        @param grid: MultiCircuit instance
        @param options: PowerFlowOptions instance
        """
        QThread.__init__(self)

        self.grid = grid

        self.options = options

        self.pf_res = pf_res

        self.results = None
 def __init__(self, source, *args):
     QThread.__init__(self, *args)
     self.source = source
     self.target = Target()
Example #22
0
 def testIntConversion(self):
     i = 0
     h = QThread.currentThreadId()
     i = 0 + int(h)
     self.assertEqual(i, int(h))
Example #23
0
 def __init__(self,device='ME', tag='TAG', environment=ENV):
     QThread.__init__(self)
     SkelDataRec.__init__(self, device=device, tag=tag, environment=environment)
Example #24
0
 def __init__(self):
     QThread.__init__(self)