B H8͋@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs"tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZt||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fS| dk rt| | dk rt| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNT)r)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr8/opt/alt/python37/lib/python3.7/asyncio/windows_utils.pyr sB           rc@s\eZdZdZddZddZeddZdd Ze j d d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__)rrrrr__repr__Ys zPipeHandle.__repr__cCs|jS)N)r)rrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueError)rrrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dS)N)r)rrrrrcloseis  zPipeHandle.closecCs,|jdk r(tjd|t|d|dS)Nz unclosed )source)rwarningswarnResourceWarningr#)rrrr__del__ns zPipeHandle.__del__cCs|S)Nr)rrrr __enter__tszPipeHandle.__enter__cCs |dS)N)r#)rtvtbrrr__exit__wszPipeHandle.__exit__N)r __module__ __qualname____doc__rr propertyrr"rrr#r(r)r-rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drt|dddks"td}}}d} } } |tkrbtddd\} } t| tj}n|}|tkrtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zy t j |f|||d |Wn4x$| | | fD]}|dk rt |qWYn>X| dk r0t | |_| dk rDt | |_| dk rXt | |_Wd|tkrpt||tkrt||tkrt|XdS) NZuniversal_newlinesrr)FTT)rr)TF)r)stdinstdoutstderr)getAssertionErrorrrmsvcrtZopen_osfhandler O_RDONLYSTDOUTsuperrrrrr2r3r4r#)rargsr2r3r4kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)rrrrsL            zPopen.__init__)NNN)rr.r/r0r __classcell__rr)rrr~sr)r0sysplatform ImportErrorr itertoolsr7r subprocessr r%__all__ZBUFSIZErr9countrrrrrrrrs$ 1-