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


Python win32pipe.PeekNamedPipe方法代码示例

本文整理汇总了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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:_pollingfile.py

示例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 
开发者ID:refack,项目名称:GYP3,代码行数:24,代码来源:TestCmd.py

示例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 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:20,代码来源:subprocessng.py

示例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 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:22,代码来源:windows.py

示例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 
开发者ID:turbulenz,项目名称:gyp,代码行数:24,代码来源:TestCmd.py

示例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) 
开发者ID:kawalpemilu,项目名称:kawalpemilu2014,代码行数:23,代码来源:TestCmd.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:24,代码来源:_pollingfile.py

示例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 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:26,代码来源:async_sub.py

示例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) 
开发者ID:refack,项目名称:GYP3,代码行数:10,代码来源:TestCmd.py

示例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 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:15,代码来源:platform_windows.py

示例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 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:14,代码来源:async_sub.py


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