
    iUF                        S SK r S SKJr  S SKJrJr  S SKJrJr  S SK	r	S SK
r
S SKrS SKJr  S SKJr  \R                   " \5      r\ R&                  S:X  Ga.  S SKrS SKrS SKr " S S	\R.                  5      rS
r\R4                  " \5      r\R8                  R:                  R<                  r\R4                  " \R>                  R@                  5      \R4                  " \R>                  R@                  5      \\R>                  RB                  /\l"        \R>                  RF                  \l$        \R8                  R:                  RJ                  r%\R>                  R@                  /\%l"        \R>                  RF                  \%l$        \" \&5      RO                  S5      r(S r)S r*\ R&                  S:X  a  S r+S r,OS r+S r,S\-S\-4S jr.S r/ " S S\05      r1 " S S5      r2S r3S r4g)    N)Path)loadsdumps)	b64encode	b64decode)compat)logntc                       \ rS rSrS\R
                  R                  4S\R
                  R                  4S\R
                  R                  4/r	Sr
g)SECURITY_ATTRIBUTES    nLengthlpSecurityDescriptorbInheritHandle N)__name__
__module____qualname____firstlineno__ctypeswintypesDWORDLPVOIDBOOL_fields___static_attributes__r       IC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller\isolated\_parent.pyr   r       s?    --.#V__%;%;<v334
r   r      z	_child.pyc                     [        X5      $ )a  
Create a one-way pipe for sending data to child processes.

Args:
    read_handle_inheritable:
        A boolean flag indicating whether the handle corresponding to the read end-point of the pipe should be
        marked as inheritable by subprocesses.
    write_handle_inheritable:
        A boolean flag indicating whether the handle corresponding to the write end-point of the pipe should be
        marked as inheritable by subprocesses.

Returns:
    A read/write pair of file descriptors (which are just integers) on posix or system file handles on Windows.

The pipe may be used either by this process or subprocesses of this process but not globally.
)_create_pipe_impl)read_handle_inheritablewrite_handle_inheritables     r   create_piper$   <   s    " 4OOr   c                     [        U 5      $ )zL
Close the file descriptor (posix) or handle (Windows) belonging to a pipe.
)_close_pipe_endpoint_impl)pipe_handles    r   close_pipe_endpointr(   P   s     %[11r   c                 `   [         R                  R                  5       n[         R                  R                  5       n[        5       n[         R                  " U5      Ul        SUl        S Ul        [        [         R                  " U5      [         R                  " U5      [         R                  " U5      S5      nU(       d  [         R                  " 5       e[        R                  " UR                  U 5        [        R                  " UR                  U5        UR                  UR                  4$ )NTr   )r   r   HANDLEr   sizeofr   r   r   
CreatePipebyrefWinErrorosset_handle_inheritablevalue)r"   r#   read_handlewrite_handlesecurity_attributes	succeededs         r   r!   r!   Y   s     oo,,.--/ 23&,mm4G&H#-1*370 LL%LL&LL,-	
	 //## 	!!+"3"35LM
!!,"4"46NO  ,"4"444r   c                 R    [        U 5      nU(       d  [        R                  " 5       eg N)CloseHandler   r.   )r'   r5   s     r   r&   r&   w   s!    ,	//## r   c                     [         R                  " 5       u  p#[         R                  " X 5        [         R                  " X15        X#4$ r7   )r/   pipeset_inheritable)read_fd_inheritablewrite_fd_inheritableread_fdwrite_fds       r   r!   r!   }   s7    GGI 	78
8:  r   c                 0    [         R                  " U 5        g r7   )r/   close)pipe_fds    r   r&   r&      s    
r   read_from_parentwrite_to_parentc                 0   [         R                  S:w  a  [        5       SS.nO#[        5       S[        R                  " SX/0S9S.n[
        R                  " [        [        5      [        U 5      [        U5      /U5      u  p4[        R                  " U40 UD6$ )zm
Spawn a Python subprocess sending it the two file descriptors it needs to talk back to this parent process.
r
   F)env	close_fdsThandle_list)lpAttributeList)rF   rG   startupinfo)
r/   name_subprocess_env
subprocessSTARTUPINFOr   __wrap_pythonstrCHILD_PYPopen)rC   rD   extra_kwargscmdoptionss        r   childrV      s     
ww$ #$
 #$%11=ScRuBvw
 ''X<L8MsSbOc(dfrsLC C+7++r   c                      SSK Jn   U S   nS[        R                  ;   a  U[        R                  S   /-   n[        R                  R	                  5       n[        R
                  R                  U5      US'   U$ )zE
Define the environment variables to be readable in a child process.
r   )CONFpathex
PYTHONPATH)PyInstaller.configrX   r/   environcopypathsepjoin)rX   python_pathrF   s      r   rL   rL      s^     (x.Krzz!!RZZ%=$>>
**//
C

4CJr   c                       \ rS rSrSrg)SubprocessDiedError   r   N)r   r   r   r   r   r   r   r   rb   rb      s    r   rb   c                   :    \ rS rSrSrS
S jrS rS rS rS r	S	r
g)Python   a  
Start and connect to a separate Python subprocess.

This is the lowest level of public API provided by this module. The advantage of using this class directly is
that it allows multiple functions to be evaluated in a single subprocess, making it faster than multiple calls to
:func:`call`.

The ``strict_mode`` argument controls behavior when the child process fails to shut down; if strict mode is enabled,
an error is raised, otherwise only warning is logged. If the value of ``strict_mode`` is ``None``, the value of
``PyInstaller.compat.strict_collect_mode`` is used (which in turn is controlled by the
``PYINSTALLER_STRICT_COLLECT_MODE`` environment variable.

Examples:
    To call some predefined functions ``x = foo()``, ``y = bar("numpy")`` and ``z = bazz(some_flag=True)`` all using
    the same isolated subprocess use::

        with isolated.Python() as child:
            x = child.call(foo)
            y = child.call(bar, "numpy")
            z = child.call(bazz, some_flag=True)

Nc                 r    S U l         Ub  UO[        R                  U l        [	        [
        SS5      U l        g )N_pyi_isolated_subprocessF)_childr   strict_collect_mode_strict_modegetattrsys_already_isolated)selfstrict_modes     r   __init__Python.__init__   s4     ,7+BKHbHb ").H%!Pr   c                 P   U R                   (       a  U $ [        SS5      u  p[        SS5      u  p4[        X25      U l        [	        U5        [	        U5        AA[
        R                  S:X  ac  [
        R                  " [        R                  " US5      S5      U l
        [
        R                  " [        R                  " US5      S5      U l        O8[
        R                  " US5      U l
        [
        R                  " US5      U l        U R                  [        R                  5        U $ )NFTr
   r   wbrb)rn   r$   rV   ri   r(   r/   rK   fdopenmsvcrtopen_osfhandle_write_handle_read_handle_sendrm   path)ro   read_from_childrD   rC   write_to_childs        r   	__enter__Python.__enter__   s    !!K ,7ud+C( ,7tU+C( ,> 	,-O, 77d?
 "$6+@+@QR+SUY!ZD "		&*?*?QR*SUY ZD!#>4!@D "		/4 @D

388r   c                 r   U R                   (       a  g U(       aU  [        U[        5      (       a@  U R                  R	                  5         U R
                  R	                  5         U ?U ?S U l        g U R                  R                  S5        U R                  R                  5         Sn U R                  R                  SS9  U R                  R	                  5         U R
                  R	                  5         U ?U ?S U l        U(       a  U R                  (       a  [!        S5      eg g ! [        R                   a~    [        R                  S5        SnU R                  R                  5          U R                  R                  SS9   N! [        R                   a    [        R                  S5          Nf = ff = f)	N   
F   )timeoutz6Timed out while waiting for the child process to exit!T   z;Timed out while waiting for the child process to be killed!)rn   
issubclassrb   ry   rA   rz   ri   writeflushwaitrM   TimeoutExpiredloggerwarningkillrk   RuntimeError)ro   exc_typeexc_valexc_tbshutdown_errors        r   __exit__Python.__exit__   sq   !!
8-@AA$$&##%!4#5DK  '  " 		^KKQ' 	  "!t1 d//WXX 0>% (( 	^NNST!NKK^   ,,, ^\]^	^s+   'D$ $AF6*F)F2.F61F22F6c                    U R                   (       a  U" U0 UD6$ U R                  c  [        S5      eU R                  UR                  UR
                  UR                  X#5         [        [        U R                  R                  5       5      5      u  pEU(       a  U$ [        SUR                   S	3U-   5      e! [        [        4 a<    [        SUR                   SU SU SU R                  R                  5        S3	5      Sef = f)
z
Call a function in the child Python. Retrieve its return value. Usage of this method is identical to that
of the :func:`call` function.
Nz:An isolated.Python object must be used in a 'with' clause.zChild process died calling z() with args=z and kwargs=z. Its exit code was .zChild process call to z() failed with:
)rn   ri   r   r{   __code____defaults____kwdefaults__r   r   rz   readlineEOFErrorBrokenPipeErrorrb   r   r   )ro   functionargskwargsokoutputs         r   callPython.call.  s    !!T,V,,;;[\\

8$$h&;&;X=T=TVZc	y):):)C)C)EFGJB M
 3H4E4E3FFWX[aabb /* 	%-h.?.?-@dV T !5dkk6F6F6H5IL 	s   %.B8 8ADc                     U HK  nU R                   R                  [        [        U5      5      5        U R                   R                  S5        MM     U R                   R	                  5         g )Nr   )ry   r   r   r   r   )ro   objectsobjects      r   r{   Python._sendP  sQ    F$$YuV}%=>$$U+ 
 	  "r   )rn   ri   rz   rk   ry   r7   )r   r   r   r   __doc__rq   r   r   r   r{   r   r   r   r   re   re      s&    ,Q$L-Y^ cD#r   re   c                 x    [        5        nUR                  " U /UQ70 UD6sSSS5        $ ! , (       d  f       g= f)a
  
Call a function with arguments in a separate child Python. Retrieve its return value.

Args:
    function:
        The function to send and invoke.
    *args:
    **kwargs:
        Positional and keyword arguments to send to the function. These must be simple builtin types - not custom
        classes.
Returns:
    The return value of the function. Again, these must be basic types serialisable by :func:`marshal.dumps`.
Raises:
    RuntimeError:
        Any exception which happens inside an isolated process is caught and reraised in the parent process.

To use, define a function which returns the information you're looking for. Any imports it requires must happen in
the body of the function. For example, to safely check the output of ``matplotlib.get_data_path()`` use::

    # Define a function to be ran in isolation.
    def get_matplotlib_data_path():
        import matplotlib
        return matplotlib.get_data_path()

    # Call it with isolated.call().
    get_matplotlib_data_path = isolated.call(matplotlib_data_path)

For single use functions taking no arguments like the above you can abuse the decorator syntax slightly to define
and execute a function in one go. ::

    >>> @isolated.call
    ... def matplotlib_data_dir():
    ...     import matplotlib
    ...     return matplotlib.get_data_path()
    >>> matplotlib_data_dir
    '/home/brenainn/.pyenv/versions/3.9.6/lib/python3.9/site-packages/matplotlib/mpl-data'

Functions may take positional and keyword arguments and return most generic Python data types. ::

    >>> def echo_parameters(*args, **kwargs):
    ...     return args, kwargs
    >>> isolated.call(echo_parameters, 1, 2, 3)
    (1, 2, 3), {}
    >>> isolated.call(echo_parameters, foo=["bar"])
    (), {'foo': ['bar']}

Notes:
    To make a function behave differently if it's isolated, check for the ``__isolated__`` global. ::

        if globals().get("__isolated__", False):
            # We're inside a child process.
            ...
        else:
            # This is the master process.
            ...

N)re   r   )r   r   r   isolateds       r   r   r   Y  s,    t 
X}}X777 
s   +
9c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )a  
Decorate a function so that it is always called in an isolated subprocess.

Examples:

    To use, write a function then prepend ``@isolated.decorate``. ::

        @isolated.decorate
        def add_1(x):
            '''Add 1 to ``x``, displaying the current process ID.'''
            import os
            print(f"Process {os.getpid()}: Adding 1 to {x}.")
            return x + 1

    The resultant ``add_1()`` function can now be called as you would a
    normal function and it'll automatically use a subprocess.

        >>> add_1(4)
        Process 4920: Adding 1 to 4.
        5
        >>> add_1(13.2)
        Process 4928: Adding 1 to 13.2.
        14.2

c                  "   > [        T/U Q70 UD6$ r7   )r   )r   r   r   s     r   wrappeddecorate.<locals>.wrapped  s    H.t.v..r   )	functoolswraps)r   r   s   ` r   decorater     s'    4 __X/ / Nr   )5r/   pathlibr   marshalr   r   base64r   r   r   rM   rm   PyInstallerr   r	   logging	getLoggerr   r   rK   rw   r   ctypes.wintypes	Structurer   HANDLE_FLAG_INHERITPOINTERLPSECURITY_ATTRIBUTESwindllkernel32r,   r   r*   r   argtypesr   restyper8   __file__	with_namerQ   r$   r(   r!   r&   intrV   rL   r   rb   re   r   r   r   r   r   <module>r      s   
    '   
  &			8	$ 77d?
f.. 
 !"NN+>?''22Jv--.v--.	J  --J --((44K"OO223K //..K>##K0P(2 77d?5<$	!,C ,# ,6
	, 	^# ^#B;8|r   