當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。