
    i
                        S r SSKrSSKrSSKr/ SQr SSKr SSKJ	r	  S r
SrSrSqS	q\R                  " \R                   \R"                  5      rS
 r \" \R*                  S   5      r\R*                  S	 \" 5         S r\SS j5       rS r\S\4S j5       rS r\R@                  S 5       r!g! \ a    Sr Nf = f! \ a    Sr	 Nf = f! \\4 a    \
" SSS	S9   N`\ a    \
" SSS	S9   Nof = f)a>  
This module connects to the bootloader to send messages to the splash screen.

It is intended to act as a RPC interface for the functions provided by the bootloader, such as displaying text or
closing. This makes the users python program independent of how the communication with the bootloader is implemented,
since a consistent API is provided.

To connect to the bootloader, it connects to a local tcp socket whose port is passed through the environment variable
'_PYI_SPLASH_IPC'. The bootloader creates a server socket and accepts every connection request. Since the os-module,
which is needed to request the environment variable, is not available at boot time, the module does not establish the
connection until initialization.

The protocol by which the Python interpreter communicates with the bootloader is implemented in this module.

This module does not support reloads while the splash screen is displayed, i.e. it cannot be reloaded (such as by
importlib.reload), because the splash screen closes automatically when the connection to this instance of the module
is lost.
    N)CLOSE_CONNECTIONFLUSH_CHARACTERis_alivecloseupdate_textupdate_wrapperc                 |    [         (       a1  [         R                  " [        5      nUR                  " X/UQ70 UD6  gg)z
Conditional wrapper around logging module. If the user excluded logging from the imports or it was not imported,
this function should handle it and avoid using the logger.
N)_logging	getLogger__name__log)levelmsgargskwargsloggers        PC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller/fake-modules/pyi_splash.py_logr   9   s4    
 x##H-

5///           FTc                      [         S:X  a  Sqg [        R                  S[         45        SqSq[        SS5        g! [         a  n [        S[          S	35      U eSn A ff = f)
z"
Initialize this module

:return:
r   TNz	127.0.0.1F
   zAIPC connection to the splash screen was successfully established.zCould not connect to TCP port .)	_ipc_port_initialized_ipc_socketconnect_ipc_socket_closedr   OSErrorConnectionError)errs    r   _initializer$   O   sl     A~V[)45"RTU V >ykKLRUUVs   +; 
AAA_PYI_SPLASH_IPC   zeThe environment does not allow connecting to the splash screen. Did bootloader fail to initialize it?)exc_info(   z1Failed to connect to the bootloader's IPC server!c                 B   ^  U 4S jn[         (       a  [        UT 5        U$ )z
Utility decorator for checking whether the function should be executed.

The wrapped function may raise a ConnectionError if the module was not initialized correctly.
c                     > [         (       a"  [        (       a  [        S:w  a  [        SS5        g[         (       d  [	        S5      eT" U 0 UD6$ )z
Executes the wrapped function if the environment allows it.

That is, if the connection to to bootloader has not been closed and the module is initialized.

:raises RuntimeError: if the module was not initialized correctly.
r   r   z4Connection to splash screen has already been closed.Nz4This module is not initialized; did it fail to load?)r   r    r   r   RuntimeError)r   r   funcs     r   wrapper"_check_connection.<locals>.wrapper   sF     <..A~ROPUVVT$V$$r   r   )r,   r-   s   ` r   _check_connectionr/   }   s    %" ~w%Nr   c                     Uc  / nU < SSR                  U5      < S3n [        R                  UR                  S5      [        -   5        g! [
         a  n[        SU< S35      UeSnAff = f)z
Send the command followed by args to the splash screen.

:param str cmd: The command to send. All command have to be defined as procedures in the tcl splash screen script.
:param list[str] args: All arguments to send to the receiving function
N( )zutf-8zUnable to send command z to the bootloader)joinr   sendallencoder   r!   r"   )cmdr   full_cmdr#   s       r   _send_commandr9      sm     |/HaHOOG4FG a 7|CUVW]``as   +A 
A,A''A,c                  2    [         =(       a    [        (       + $ )z
Indicates whether the module can be used.

Returns False if the module is either not initialized or was disabled by closing the splash screen. Otherwise,
the module should be usable.
)r   r     r   r   r   r      s     2 222r   r   c                     [        SU /5        g)z
Updates the text on the splash screen window.

:param str msg: the text to be displayed
:raises ConnectionError: If the OS fails to write to the socket.
:raises RuntimeError: If the module is not initialized.
r   N)r9   )r   s    r   r   r      s     -#'r   c                      [         (       a<  [        (       d0  [        R                  [        5        [        R                  5         Sqggg)a  
Close the connection to the ipc tcp server socket.

This will close the splash screen and renders this module unusable. After this function is called, no connection
can be opened to the splash screen again and all functions in this module become unusable.
TN)r   r    r   r5   r   r   r;   r   r   r   r      s7     |..,-! /|r   c                      [        5         g N)r   r;   r   r   _exitr@      s    	Gr   r?   )"__doc__atexitos_socket__all__loggingr   ImportError	functoolsr	   r   r   r   r   r    socketAF_INETSOCK_STREAMr   r$   intenvironr   KeyError
ValueErrorr"   r/   r9   r   strr   r   registerr@   r;   r   r   <module>rR      s]  &  	
 
U(0    nnW__g.A.ABV8QBJJ012I


$% M< a a"3 (S ( ("  I  H  Nz 	* 
o
  Q@4PQs:   B0 B> )C 0B;:B;>C	C	C.C.-C.