a  ze@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.Nwin32z 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} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| durt| | durt| Yn0dS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfilemktempformatosgetpidnext _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) rrr addressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrI/opt/bitninja-python-dojo/embedded/lib/python3.9/asyncio/windows_utils.pyr sJ            rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdurd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdurtd|jS)NzI/O operation on closed pipe)r ValueErrorr(rrrfilenods zPipeHandle.fileno)rcCs|jdur||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdur&|d|t|d|dS)Nz unclosed )source)rResourceWarningr+)r_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr(rrr __enter__sszPipeHandle.__enter__cCs |dSr)r+)rtvtbrrr__exit__vszPipeHandle.__exit__N)r& __module__ __qualname____doc__r r'propertyrr*rrr+warningswarnr/r0r4rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drJ|dddks"Jd}}}d} } } |tkrbtddd\} } t| tj}n|}|tkrtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d |Wn0| | | fD]}|durt |qYn>0| dur,t | |_ | dur@t | |_| durTt | |_W|tkrjt||tkr~t||tkrt|n>|tkrt||tkrt||tkrt|0dS) Nuniversal_newlinesr r)FTT)rr)TFr )stdinstdoutstderr)getrrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr rrrr<r=r>r+)rargsr<r=r>kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr%rrr s^                    zPopen.__init__)NNN)r&r5r6r7r __classcell__rrrHrr}sr)r7sysplatform ImportErrorr itertoolsr@r subprocessr r9__all__BUFSIZErrCcountrrrrrrrrs$ 1,