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


Python pywintypes.OVERLAPPED属性代码示例

本文整理汇总了Python中pywintypes.OVERLAPPED属性的典型用法代码示例。如果您正苦于以下问题:Python pywintypes.OVERLAPPED属性的具体用法?Python pywintypes.OVERLAPPED怎么用?Python pywintypes.OVERLAPPED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pywintypes的用法示例。


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

示例1: __init__

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def __init__(self,tuntap,transmit):
    
        # store params
        self.tuntap               = tuntap
        self.transmit             = transmit
        
        # local variables
        self.goOn                 = True
        self.overlappedRx         = pywintypes.OVERLAPPED()
        self.overlappedRx.hEvent  = win32event.CreateEvent(None, 0, 0, None)
        
        # initialize parent
        threading.Thread.__init__(self)
        
        # give this thread a name
        self.name                 = 'readThread' 
开发者ID:alexsunday,项目名称:pyvpn,代码行数:18,代码来源:tun-ping-responder.py

示例2: _watcherThread

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def _watcherThread(self, dn, dh, changes):
        # A synchronous version:
        # XXX - not used - I was having a whole lot of problems trying to
        # get this to work.  Specifically:
        # * ReadDirectoryChangesW without an OVERLAPPED blocks infinitely.
        # * If another thread attempts to close the handle while
        #   ReadDirectoryChangesW is waiting on it, the ::CloseHandle() method
        #   blocks (which has nothing to do with the GIL - it is correctly
        #   managed)
        # Which ends up with no way to kill the thread!
        flags = win32con.FILE_NOTIFY_CHANGE_FILE_NAME
        while 1:
            try:
                print "waiting", dh
                changes = win32file.ReadDirectoryChangesW(dh,
                                                          8192,
                                                          False, #sub-tree
                                                          flags)
                print "got", changes
            except:
                raise
            changes.extend(changes) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_win32file.py

示例3: test_connect_with_payload

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def test_connect_with_payload(self):
        giveup_event = win32event.CreateEvent(None, 0, 0, None)
        t = threading.Thread(target=self.connect_thread_runner,
                             args=(True, giveup_event))
        t.start()
        time.sleep(0.1)
        s2 = socket.socket()
        ol = pywintypes.OVERLAPPED()
        s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand
        try:
            win32file.ConnectEx(s2, self.addr, ol, str2bytes("some expected request"))
        except win32file.error, exc:
            win32event.SetEvent(giveup_event)
            if exc.winerror == 10022: # WSAEINVAL
                raise TestSkipped("ConnectEx is not available on this platform")
            raise # some error error we don't expect. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_win32file.py

示例4: test_connect_without_payload

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def test_connect_without_payload(self):
        giveup_event = win32event.CreateEvent(None, 0, 0, None)
        t = threading.Thread(target=self.connect_thread_runner,
                             args=(False, giveup_event))
        t.start()
        time.sleep(0.1)
        s2 = socket.socket()
        ol = pywintypes.OVERLAPPED()
        s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand
        try:
            win32file.ConnectEx(s2, self.addr, ol)
        except win32file.error, exc:
            win32event.SetEvent(giveup_event)
            if exc.winerror == 10022: # WSAEINVAL
                raise TestSkipped("ConnectEx is not available on this platform")
            raise # some error error we don't expect. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_win32file.py

示例5: __init__

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def __init__(self, filename):
        self._hfile = win32file.CreateFile(filename,
                                           win32con.GENERIC_READ | win32con.GENERIC_WRITE,
                                           win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
                                           win32security.SECURITY_ATTRIBUTES(),
                                           win32con.OPEN_EXISTING,
                                           win32con.FILE_FLAG_OVERLAPPED,
                                           0)
        self._read_ovrlpd = pywintypes.OVERLAPPED()
        self._read_ovrlpd.hEvent = win32event.CreateEvent(None, True,
                                                          False, None)
        self._write_ovrlpd = pywintypes.OVERLAPPED()
        self._write_ovrlpd.hEvent = win32event.CreateEvent(None, True,
                                                           False, None)
        self._bufs = []
        self._n = 0 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:18,代码来源:windows_support.py

示例6: packet_writer_win

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def packet_writer_win(self, packet):
		import pywintypes
		import win32file

		overlapped_write = pywintypes.OVERLAPPED()
		win32file.WriteFile(self.tunnel_w, packet, overlapped_write)
		return

	# on MacOS(X) utun, all packets needs to be prefixed with 4 specific bytes 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:11,代码来源:Stateful_module.py

示例7: send

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def send(self, channel_type, message, additional_data):
		if channel_type == common.CONTROL_CHANNEL_BYTE:
			transformed_message = self.transform(self.encryption, common.CONTROL_CHANNEL_BYTE+message, 1)
		else:
			transformed_message = self.transform(self.encryption, common.DATA_CHANNEL_BYTE+message, 1)

		common.internal_print("RDP sent: {0}".format(len(transformed_message)), 0, self.verbosity, common.DEBUG)

		overlapped_write = pywintypes.OVERLAPPED()
		try:
			win32file.WriteFile(self.comms_socket, struct.pack(">H", len(transformed_message))+transformed_message, overlapped_write)
		except Exception as e:
			raise 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:15,代码来源:RDP.py

示例8: packet_writer_win

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def packet_writer_win(self, packet):
		import pywintypes
		import win32file

		overlapped_write = pywintypes.OVERLAPPED()
		win32file.WriteFile(self.tunnel, packet, overlapped_write)
		return

	# on MacOS(X) utun, all packets needs to be prefixed with 4 specific bytes 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:11,代码来源:Stateless_module.py

示例9: post_authentication_server

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def post_authentication_server(self, control_message, additional_data):
		c = self.lookup_client_pub(additional_data)
		if c.get_initiated():
			c.set_authenticated(True)
			self.packetselector.add_client(c)
			if c.get_pipe_r() not in self.rlist:
				self.rlist.append(c.get_pipe_r())
				if self.os_type == common.OS_WINDOWS:
					# creating objects and adding to corresponding lists
					import win32event
					import win32file
					import pywintypes

					hEvent_pipe = win32event.CreateEvent(None, 0, 0, None) # for reading from the pipe
					overlapped_pipe = pywintypes.OVERLAPPED()
					overlapped_pipe.hEvent = hEvent_pipe
					message_buffer = win32file.AllocateReadBuffer(4096)
					self.olist.append(overlapped_pipe)
					self.elist.append(hEvent_pipe)
					self.mlist.append(message_buffer)
					self.ulist.append(len(self.elist)-1)
			return True

		return False

	# PLACEHOLDER: prolog for the communication
	# What comes here: anything that should be set up before the actual
	# communication 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:30,代码来源:Stateless_module.py

示例10: unlock_and_close

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def unlock_and_close(self):
      """Close and unlock the file using the win32 primitive."""
      if self._locked:
        try:
          hfile = win32file._get_osfhandle(self._fh.fileno())
          win32file.UnlockFileEx(hfile, 0, -0x10000, pywintypes.OVERLAPPED())
        except pywintypes.error as e:
          if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
            raise
      self._locked = False
      if self._fh:
        self._fh.close() 
开发者ID:mortcanty,项目名称:earthengine,代码行数:14,代码来源:locked_file.py

示例11: HttpExtensionProc

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def HttpExtensionProc(self, control_block):
        overlapped = OVERLAPPED()
        overlapped.object = control_block
        PostQueuedCompletionStatus(self.io_req_port, 0, ISAPI_REQUEST, overlapped)
        return isapicon.HSE_STATUS_PENDING 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:threaded_extension.py

示例12: __init__

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = CreateEvent(None, 0, 0, None)
        self.overlapped = pywintypes.OVERLAPPED()
        self.overlapped.hEvent = CreateEvent(None,0,0,None)
        self.thread_handles = [] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:pipeTestService.py

示例13: testTransactNamedPipeAsync

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def testTransactNamedPipeAsync(self):
        event = threading.Event()
        overlapped = pywintypes.OVERLAPPED()
        overlapped.hEvent = win32event.CreateEvent(None, 0, 0, None)
        self.startPipeServer(event, 0.5)
        open_mode = win32con.GENERIC_READ | win32con.GENERIC_WRITE

        hpipe = win32file.CreateFile(self.pipename,
                                     open_mode,
                                     0, # no sharing
                                     None, # default security
                                     win32con.OPEN_EXISTING,
                                     win32con.FILE_FLAG_OVERLAPPED,
                                     None)

        # set to message mode.
        win32pipe.SetNamedPipeHandleState(
                        hpipe, win32pipe.PIPE_READMODE_MESSAGE, None, None)

        buffer = win32file.AllocateReadBuffer(1024)
        hr, got = win32pipe.TransactNamedPipe(hpipe, str2bytes("foo\0bar"), buffer, overlapped)
        self.failUnlessEqual(hr, winerror.ERROR_IO_PENDING)
        nbytes = win32file.GetOverlappedResult(hpipe, overlapped, True)
        got = buffer[:nbytes]
        self.failUnlessEqual(got, str2bytes("bar\0foo"))
        event.wait(5)
        self.failUnless(event.isSet(), "Pipe server thread didn't terminate") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:29,代码来源:test_win32pipe.py

示例14: testSimpleOverlapped

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def testSimpleOverlapped(self):
        # Create a file in the %TEMP% directory.
        import win32event
        testName = os.path.join( win32api.GetTempPath(), "win32filetest.dat" )
        desiredAccess = win32file.GENERIC_WRITE
        overlapped = pywintypes.OVERLAPPED()
        evt = win32event.CreateEvent(None, 0, 0, None)
        overlapped.hEvent = evt
        # Create the file and write shit-loads of data to it.
        h = win32file.CreateFile( testName, desiredAccess, 0, None, win32file.CREATE_ALWAYS, 0, 0)
        chunk_data = str2bytes("z") * 0x8000
        num_loops = 512
        expected_size = num_loops * len(chunk_data)
        for i in range(num_loops):
            win32file.WriteFile(h, chunk_data, overlapped)
            win32event.WaitForSingleObject(overlapped.hEvent, win32event.INFINITE)
            overlapped.Offset = overlapped.Offset + len(chunk_data)
        h.Close()
        # Now read the data back overlapped
        overlapped = pywintypes.OVERLAPPED()
        evt = win32event.CreateEvent(None, 0, 0, None)
        overlapped.hEvent = evt
        desiredAccess = win32file.GENERIC_READ
        h = win32file.CreateFile( testName, desiredAccess, 0, None, win32file.OPEN_EXISTING, 0, 0)
        buffer = win32file.AllocateReadBuffer(0xFFFF)
        while 1:
            try:
                hr, data = win32file.ReadFile(h, buffer, overlapped)
                win32event.WaitForSingleObject(overlapped.hEvent, win32event.INFINITE)
                overlapped.Offset = overlapped.Offset + len(data)
                if not data is buffer:
                    self.fail("Unexpected result from ReadFile - should be the same buffer we passed it")
            except win32api.error:
                break
        h.Close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:37,代码来源:test_win32file.py

示例15: testCompletionPortsQueued

# 需要导入模块: import pywintypes [as 别名]
# 或者: from pywintypes import OVERLAPPED [as 别名]
def testCompletionPortsQueued(self):
        class Foo: pass
        io_req_port = win32file.CreateIoCompletionPort(-1, None, 0, 0)
        overlapped = pywintypes.OVERLAPPED()
        overlapped.object = Foo()
        win32file.PostQueuedCompletionStatus(io_req_port, 0, 99, overlapped)
        errCode, bytes, key, overlapped = \
                win32file.GetQueuedCompletionStatus(io_req_port, win32event.INFINITE)
        self.failUnlessEqual(errCode, 0)
        self.failUnless(isinstance(overlapped.object, Foo)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_win32file.py


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