Exemple #1
0
    def __init__(self, files, needPrj):
        QThread.__init__(self, QThread.currentThread())
        self.inFiles = files
        self.needPrj = needPrj

        self.mutex = QMutex()
        self.stopMe = 0
Exemple #2
0
 def __init__(self, framework, parent=None):
     QThread.__init__(self, parent)
     self.framework = framework
     self.qlock = QMutex()
     self.cursor = None
     QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
     QObject.connect(self, SIGNAL('started()'), self.startedHandler)
Exemple #3
0
 def __init__(self, parent):
     QThread.__init__(self)
     self.result = None
     self.parent = parent
     self._stopped = False
     self.mutex = QMutex()
     self.filePrefix = None
     self.fileFormat = None
     self.wallColoring = None
     self.cellColoring = None
     self.pointColoring = None
     self.extraDrawing = []
     self.pointSize = None
     self.pointLineColor = None
     self.pointLineThickness = None
     self.ellipsisDraw = None
     self.overSampling = None
     self.wallThickness = None
     self.bgColor = None
     self.loading = False
     self._crop = QRect(0, 0, 1, 1)
     self._pix = None
     self._end_image_plot = False
     self._loading_arguments = {}
     self.retryObject = None
Exemple #4
0
    def __init__(self,
                 framework,
                 queueDataModel,
                 resultsDataModel,
                 parent=None):
        QThread.__init__(self, parent)
        self.framework = framework
        self.queueDataModel = queueDataModel
        self.resultsDataModel = resultsDataModel
        self.qlock = QMutex()
        self.qlock_analysis = QMutex()
        QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
        QObject.connect(self, SIGNAL('started()'), self.startedHandler)

        self.re_delim = re.compile(r'([;&])')
        self.re_unique_marker_base = re.compile(
            re.escape(self.UNIQUE_MARKER_BASE), re.I)
        self.pending_fuzz_response_ids = deque()
        self.analysis_queue = deque()
        self.processed_urls = {}

        self.Data = None
        self.read_cursor = None
        self.read_cursor2 = None
        self.write_cursor = None
Exemple #5
0
 def __init__(self, label, parent=None):
     QRunnable.__init__(self)
     self.label = label
     self.parent = parent
     self.data = None
     self.mutex = QMutex()
     self.setAutoDelete(True)
    class MainW(QtGui.QMainWindow):
        """
        Mainw to host and run one single thread
        """
        def __init__(self):
            QtGui.QMainWindow.__init__(self)
            self.mutex = QMutex()
            self.thr = GuiThread(process=self.fun, period=0.1)
            self.thr2 = GuiThread(process=self.fun2, period=0.1)
            self.buff = CircIoBuffer(byte_size=15 * len('rafal miecznik'))
            self.thr.start()
            self.thr2.start()
            time.sleep(2)
            print(self.buff.read())
            for d in dir(self.mutex):
                print(d)

        def fun(self):
            print(self.mutex.tryLock())
            self.buff.write(' rafal')
            self.mutex.unlock()
            #print self.thr.currentThreadId()

        def fun2(self):
            self.mutex.lock()
            self.buff.write(' miecznik')
Exemple #7
0
 def __init__(self, weboob, parent=None):
     QObject.__init__(self, 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)
Exemple #8
0
    def __init__(self, rect):
        self._mutex = QMutex()
        self.image = QImage(rect.width(), rect.height(),
                            QImage.Format_ARGB32_Premultiplied)
        self.image.fill(0x00000000)

        self._topLeft = rect.topLeft()

        # Whenever the underlying data changes, the data version is incremented.
        # By comparing the data version to the image and request version, it can
        # be determined if the content of this tile is recent or needs to be
        # re-computed.

        # version of the data
        self.dataVer = 0

        # version of self.image
        #
        # If self.imgVer < self.dataVer, the image needs to be re-computed
        # from the new data.
        self.imgVer = -1

        # version of the request that has been generated to update the contents
        # of self.image
        #
        # If self.reqVer == self.dataVer, a request is currently running that will
        # eventually replace self.image with the new data.
        self.reqVer = -2
Exemple #9
0
 def __init__(self, label, parent=None):
     QRunnable.__init__(self)
     self.imap = None
     self.label = label
     self.parent = parent
     self.mutex = QMutex()
     self.login()
Exemple #10
0
    def __init__(self, lock, instr_hub, parent=None):
        print("DTT created")
        super(DataTaker, self).__init__(parent)

        self.instr_hub = instr_hub
        self.connect(self.instr_hub, SIGNAL("changed_list()"),
                     self.reset_lists)
        self.lock = lock
        self.stopped = True
        self.paused = False
        self.mutex = QMutex()

        self.completed = False
        self.DEBUG = IOTool.get_debug_setting()

        #the script which is run everytime the user call the routine "run"
        self.script_file_name = ''

        #a dict that can be populated by variable the user would like to change
        #in real time while the script is ran
        self.user_variables = {}

        self.t_start = None
        # scriptize the intruments and their parameters
        self.reset_lists()
Exemple #11
0
 def __init__(self, weboob, parent=None):
     QObject.__init__(self, parent)
     self.weboob = weboob
     self.weboob.callbacks['login'] = self.callback(self.LoginRequest)
     self.mutex = QMutex()
     self.requests = []
     self.connect(self, SIGNAL('new_request'), self.do_request)
class QtStreamHandler(logging.Handler): 
    def __init__(self, parent, main): 
        logging.Handler.__init__(self) 
        self.parent = parent 
        self.main = main         
        self.textWidget = parent 
        self.formater = logging.Formatter("%(asctime)s - %(levelname)s -> %(message)s") 
        self.logString = ""
    def getLoggingCompleteText(self):
        return self.logString
    def createLock(self): 
        self.mutex = QMutex() 
    
    def acquire(self): 
        self.mutex.lock() 
    
    def release(self): 
        self.mutex.unlock() 
    
    def emit(self, record): 
#        self.textWidget.appendPlainText(self.formater.format(record))
        formattedText = self.formater.format(record)
        #separate text from date
        index = formattedText.find('->')
        self.textWidget.setTextColor(QColor("green"))
        self.textWidget.insertPlainText(formattedText[:index])
        self.textWidget.setTextColor(QColor("blue"))
        self.textWidget.insertPlainText(formattedText[index:] + "\n") 
        self.textWidget.moveCursor(QTextCursor.EndOfLine) 
        self.textWidget.ensureCursorVisible() 
        self.logString += formattedText + "\n";
Exemple #13
0
 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
Exemple #14
0
class Feed(QRunnable):
    def __init__(self, label, parent=None):
        QRunnable.__init__(self)
        self.label = label
        self.parent = parent
        self.data = None
        self.mutex = QMutex()
        self.setAutoDelete(True)

    def run(self):
        self.check()

    def check(self):
        try:
            self.fetch()
        except (urllib2.URLError, urllib2.HTTPError) as err:
            self.parent.error.emit(str(err))
        else:
            self.read()
            if self.data:
                self.parse()

    def fetch(self):
        auth_handler = urllib2.HTTPBasicAuthHandler()
        auth_handler.add_password(REALM, HOST, self.parent.user,
                                  self.parent.passwd)
        opener = urllib2.build_opener(auth_handler)
        urllib2.install_opener(opener)
        url = "%s/%s" % (URL_ATOM, self.label) if self.label else URL_ATOM
        self.conn = urllib2.urlopen(url)

    def read(self):
        code = self.conn.getcode()
        if code != 200:
            self.conn.close()
            self.parent.error.emit(
                "HTTP Error %d: %s" %
                (code, BaseHTTPRequestHandler.responses[code]))
        else:
            self.data = self.conn.read()
            self.conn.close()

    def parse(self):
        tree = et.fromstring(self.data)
        for e in tree.findall("%sentry" % XMLNS):
            entry = Entry()
            entry.title = e.find("%stitle" % XMLNS).text
            entry.summary = e.find("%ssummary" % XMLNS).text
            entry.link = e.find("%slink" % XMLNS).attrib["href"]
            entry.modified = e.find("%smodified" % XMLNS).text
            entry.issued = e.find("%sissued" % XMLNS).text
            entry.id = e.find("%sid" % XMLNS).text
            for a in e.findall("%sauthor" % XMLNS):
                entry.author_name = a.find("%sname" % XMLNS).text
                entry.author_email = a.find("%semail" % XMLNS).text

            self.mutex.lock()
            self.parent.entries.append((self.label, entry))
            self.mutex.unlock()
Exemple #15
0
class Feed(QRunnable):
    def __init__(self, label, parent=None):
        QRunnable.__init__(self)
        self.label = label
        self.parent = parent
        self.data = None
        self.mutex = QMutex()
        self.setAutoDelete(True)

    def run(self):
        self.check()

    def check(self):
        try:
            self.fetch()
        except (urllib2.URLError, urllib2.HTTPError) as err:
            self.parent.error.emit(str(err))
        else:
            self.read()
            if self.data:
                self.parse()

    def fetch(self):
        auth_handler = urllib2.HTTPBasicAuthHandler()
        auth_handler.add_password(REALM, HOST,
                self.parent.user, self.parent.passwd)
        opener = urllib2.build_opener(auth_handler)
        urllib2.install_opener(opener)
        url = "%s/%s" % (URL_ATOM, self.label) if self.label else URL_ATOM
        self.conn = urllib2.urlopen(url)

    def read(self):
        code = self.conn.getcode()
        if code != 200:
            self.conn.close()
            self.parent.error.emit("HTTP Error %d: %s" % (
                code, BaseHTTPRequestHandler.responses[code]))
        else:
            self.data = self.conn.read()
            self.conn.close()

    def parse(self):
        tree = et.fromstring(self.data)
        for e in tree.findall("%sentry" % XMLNS):
            entry = Entry()
            entry.title = e.find("%stitle" % XMLNS).text
            entry.summary = e.find("%ssummary" % XMLNS).text
            entry.link = e.find("%slink" % XMLNS).attrib["href"]
            entry.modified = e.find("%smodified" % XMLNS).text
            entry.issued = e.find("%sissued" % XMLNS).text
            entry.id = e.find("%sid" % XMLNS).text
            for a in e.findall("%sauthor" % XMLNS):
                entry.author_name = a.find("%sname" % XMLNS).text
                entry.author_email = a.find("%semail" % XMLNS).text

            self.mutex.lock()
            self.parent.entries.append((self.label, entry))
            self.mutex.unlock()
Exemple #16
0
    def __init__(self, layers, isFiles):
        QThread.__init__(self, QThread.currentThread())
        self.layers = layers
        self.isFiles = isFiles

        self.mutex = QMutex()
        self.stopMe = 0

        self.errors = []
Exemple #17
0
 def __init__(self, searcher, parent):
     QThread.__init__(self, parent)
     self._searcher = searcher
     self._quit = False
     self._mutex = QMutex()
     self._pending = QWaitCondition()
     self._collector = None
     self._query = None
     self._result = None
Exemple #18
0
    def __init__( self, plugin, parent = None ):
        QThread.__init__( self, parent )

        self.__plugin = plugin
        self.__requestQueue = deque()

        self.__stopRequest = False
        self.__lock = QMutex()
        self.__condition = QWaitCondition()
        return
Exemple #19
0
 def __init__(self, parent = None):
   super(WorkerThread, self).__init__(parent)
   self.mutex = QMutex()
   self.condition = QWaitCondition()
   self.restart = False
   self.abort = False
   self.timeline = parent
   self.countThread = parent.countThread
   self.populateThread = parent.populateThread
   self.maxOccThread = parent.maxOccThread
    def __init__(self, dir, shapes, inputEncoding, outputFileName, outputEncoding):
        QThread.__init__(self, QThread.currentThread())
        self.baseDir = dir
        self.shapes = shapes
        self.inputEncoding = inputEncoding
        self.outputFileName = outputFileName
        self.outputEncoding = outputEncoding

        self.mutex = QMutex()
        self.stopMe = 0
Exemple #21
0
 def __init__(self, parent):
     QThread.__init__(self)
     self.parent = parent
     self.data = None
     self.list_img = None
     self._method = None
     self._cells_selection = None
     self.mutex = QMutex()
     self.filename = None
     self._stop = False
Exemple #22
0
 def __init__(self, index, lock, files, filenamesForWords,
              commonWords, parent=None):
     super(Walker, self).__init__(parent)
     self.index = index
     self.lock = lock
     self.files = files
     self.filenamesForWords = filenamesForWords
     self.commonWords = commonWords
     self.stopped = False
     self.mutex = QMutex()
     self.completed = False
Exemple #23
0
    def __init__(self, layer, splitField, encoding, outDir):
        QThread.__init__(self, QThread.currentThread())
        self.layer = layer
        self.field = splitField
        self.encoding = encoding
        self.outDir = outDir

        self.mutex = QMutex()
        self.stopMe = 0

        self.errors = []
Exemple #24
0
    def __init__( self, inPoly, inPoints, fieldName, outPath, encoding ):
        QThread.__init__( self, QThread.currentThread() )
        self.mutex = QMutex()
        self.stopMe = 0
        self.interrupted = False

        self.layerPoly = inPoly
        self.layerPoints = inPoints
        self.fieldName = fieldName
        self.outPath = outPath
        self.encoding = encoding
Exemple #25
0
    def __init__(self, framework, queueDataModel, pendingResponsesDataModel, pendingAnalysisDataModel, internalStateDataModel, parent = None):
        QThread.__init__(self, parent)
        self.framework = framework
        self.queueDataModel = queueDataModel
        self.pendingResponsesDataModel = pendingResponsesDataModel
        self.pendingAnalysisDataModel = pendingAnalysisDataModel
        self.internalStateDataModel = internalStateDataModel

        self.qlock = QMutex()
        self.qlock_analysis = QMutex()
        QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
        QObject.connect(self, SIGNAL('started()'), self.startedHandler)
 def __init__(self):
     QtGui.QMainWindow.__init__(self)
     self.mutex = QMutex()
     self.thr = GuiThread(process=self.fun, period=0.1)
     self.thr2 = GuiThread(process=self.fun2, period=0.1)
     self.buff = CircIoBuffer(byte_size=15 * len('rafal miecznik'))
     self.thr.start()
     self.thr2.start()
     time.sleep(2)
     print(self.buff.read())
     for d in dir(self.mutex):
         print(d)
Exemple #27
0
class ImporterThread(QThread):
    def __init__(self, framework, parent=None):
        QThread.__init__(self, parent)
        self.framework = framework
        self.qlock = QMutex()
        self.cursor = None
        QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
        QObject.connect(self, SIGNAL('started()'), self.startedHandler)

    def run(self):
        QObject.connect(self, SIGNAL('do_runImport()'), self.handle_runImport,
                        Qt.DirectConnection)
        self.exec_()

    def quitHandler(self):
        if self.cursor:
            self.cursor.close()
        self.exit(0)

    def startedHandler(self):
        pass

    def runImport(self, importers, proxy_file, source, callback):
        self.importers = importers
        self.proxy_filelist = [proxy_file]
        self.source = source
        self.callbackObj = callback
        QTimer.singleShot(50, self, SIGNAL('do_runImport()'))

    def runImportList(self, importers, proxy_filelist, source, callback):
        self.importers = importers
        self.proxy_filelist = proxy_filelist
        self.source = source
        self.callbackObj = callback
        QTimer.singleShot(50, self, SIGNAL('do_runImport()'))

    def handle_runImport(self):
        if self.qlock.tryLock():
            try:
                for proxy_file in self.proxy_filelist:
                    try:
                        self.framework.debug_log('attempting import of %s' %
                                                 (str(proxy_file)))
                        self.importers.process_import(str(proxy_file),
                                                      self.framework,
                                                      self.source)
                    except Exception as ex:
                        self.framework.report_exception(ex)
            finally:
                self.qlock.unlock()

        self.callbackObj.emit(SIGNAL('runImportFinished()'))
 def __init__(self):
     '''
     Constructor
     '''
     self._maths = {}
     self._mathsLock = QMutex()
     self._mathTTS = None
     
     # Start my math parsing thread, which will constantly parse math into
     # prose
     self.mathThread = MathParserThread(self._mathTTS)
     self.mathThread.mathParsed.connect(self._setMathData)
     self.mathThread.start()
Exemple #29
0
    def __init__(self, framework, parent=None):
        QThread.__init__(self, parent)
        self.framework = framework

        self.callback_object = None
        self.qtimer = QTimer()
        self.qlock = QMutex()
        QObject.connect(self, SIGNAL('quit()'), self.handle_quit)
        QObject.connect(self, SIGNAL('started()'), self.handle_started)

        self.Data = None
        self.read_cursor = None
        self.cursor = None
Exemple #30
0
class MyStreamHandler(StreamHandler):
    def __init__(self):
        StreamHandler.__init__(self)

    def createLock(self):
        # must be Recursive (= reentrant)
        self._mutex = QMutex(QMutex.Recursive)

    def acquire(self):
        self._mutex.lock()

    def release(self):
        self._mutex.unlock()
    def __init__(self, pdbConnector):
        QThread.__init__(self)

        self.resultRecordQueue = deque()
        self.resultRecordMutex = QMutex()
        self.resultRecordSem = QSemaphore(0)

        self.resultConsoleQueue = deque()
        self.resultConsoleMutex = QMutex()
        self.resultConsoleSem = QSemaphore(0)

        self.parser = PdbParser(pdbConnector, self)
        self.pdbConnector = pdbConnector
    def __init__(self, inPoly, inPoints, fieldName, outPath, encoding, attributeList, statisticSelector):
        QThread.__init__(self, QThread.currentThread())
        self.mutex = QMutex()
        self.stopMe = 0
        self.interrupted = False

        self.layerPoly = inPoly
        self.layerPoints = inPoints
        self.fieldName = fieldName
        self.outPath = outPath
        self.encoding = encoding
        self.attributeList = attributeList
        self.statistics = statisticSelector.currentText()
Exemple #33
0
class MyStreamHandler(StreamHandler):
    def __init__(self):
        StreamHandler.__init__(self)

    def createLock(self):
        # must be Recursive (= reentrant)
        self._mutex = QMutex(QMutex.Recursive)

    def acquire(self):
        self._mutex.lock()

    def release(self):
        self._mutex.unlock()
Exemple #34
0
    def __init__(self, function, inputLayer, useSelection, tolerance,
                 writeShape, shapePath, shapeEncoding):
        QThread.__init__(self, QThread.currentThread())
        self.inputLayer = inputLayer
        self.useSelection = useSelection
        self.tolerance = tolerance
        self.writeShape = writeShape
        self.outputFileName = shapePath
        self.outputEncoding = shapeEncoding
        self.myFunction = function

        self.mutex = QMutex()
        self.stopMe = 0
class VCSPluginThread( QThread ):
    " Wrapper for the plugin thread "

    def __init__( self, plugin, parent = None ):
        QThread.__init__( self, parent )

        self.__plugin = plugin
        self.__requestQueue = deque()

        self.__stopRequest = False
        self.__lock = QMutex()
        self.__condition = QWaitCondition()
        return

    def run( self ):
        " Thread loop "
        while not self.__stopRequest:
            self.__lock.lock()
            while self.__requestQueue:
                path, flag = self.__requestQueue.pop()
                self.__lock.unlock()
                time.sleep( 0.01 )
                self.__processRequest( path, flag )
                if self.__stopRequest:
                    break
                self.__lock.lock()
            if self.__stopRequest:
                self.__lock.unlock()
                break
            self.__condition.wait( self.__lock )
            self.__lock.unlock()
        return

    def __processRequest( self, path, flag ):
        " Processes a single request. It must be exception safe. "
        try:
            statuses = self.__plugin.getObject().getStatus( path, flag )
            for status in statuses:
                if len( status ) == 3:
                    self.emit( SIGNAL( "VCSStatus" ), path + status[ 0 ],
                               status[ 1 ], status[ 2 ] )
                else:
                    self.emit( SIGNAL( "VCSStatus" ), path, IND_VCS_ERROR,
                               "The " + self.__plugin.getName() + " plugin "
                               "does not follow the getStatus() interface "
                               "agreement" )
        except Exception, exc:
            self.emit( SIGNAL( "VCSStatus" ), path, IND_VCS_ERROR,
                       "Exception in " + self.__plugin.getName() +
                       " plugin while retrieving VCS status: " + str( exc ) )
        except:
Exemple #36
0
class ImporterThread(QThread):
    def __init__(self, framework, parent = None):
        QThread.__init__(self, parent)
        self.framework = framework
        self.qlock = QMutex()
        self.cursor = None
        QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
        QObject.connect(self, SIGNAL('started()'), self.startedHandler)

    def run(self):
        QObject.connect(self, SIGNAL('do_runImport()'), self.handle_runImport, Qt.DirectConnection)
        self.exec_()

    def quitHandler(self):
        if self.cursor:
            self.cursor.close()
        self.exit(0)

    def startedHandler(self):
        pass

    def runImport(self, importers, proxy_file, source, callback):
        self.importers = importers
        self.proxy_filelist = [proxy_file]
        self.source = source
        self.callbackObj = callback
        QTimer.singleShot(50, self, SIGNAL('do_runImport()'))

    def runImportList(self, importers, proxy_filelist, source, callback):
        self.importers = importers
        self.proxy_filelist = proxy_filelist
        self.source = source
        self.callbackObj = callback
        QTimer.singleShot(50, self, SIGNAL('do_runImport()'))

    def handle_runImport(self):
        if self.qlock.tryLock():
            try:
                for proxy_file in self.proxy_filelist:
                    try: 
                        self.framework.debug_log('attempting import of %s' % (str(proxy_file)))
                        self.importers.process_import(str(proxy_file), self.framework, self.source)
                    except Exception as ex:
                        self.framework.report_exception(ex)
            finally:
                self.qlock.unlock()
        
        self.callbackObj.emit(SIGNAL('runImportFinished()'))
	def __init__(self, obj, parent = None):
		QWidget.__init__(self, parent)
		self.prnt = obj
		self.setWindowTitle(self.prnt.tr._translate('M@il Checker : Stack'))
		self.mutex = QMutex()

		self.stack = QWidget()
		self.scroll = QScrollArea()
		self.scroll.setWidgetResizable(True)
		self.scroll.setWidget(self.stack)

		self.scrolledLayout = QVBoxLayout()
		self.buttonLayout = QHBoxLayout()
		self.stackLayout = QVBoxLayout()
		self.stackLayout.setSpacing(3)

		self.freezAllMSG = QPushButton(QIcon.fromTheme("layer-visible-on"), '')
		self.freezAllMSG.setToolTip(self.prnt.tr._translate('Freez all messages'))
		self.freezAllMSG.clicked.connect(self.freezAllMessages)
		self.clearAllMSG = QPushButton(QIcon.fromTheme("edit-clear"), '')
		self.clearAllMSG.setToolTip(self.prnt.tr._translate('Clear all messages'))
		self.clearAllMSG.clicked.connect(self.clearAllMessages)

		self.buttonLayout.addWidget(self.freezAllMSG)
		self.buttonLayout.addWidget(self.clearAllMSG)
		self.scrolledLayout.addItem(self.buttonLayout)
		self.scrolledLayout.addWidget(self.scroll)
		self.scrolledLayout.setSpacing(3)
		self.setLayout(self.scrolledLayout)

		self.setMinimumHeight(self.prnt.desktop.height()/5)
		self.setMinimumWidth(self.prnt.desktop.width()/3)
		self.stack.setStyleSheet("QWidget {background: rgba(235,240,255,0);}")
		self.MessageStack = {}
		self.checkEmpty.connect(self.checkStackContent)
Exemple #38
0
 def __init__(self, label, parent=None):
     QRunnable.__init__(self)
     self.imap = None
     self.label = label
     self.parent = parent
     self.mutex = QMutex()
     self.login()
Exemple #39
0
  def __init__( self, files, needPrj ):
    QThread.__init__( self, QThread.currentThread() )
    self.inFiles = files
    self.needPrj = needPrj

    self.mutex = QMutex()
    self.stopMe = 0
Exemple #40
0
 def __init__(self, framework, Data, parent = None):
     QThread.__init__(self, parent)
     self.framework = framework
     self.Data = Data
     self.qlock = QMutex()
     QObject.connect(self, SIGNAL('quit()'), self.quitHandler)
     QObject.connect(self, SIGNAL('started()'), self.startedHandler)
Exemple #41
0
class Evaluate(QThread):
    """Thread used to insolate calculation process in entities (stream, project
    and equipment, so gui can response while calculation is in process"""
    def __init__(self, parent=None):
        super(Evaluate, self).__init__(parent)
        self.mutex = QMutex()

    def start(self, entity, kwargs):
        self.entity = entity
        self.kwargs = kwargs
        QThread.start(self)

    def run(self):
        self.mutex.lock()
        self.entity(**self.kwargs)
        self.mutex.unlock()
Exemple #42
0
 def __init__(self, label, parent=None):
     QRunnable.__init__(self)
     self.label = label
     self.parent = parent
     self.data = None
     self.mutex = QMutex()
     self.setAutoDelete(True)
Exemple #43
0
 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
Exemple #44
0
 def __init__(self, weboob, parent=None):
     QObject.__init__(self, parent)
     self.weboob = weboob
     self.weboob.callbacks['login'] = self.callback(self.LoginRequest)
     self.mutex = QMutex()
     self.requests = []
     self.connect(self, SIGNAL('new_request'), self.do_request)
Exemple #45
0
    def __init__(self, rect):
        self._mutex = QMutex()
        self.image  = QImage(rect.width(), rect.height(), 
                             QImage.Format_ARGB32_Premultiplied)
        self.image.fill(0)

        self._topLeft = rect.topLeft()

        #Whenever the underlying data changes, the data version is incremented.
        #By comparing the data version to the image and request version, it can
        #be determined if the content of this tile is recent or needs to be
        #re-computed.
        
        #version of the data
        self.dataVer = 0
        
        #version of self.image
        #
        #If self.imgVer < self.dataVer, the image needs to be re-computed
        #from the new data.
        self.imgVer  = -1
        
        #version of the request that has been generated to update the contents
        #of self.image
        #
        #If self.reqVer == self.dataVer, a request is currently running that will
        #eventually replace self.image with the new data.
        self.reqVer  = -2
Exemple #46
0
	def __init__(self, parent, pattern=None, location=None, settings=None):
		"""
		Initializes the class.

		:param parent: Object parent.
		:type parent: QObject
		"""

		LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__))

		QThread.__init__(self, parent)

		# --- Setting class attributes. ---
		self.__container = parent

		self.__pattern = None
		self.pattern = pattern
		self.__location = None
		self.location = location
		self.__settings = None
		self.settings = settings

		self.__searchResults = None

		self.__interrupt = False
		self.__lock = QMutex()
Exemple #47
0
 def __init__(self, interval, projectDir, vcs, parent = None):
     """
     Constructor
     
     @param interval new interval in seconds (integer)
     @param projectDir project directory to monitor (string or QString)
     @param vcs reference to the version control object
     @param parent reference to the parent object (QObject)
     """
     QThread.__init__(self, parent)
     self.setObjectName("VcsStatusMonitorThread")
     
     self.setTerminationEnabled(True)
     
     self.projectDir = QString(projectDir)
     self.vcs = vcs
     
     self.interval = interval
     self.autoUpdate = False
     
     self.statusList = QStringList()
     self.reportedStates = {}
     self.shouldUpdate = False
     
     self.monitorMutex = QMutex()
     self.monitorCondition = QWaitCondition()
     self.__stopIt = False
 def __init__(self, parent):
     QThread.__init__(self)
     self.result = None
     self.parent = parent
     self._stopped = False
     self.mutex = QMutex()
     self.filePrefix = None
     self.fileFormat = None
     self.wallColoring = None
     self.cellColoring = None
     self.pointColoring = None
     self.extraDrawing = []
     self.pointSize = None
     self.pointLineColor = None
     self.pointLineThickness = None
     self.ellipsisDraw = None
     self.overSampling = None
     self.wallThickness = None
     self.bgColor = None
     self.loading = False
     self._crop = QRect(0,0,1,1)
     self._pix = None
     self._end_image_plot = False
     self._loading_arguments = {}
     self.retryObject = None
 def __init__(self,tid,name,counter):
     QThread.__init__(self)
     
     global sio
     self.mutex = QMutex()
     self.tid = tid
     self.name = name
     self.counter = counter
Exemple #50
0
 def __init__(self, *args):
   QThread.__init__(self)
   self.typeQueue = Queue()
   self.regImage = re.compile("(JPEG|JPG|jpg|jpeg|GIF|gif|bmp|BMP|png|PNG|pbm|PBM|pgm|PGM|ppm|PPM|xpm|XPM|xbm|XBM|TIFF|tiff).*", re.IGNORECASE)
   self.typeQueue = []
   self.setUniq = set()
   self.qmutex = QMutex()
   self.qsem = QSemaphore()
Exemple #51
0
 def __init__(self, length):
     super(Recorder, self).__init__()
     self.dataAccessMutex = QMutex()
     self.data = []
     self.client = connection()
     self.temperatureClient = temperatureConnection()
     self.length = length
     self.tempeatureUpdateRequested = False
class ComputationThread(QThread):
   def __init__(self, animation_thread):
      QThread.__init__(self) 
      self.is_running =  True
      self.mutex = QMutex()
      self.other_thread = animation_thread

   def stop(self):
      self.is_running = False

   def run(self):
      while  self.is_running:
         self.mutex.lock() # locking may not be necessary
         raw_input("")
         #self.other_thread.stop( )
         self.mutex.unlock()
      print " run method ends "
Exemple #53
0
class UdpClient(QThread):
	def __init__(self, parent):
		QThread.__init__(self, parent)

		self.prnt = parent
		self.udp = QUdpSocket()
		addr = QHostAddress(QHostAddress.Any)
		print 'bind to:', addr.toString()
		self.udp.bind(addr, 34001)
		self.udp.error.connect(self.errorAnalyser)
		self.udp.readyRead.connect(self.readUdp)
		print "Binding..."
		self.STOP = False
		self.locker = QMutex()

	def run(self):
		self.prnt.initAvahiService()
		while True :
			if self.udp is not None and self.udp.state() == QAbstractSocket.ConnectedState :
				self.udp.waitForReadyRead()
			else : self.msleep(100)
			if self.STOP and self.udp is not None: self.udp.close(); break
		print 'UDPClient closed...'
		self.prnt.changeConnectState.emit()

	def stop(self):
		self.locker.lock()
		self.STOP = True
		self.locker.unlock()

	def readUdp(self):
		while ( self.udp.hasPendingDatagrams() ):
			data = QByteArray()
			addr = QHostAddress()
			port = 0
			try :
				datagramSize = self.udp.pendingDatagramSize()
				if datagramSize > 0 :
					(data, addr, port) = self.udp.readDatagram(datagramSize)
					#print "Datagram: [%s] from %s:%i" % (QString().fromUtf8(data), addr.toString(), port)
					self.prnt.contactMessage.emit(QString().fromUtf8(data), addr.toString())
			except socket.error, err :
				print '[in readUdp() UdpClient] SocketError1 : ', err
			except socket.timeout, err :
				print '[in readUdp() UdpClient] SocketError2 : ', err
			except :
Exemple #54
0
 def __init__(self, searcher, parent):
     QThread.__init__(self, parent)
     self._searcher = searcher
     self._quit = False
     self._mutex = QMutex()
     self._pending = QWaitCondition()
     self._collector = None
     self._query = None
     self._result = None
Exemple #55
0
 def __init__(self, parent=None, text='light_button', color_scheme='green',
              initial_state=False):
     super(LightButton, self).__init__(text=text, parent=parent)
     self.setCheckable(True)
     self.setChecked(initial_state)
     self._color_scheme = None
     self.setColorscheme(color_scheme)
     self.value_change_signal_mutex = QMutex()
     self.toggled.connect(self.valueChanged)
Exemple #56
0
  def __init__( self, layers, isFiles ):
    QThread.__init__( self, QThread.currentThread() )
    self.layers = layers
    self.isFiles = isFiles

    self.mutex = QMutex()
    self.stopMe = 0

    self.errors = []
Exemple #57
0
class QCallbacksManager(QObject):
    class Request(object):
        def __init__(self):
            self.event = Event()
            self.answer = None

        def __call__(self):
            raise NotImplementedError()

    class LoginRequest(Request):
        def __init__(self, backend_name, value):
            QCallbacksManager.Request.__init__(self)
            self.backend_name = backend_name
            self.value = value

        def __call__(self):
            password, ok = QInputDialog.getText(None,
                '%s request' % self.value.label,
                'Please enter %s for %s' % (self.value.label,
                                            self.backend_name),
                                                QLineEdit.Password)
            return password

    new_request = Signal()

    def __init__(self, weboob, parent=None):
        QObject.__init__(self, parent)
        self.weboob = weboob
        self.weboob.callbacks['login'] = self.callback(self.LoginRequest)
        self.mutex = QMutex()
        self.requests = []
        self.new_request.connect(self.do_request)

    def callback(self, klass):
        def cb(*args, **kwargs):
            return self.add_request(klass(*args, **kwargs))
        return cb

    @Slot()
    def do_request(self):
        self.mutex.lock()
        request = self.requests.pop()
        request.answer = request()
        request.event.set()
        self.mutex.unlock()

    def add_request(self, request):
        self.mutex.lock()
        self.requests.append(request)
        self.mutex.unlock()
        self.new_request.emit()
        request.event.wait()
        return request.answer