本文整理汇总了Python中win32pipe.PeekNamedPipe方法的典型用法代码示例。如果您正苦于以下问题:Python win32pipe.PeekNamedPipe方法的具体用法?Python win32pipe.PeekNamedPipe怎么用?Python win32pipe.PeekNamedPipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32pipe
的用法示例。
在下文中一共展示了win32pipe.PeekNamedPipe方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkWork
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def checkWork(self):
finished = 0
fullDataRead = []
while 1:
try:
buffer, bytesToRead, result = win32pipe.PeekNamedPipe(self.pipe, 1)
# finished = (result == -1)
if not bytesToRead:
break
hr, data = win32file.ReadFile(self.pipe, bytesToRead, None)
fullDataRead.append(data)
except win32api.error:
finished = 1
break
dataBuf = b''.join(fullDataRead)
if dataBuf:
self.receivedCallback(dataBuf)
if finished:
self.cleanup()
return len(dataBuf)
示例2: _recv
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception) as why:
if why.args[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
# if self.universal_newlines:
# read = self._translate_newlines(read)
return read
示例3: _recv
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except (ValueError, NameError):
return self._close(which)
except (subprocess.pywintypes.error, Exception), why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
示例4: _peek
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _peek(self):
if self._closed:
return False
# Check if there is anything to read and read if available
(read, nAvail, nMessage) = win32pipe.PeekNamedPipe(self._osfhandle, 0)
if nAvail >= self._buffer_size:
data = self._pipe.read(self._buffer_size)
self._buffer += data
# If there is read_async callback and buffer has some data,
# send them right away
if not self._waits_for_read is None and len(self._buffer) > 0:
r = WinPopenReader.Results(self._buffer)
self._buffer = ""
callback, data = self._waits_for_read
self._waits_for_read = None
callback(self, r, *data)
GLib.idle_add(self._peek)
return False
GLib.timeout_add_seconds(1, self._peek)
return False
示例5: _recv
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception) as why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
#if self.universal_newlines:
# read = self._translate_newlines(read)
return read
示例6: _recv
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception), why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
#if self.universal_newlines:
# read = self._translate_newlines(read)
示例7: checkWork
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def checkWork(self):
finished = 0
fullDataRead = []
while 1:
try:
buffer, bytesToRead, result = win32pipe.PeekNamedPipe(self.pipe, 1)
# finished = (result == -1)
if not bytesToRead:
break
hr, data = win32file.ReadFile(self.pipe, bytesToRead, None)
fullDataRead.append(data)
except win32api.error:
finished = 1
break
dataBuf = ''.join(fullDataRead)
if dataBuf:
self.receivedCallback(dataBuf)
if finished:
self.cleanup()
return len(dataBuf)
示例8: _recv
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception):
if geterror()[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
if self.universal_newlines:
# Translate newlines. For Python 3.x assume read is text.
# If bytes then another solution is needed.
read = read.replace("\r\n", "\n").replace("\r", "\n")
return read
示例9: PeekNamedPipe
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def PeekNamedPipe(hPipe, size):
assert size == 0
bytesAvail = DWORD()
bErr = ctypes.windll.kernel32.PeekNamedPipe(
hPipe, None, size, None, ctypes.byref(bytesAvail), None)
if not bErr:
raise ctypes.WinError()
return ("", bytesAvail.value, None)
示例10: peek
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def peek(self):
"""Returns the number of bytes available for reading without blocking.
@return A two values, the first the number of bytes, and the second, an error code. An error code
of zero indicates there was no error.
@rtype (int, int)
"""
result = win32pipe.PeekNamedPipe(self.__pipe_handle, 1024)
if result:
return result[1], 0
else:
return 0, 1
示例11: PeekNamedPipe
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import PeekNamedPipe [as 别名]
def PeekNamedPipe(handle, desired_bytes):
c_avail = DWORD()
c_message = DWORD()
if desired_bytes > 0:
c_read = DWORD()
buffer = ctypes.create_string_buffer(desired_bytes+1)
success = ctypes.windll.kernel32.PeekNamedPipe(handle, buffer, desired_bytes, ctypes.byref(c_read), ctypes.byref(c_avail), ctypes.byref(c_message))
buffer[c_read.value] = null_byte
return decode(buffer.value), c_avail.value, c_message.value
else:
success = ctypes.windll.kernel32.PeekNamedPipe(handle, None, desired_bytes, None, ctypes.byref(c_avail), ctypes.byref(c_message))
return "", c_avail.value, c_message.value