当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QMutex类代码示例

本文整理汇总了Python中PyQt4.QtCore.QMutex的典型用法代码示例。如果您正苦于以下问题:Python QMutex类的具体用法?Python QMutex怎么用?Python QMutex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QMutex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: QtStreamHandler

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";
开发者ID:rahulsinha20,项目名称:py-youtube-downloader,代码行数:31,代码来源:CustomLoggingHandler.py

示例2: Feed

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()
开发者ID:gen2brain,项目名称:gmailcheck,代码行数:58,代码来源:gmailcheck.py

示例3: __init__

    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)
开发者ID:Averroes,项目名称:raft,代码行数:12,代码来源:SpiderThread.py

示例4: MyStreamHandler

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()
开发者ID:AlecChou,项目名称:ldoce5viewer,代码行数:13,代码来源:error.py

示例5: VCSPluginThread

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:
开发者ID:eaglexmw,项目名称:codimension,代码行数:51,代码来源:vcspluginthread.py

示例6: ImporterThread

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()'))
开发者ID:Averroes,项目名称:raft,代码行数:48,代码来源:ImporterThread.py

示例7: __init__

 def __init__(self, label, parent=None):
     QRunnable.__init__(self)
     self.imap = None
     self.label = label
     self.parent = parent
     self.mutex = QMutex()
     self.login()
开发者ID:gen2brain,项目名称:gmailcheck,代码行数:7,代码来源:gmailcheck.py

示例8: __init__

	def __init__(self, obj, parent = None):
		QWidget.__init__(self, parent)
		self.prnt = obj
		self.setWindowTitle(self.prnt.tr._translate('[email protected] 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)
开发者ID:F1ash,项目名称:pyqt-mail-checker,代码行数:35,代码来源:MessageStackWidget.py

示例9: __init__

 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)
开发者ID:frankrousseau,项目名称:weboob,代码行数:7,代码来源:qt.py

示例10: __init__

 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)
开发者ID:Averroes,项目名称:raft,代码行数:7,代码来源:DatabaseThread.py

示例11: __init__

    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
开发者ID:LimpingTwerp,项目名称:volumina,代码行数:28,代码来源:tiling.py

示例12: Evaluate

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()
开发者ID:edusegzy,项目名称:pychemqt,代码行数:16,代码来源:thread.py

示例13: __init__

 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
开发者ID:dpeinado,项目名称:restec,代码行数:7,代码来源:walker.py

示例14: __init__

  def __init__( self, files, needPrj ):
    QThread.__init__( self, QThread.currentThread() )
    self.inFiles = files
    self.needPrj = needPrj

    self.mutex = QMutex()
    self.stopMe = 0
开发者ID:Ariki,项目名称:QGIS,代码行数:7,代码来源:doExtractProj.py

示例15: __init__

 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
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:25,代码来源:plottingdlg.py


注:本文中的PyQt4.QtCore.QMutex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。