當前位置: 首頁>>代碼示例>>Python>>正文


Python win32event.ResetEvent方法代碼示例

本文整理匯總了Python中win32event.ResetEvent方法的典型用法代碼示例。如果您正苦於以下問題:Python win32event.ResetEvent方法的具體用法?Python win32event.ResetEvent怎麽用?Python win32event.ResetEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32event的用法示例。


在下文中一共展示了win32event.ResetEvent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: serialReadEvent

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import ResetEvent [as 別名]
def serialReadEvent(self):
        #get that character we set up
        n = win32file.GetOverlappedResult(self._serial.hComPort, self._overlappedRead, 0)
        if n:
            first = str(self.read_buf[:n])
            #now we should get everything that is already in the buffer
            flags, comstat = win32file.ClearCommError(self._serial.hComPort)
            if comstat.cbInQue:
                win32event.ResetEvent(self._overlappedRead.hEvent)
                rc, buf = win32file.ReadFile(self._serial.hComPort,
                                             win32file.AllocateReadBuffer(comstat.cbInQue),
                                             self._overlappedRead)
                n = win32file.GetOverlappedResult(self._serial.hComPort, self._overlappedRead, 1)
                #handle all the received data:
                self.protocol.dataReceived(first + str(buf[:n]))
            else:
                #handle all the received data:
                self.protocol.dataReceived(first)

        #set up next one
        win32event.ResetEvent(self._overlappedRead.hEvent)
        rc, self.read_buf = win32file.ReadFile(self._serial.hComPort,
                                               win32file.AllocateReadBuffer(1),
                                               self._overlappedRead) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:_win32serialport.py

示例2: serialReadEvent

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import ResetEvent [as 別名]
def serialReadEvent(self):
        #get that character we set up
        n = win32file.GetOverlappedResult(self._serial._port_handle, self._overlappedRead, 0)
        first = to_bytes(self.read_buf[:n])
        #now we should get everything that is already in the buffer
        flags, comstat = self._clearCommError()
        if comstat.cbInQue:
            win32event.ResetEvent(self._overlappedRead.hEvent)
            rc, buf = win32file.ReadFile(self._serial._port_handle,
                                         win32file.AllocateReadBuffer(comstat.cbInQue),
                                         self._overlappedRead)
            n = win32file.GetOverlappedResult(self._serial._port_handle, self._overlappedRead, 1)
            #handle all the received data:
            self.protocol.dataReceived(first + to_bytes(buf[:n]))
        else:
            #handle all the received data:
            self.protocol.dataReceived(first)

        #set up next one
        win32event.ResetEvent(self._overlappedRead.hEvent)
        rc, self.read_buf = win32file.ReadFile(self._serial._port_handle,
                                               win32file.AllocateReadBuffer(1),
                                               self._overlappedRead) 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:25,代碼來源:_win32serialport.py

示例3: Connect

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import ResetEvent [as 別名]
def Connect(entryName, bUseCallback):
    if bUseCallback:
        theCallback = Callback
        win32event.ResetEvent(callbackEvent)
    else:
        theCallback = None
    #       in order to *use* the username/password of a particular dun entry, one must
    #       explicitly get those params under win95....
    try:
        dp, b = win32ras.GetEntryDialParams( None, entryName )
    except:
        print "Couldn't find DUN entry: %s" % entryName
    else:
        hras, rc = win32ras.Dial(None, None, (entryName, "", "", dp[ 3 ], dp[ 4 ], ""),theCallback)
    #       hras, rc = win32ras.Dial(None, None, (entryName, ),theCallback)
    #       print hras, rc
        if not bUseCallback and rc != 0:
            print "Could not dial the RAS connection:", win32ras.GetErrorString(rc)
            hras = HangUp( hras )
        #       don't wait here if there's no need to....
        elif bUseCallback and win32event.WaitForSingleObject(callbackEvent, 60000)!=win32event.WAIT_OBJECT_0:
            print "Gave up waiting for the process to complete!"
            #       sdk docs state one must explcitly hangup, even if there's an error....
            try:
                cs = win32ras.GetConnectStatus( hras )
            except:
                #       on error, attempt a hang up anyway....
                hras = HangUp( hras )
            else:
                if int( cs[ 0 ] ) == win32ras.RASCS_Disconnected:
                    hras = HangUp( hras )
    return hras, rc 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:34,代碼來源:rastest.py

示例4: Write

# 需要導入模塊: import win32event [as 別名]
# 或者: from win32event import ResetEvent [as 別名]
def Write(self, data, timeout):
        if self.handle:
            try:
                self.lockObject.acquire()
                if eg.debugLevel:
                    print "writing " + str(len(data)) + " bytes to " + self.getName()
                if not self._overlappedWrite:
                    self._overlappedWrite = win32file.OVERLAPPED()
                err, n = win32file.WriteFile(self.handle, data, self._overlappedWrite)
                if err:  #will be ERROR_IO_PENDING:
                    # Wait for the write to complete.
                    n = win32file.GetOverlappedResult(self.handle, self._overlappedWrite, 1)
                    if n != len(data):
                        raise Exception("could not write full data")
                elif n != len(data):
                    raise Exception("could not write full data")
                if timeout:  #waits for response from device
                    win32event.ResetEvent(self._overlappedRead.hEvent)
                    res = win32event.WaitForSingleObject(self._overlappedRead.hEvent, timeout)
                    if res == win32event.WAIT_TIMEOUT:
                        raise Exception("no response from device within timeout")
            finally:
                self.lockObject.release()
        else:
            raise Exception("invalid handle")
            return 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:28,代碼來源:HID.py


注:本文中的win32event.ResetEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。