def __init__(self, sequencelistmodel, parent=None, *args): super().__init__(parent=parent, *args) self.seqlist = sequencelistmodel self._hwsoc = HWSOC() self.mark = 0 self._steps = 0 self._sequence_cache = None # thread locks self.lock_running = QMutex() self.lock_waiting = QMutex() self.lock_waitcond = QWaitCondition() self.lock_steps = QMutex() # state variables self.state_paused = False self.state_running = False self.state_waitinghwok = False self.startTreatment.connect(self._startTreatment) self.stopTreatment.connect(self._stopTreatment) self.restartTreatment.connect(self._restartTreatment) self.abortTreatment.connect(self._abortTreatment) self.setHWOK.connect(self._sethwok) # create QThread and move this object to it self.thread = QThread() self.moveToThread(self.thread) self.thread.start()
def init_commons(self): self.stopped = False self.stop_mutex = QMutex() self.clock = QTime() self.fps = Queue() self.processing_time = 0 self.processing_mutex = QMutex() self.fps_sum = 0 self.stat_data = ThreadStatisticsData()
def __init__(self, sensor, mirror, verbose=0): super(Loop, self).__init__() self.sensor_mutex = QMutex() self.mirror_mutex = QMutex() self.verbose = verbose self.mirror_thread = QThread() self.sensor_thread = QThread() self.sensor = sensor self.active_lenslets = np.ones(self.sensor.n_lenslets).astype(int) self.mirror = mirror n_lenslets = self.sensor.n_lenslets n_actuators = self.mirror.n_actuators #DEBUG self.sensor.moveToThread(self.sensor_thread) self.mirror.moveToThread(self.mirror_thread) # We have to connect the mirror timer's timeout signal # to the mirror update slot, and then start the timer # here. It's a little awkward, but the mirror timer # cannot be started until it's in its own thread, and # because we've used moveToThread (instead of # making Mirror a QThread subclass). self.mirror.timer.timeout.connect(self.mirror.update) self.mirror.timer.start(1.0 / self.mirror.update_rate * 1000.0) self.sensor_thread.started.connect(self.sensor.update) self.finished.connect(self.sensor.update) self.sensor.finished.connect(self.update) self.pause_signal.connect(self.sensor.pause) self.pause_signal.connect(self.mirror.pause) self.unpause_signal.connect(self.sensor.unpause) self.unpause_signal.connect(self.mirror.unpause) self.poke = None self.closed = False # try to load the poke file specified in # ciao_config.py; if it doesn't exist, create # a dummy poke with all 1's; this will result # in an inverse control matrix with very low # gains, i.e. the mirror won't be driven if not os.path.exists(ccfg.poke_filename): dummy = np.ones((2 * n_lenslets, n_actuators)) np.savetxt(ccfg.poke_filename, dummy) self.load_poke(ccfg.poke_filename) self.gain = ccfg.loop_gain self.loss = ccfg.loop_loss self.paused = False self.n = 0
def __init__(self, width, height, logger=None): QWidget.__init__(self) self.scroll_bar: QScrollBar = None self.logger = logger if logger else logging.getLogger() self.logger.info("Initializing Terminal...") TerminalBuffer.__init__(self, 0, 0, logger) # we paint everything to the pixmap first then paint this pixmap # on paint event. This allows us to partially update the canvas. self._canvas = QPixmap(width, height) self._painter_lock = QMutex(QMutex.Recursive) self._width = width self._height = height self.font = None self.char_width = None self.char_height = None self.line_height = None self.row_len = None self.col_len = None self.dpr = self.devicePixelRatioF() self.set_bg(DEFAULT_BG_COLOR) self.set_fg(DEFAULT_FG_COLOR) self.set_font() self.setAutoFillBackground(True) self.setMinimumSize(width, height) # connect reapint signals self.buffer_repaint_sig.connect(self._paint_buffer) self.cursor_repaint_sig.connect(self._paint_cursor) self.total_repaint_sig.connect(self._canvas_repaint) # intializing blinking cursor self._cursor_blinking_lock = QMutex() self._cursor_blinking_state = CursorState.ON self._cursor_blinking_elapse = 0 self._cursor_blinking_timer = QTimer() self._cursor_blinking_timer.timeout.connect(self._blink_cursor) self._switch_cursor_blink(state=CursorState.ON, blink=True) self.update_scroll_sig.connect(self._update_scroll_position) self.setFocusPolicy(Qt.StrongFocus) # terminal options, in case you don't want pty to handle it # self.echo = True # self.canonical_mode = True self._stdout_sig.connect(self._stdout) self.resize(width, height)
def __init__(self): super().__init__() self.setMinimumSize(QSize(475, 450)) self.setWindowTitle("Thread Example") self.threads = [] update_window_lock = QMutex() worms_mutex = [QMutex() for i in range(3)] self.create_paths() self.create_worms(update_window_lock, worms_mutex) self.show()
def __init__(self, context: ApplicationContext, manager: SoftwareManager, i18n: I18n): super(Prepare, self).__init__() self.manager = manager self.i18n = i18n self.context = context self.waiting_password = False self.password_response = None self._tasks_added = set() self._tasks_finished = set() self._add_lock = QMutex() self._finish_lock = QMutex()
def __init__(self, *args, **kwargs): self.settings = kwargs.get('settings', UserSettings.getInstance()) kwargs['settings'] = self.settings kwargs['cached'] = False self.session_storage = SessionStorage.getInstance() self.pkcs11client = PKCS11Client(*args, **kwargs) self.session_storage.pkcs11_client = self.pkcs11client QRunnable.__init__(self) self.setAutoDelete(True) self.cardmonitor = None self.cardobserver = None self.mutex = QMutex() self.run_mutex = QMutex()
def __init__(self, loop): super(UI, self).__init__() self.sensor_mutex = QMutex() #loop.sensor_mutex self.mirror_mutex = QMutex() #loop.mirror_mutex self.loop = loop try: self.loop.finished.connect(self.update) except Exception as e: pass self.draw_boxes = ccfg.show_search_boxes self.draw_lines = ccfg.show_slope_lines self.init_UI() self.frame_timer = FrameTimer('UI', verbose=False) self.show()
def __init__(self): super().__init__() self.hp_detector = HeadPoseDetector() self.cam = Video() self.mut = QMutex() self.mut_file = QMutex() self.thread_set_pose = SetPoseThread(self.cam, self.mut, self.hp_detector) self.thread_renew_frame = FrameRenewerThread(self.cam, self.mut) self.set_ui() self.slot_init() self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, logger=None): QThread.__init__(self) self.cond = QWaitCondition() self.mutex = QMutex() if logger is None: exit(-1) self.logger = logger self.wakereason = self.REASON_NONE self.uievent = '' self.state = None self.statePhase = None self.timer = QTimer() self.timer.setSingleShot(False) self.timer.timeout.connect(self.__timerTick) self.timerStart.connect(self.timer.start) self.timerStop.connect(self.timer.stop) self.quit = False
def __init__(self, interval, project, vcs, parent=None): """ Constructor @param interval new interval in seconds (integer) @param project reference to the project object (Project) @param vcs reference to the version control object @param parent reference to the parent object (QObject) """ super(VcsStatusMonitorThread, self).__init__(parent) self.setObjectName("VcsStatusMonitorThread") self.setTerminationEnabled(True) self.projectDir = project.getProjectPath() self.project = project self.vcs = vcs self.interval = interval self.autoUpdate = False self.statusList = [] self.reportedStates = {} self.shouldUpdate = False self.monitorMutex = QMutex() self.monitorCondition = QWaitCondition() self.__stopIt = False
def __init__(self, lock, parent=None): super(Walker, self).__init__(parent) self.lock = lock self.stopped = False self.mutex = QMutex() self.path = None self.completed = False
def __init__(self, parent=None, layer=None): super(self.__class__, self).__init__(parent) self.layer = layer self.anchorPoints = [] self.anchorIndex = QgsSpatialIndex() self.abort = False self._mutex = QMutex()
def __init__(self, parent, limit): QThread.__init__(self) self.cond = QWaitCondition() self.mutex = QMutex() self.is_running = True self.limit = limit self.parent = parent
def __init__(self, config, hku_config_file, market='SH'): super(self.__class__, self).__init__() self.working = True self._config = config self.hku_config_file = hku_config_file self.market = market.lower() self.marketid = None self._interval = TimeDelta(seconds=config.getint('collect', 'interval', fallback=60 * 60)) self._phase1_start_time = Datetime( datetime.datetime.combine( datetime.date.today(), datetime.time.fromisoformat( (config.get('collect', 'phase1_start', fallback='09:05')) ) ) ) self._phase1_end_time = Datetime( datetime.datetime.combine( datetime.date.today(), datetime.time.fromisoformat( (config.get('collect', 'phase1_end', fallback='09:05')) ) ) ) self._use_zhima_proxy = config.getboolean('collect', 'use_zhima_proxy', fallback=False) self.cond = QWaitCondition() self.mutex = QMutex()
def __init__(self, parent=None, name=None): """ Constructor @param parent parent widget (QWidget) @param name name of this object (string) """ super(VersionControl, self).__init__(parent) if name: self.setObjectName(name) self.defaultOptions = { 'global': [''], 'commit': [''], 'checkout': [''], 'update': [''], 'add': [''], 'remove': [''], 'diff': [''], 'log': [''], 'history': [''], 'status': [''], 'tag': [''], 'export': [''] } self.interestingDataKeys = [] self.options = {} self.otherData = {} self.canDetectBinaries = True self.autoCommit = False self.statusMonitorThread = None self.vcsExecutionMutex = QMutex()
def __init__(self, parent=None): super(SetPwdWorker, self).__init__(parent) self._disk = object self.infos = None self._work_id = -1 self._mutex = QMutex() self._is_work = False
def __init__(self, arrayrequest, colorTable, normalize, direct=False): self._mutex = QMutex() self._arrayreq = arrayrequest self._colorTable = colorTable self.direct = direct self._normalize = normalize assert not normalize or len(normalize) == 2
def __init__(self, parent, mode): super(GameBoard, self).__init__(parent) self.parent_widget = parent self.BoardWidth = 32 self.BoardHeight = 18 self.mutex = QMutex() # tile width/height in px self.TILE_SIZE = 16 self.mode = mode self.commands_1 = [] self.commands_2 = [] self.enemies_list = [] self.bullets_list = [] self.socket = None if mode is GameMode.MULTIPLAYER_ONLINE_HOST or mode is GameMode.MULTIPLAYER_ONLINE_CLIENT: self.communnication = Communication(mode, 50005) if self.communnication.socket is not None: self.socket = self.communnication.socket self.conn = self.communnication.conn else: print("Error on socket creation.") self.initGameBoard()
def __init__(self, do_sync=True): self.sync_devices = set() self.do_sync = do_sync self.wc = QWaitCondition() self.mutex = QMutex() self.arrived = 0 self.buffer_maps = dict()
def __init__(self): QThread.__init__(self) self.cond = QWaitCondition() self.mutex = QMutex() self.cnt = 0 self._status = True self.sub = rospy.Subscriber("get_action", Float32MultiArray, self.get_array)
def __init__(self,inipr): super(ServerRun, self).__init__() self.th_on = True # self.cond = QWaitCondition() self.mutex = QMutex() self.config = inipr #pr is list->dict self.createsrvs()
class ProcessWithThreadsMixin: mutex = QMutex() def __init__(self): self.finish_thread_callback = None self.thread_list = [] def set_loading_indicator(self): self.indicator = WaitingSpinner(self.view, True, True, Qt.ApplicationModal) def start_loading(self, started_callback, finished_callback, with_indicator=True): self.finish_thread_callback = finished_callback if with_indicator: self.indicator.start() thread = Thread(started_callback, self.mutex) thread.finished.connect(self.stop_loading) thread.start() self.thread_list.append(thread) def stop_loading(self, error_text): self.indicator.stop() self.thread_list = [ thread for thread in self.thread_list if not thread.isFinished() ] self.finish_thread_callback(error_text)
def shown(self): # Disable mouse handler ctx.mainScreen.dontAskCmbAgain = True ctx.mainScreen.theme_shortcut.setEnabled(False) ctx.mainScreen.ui.system_menu.setEnabled(False) # start installer thread ctx.logger.debug("PkgInstaller is creating...") self.mutex = QMutex() self.wait_condition = QWaitCondition() self.queue = Queue() self.pkg_installer = PkgInstaller(self.queue, self.mutex, self.wait_condition, self.retry_answer) self.poll_timer.start(500) # start installer polling ctx.logger.debug("Calling PkgInstaller.start...") self.pkg_installer.start() ctx.mainScreen.disableNext() ctx.mainScreen.disableBack() # start 30 seconds self.timer.start(1000 * 30) self.installProgress.showInstallProgress()
class FitThread(QThread): begin = pyqtSignal() update = pyqtSignal() error = pyqtSignal() mutex = QMutex() def __init__(self, fitter_widget): super(FitThread, self).__init__(fitter_widget) self.fitter_widget = fitter_widget def run(self): try: self.begin.emit() for iteration in range(1, self.fitter_widget.n_iterations + 1): if self.fitter_widget.stop_fit: break self.fitter_widget.fitted_patterns, \ self.fitter_widget.fitted_fit_global_parameters, \ self.fitter_widget.fit_data = \ self.fitter_widget.fitter.do_fit(current_fit_global_parameters=self.fitter_widget.fitted_fit_global_parameters, current_iteration=iteration) self.update.emit() if self.fitter_widget.stop_fit: break if self.fitter_widget.fitted_fit_global_parameters.is_convergence_reached(): break except Exception as exception: self.fitter_widget.thread_exception = exception self.error.emit()
def __init__(self): QtWidgets.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) #self.resize(600, 400) # The resize() method resizes the widget. self.setWindowTitle( "BrewStore") # Here we set the title for our window. self.setWindowIcon(QIcon('icons/brewstore_v1_1280.icns')) self.taskQ = Queue() self.tasker = RunTasks(self.taskQ) self.tasker.stderr.connect(self.console_writer) self.tasker.stdout.connect(self.console_writer) self.tasker.notify.connect(self.readNotif) self.tasker.start() self.fakeprogresstimer = QTimer() self.fakeprogresstimer.timeout.connect(self.fakeProgress) self.on_startup() self.apps = defaultdict(list) self.appDict = defaultdict(dict) self.appListMutex = QMutex() self.initToolbar() self.viewstate = None self.AppList.itemSelectionChanged.connect(self.selectApp) self.defaultAppIcon = QIcon( "icons/open_icon_library-mac/icons/32x32/mimetypes/package-x-generic-2.icns" ) self.FilterEdit.textChanged.connect(self.filterChange) self.InstallButton.clicked.connect(self.install)
def __init__(self, parent=None): super(DescPwdFetcher, self).__init__(parent) self._disk = object self.infos = None self.download = False self._mutex = QMutex() self._is_work = False
def __init__(self, weboob, parent=None): super(QCallbacksManager, self).__init__(parent) self.weboob = weboob self.weboob.requests.register('login', self.callback(self.LoginRequest)) self.mutex = QMutex() self.requests = [] self.new_request.connect(self.do_request)
def __init__(self, parent=None): super(GetAllFoldersWorker, self).__init__(parent) self._disk = None self.org_infos = None self._mutex = QMutex() self._is_work = False self.move_infos = None
def __init__(self): # QThread.__init__(self) super().__init__() self.cond = QWaitCondition() self.mutex = QMutex() self.cnt = 0 self._status = True