zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
U
W±dk!ã
@szdZddlZddlZddlZdddddgZz ddlZWnek
rNdZYnXzddlm    Z    Wnek
rxdZ    YnXd    d
„Z
d Z d Z d a dae ejej¡add„Zz eejdƒZejd=eƒWndeefk
rþZze
ddedW5dZ[XYn2ek
r.Zze
ddedW5dZ[XYnXdd„Zed!dd„ƒZdd„Zeedœdd„ƒZdd„Z ej!dd „ƒZ"dS)"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
'_PYIBoot_SPLASH'. 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_wrappercOs&tr"t t¡}|j||f|ž|ŽdS)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Úlogger©rúZd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/fake-modules/pyi_splash.pyÚ_log9s
róó FTc
CsZz$t dtf¡dadatddƒWn0tk
rT}ztdtƒ|‚W5d}~XYnXdS)z.
    Initialize this module
 
    :return:
    Ú    localhostFTéz?A connection to the splash screen was successfully established.z5Unable to connect to the tcp server socket on port %dN)Ú _ipc_socketÚconnectÚ    _ipc_portÚ_ipc_socket_closedÚ _initializedrÚOSErrorÚConnectionError)ÚerrrrrÚ _initializeOsr!Z_PYIBoot_SPLASHézŠThe environment does not allow connecting to the splash screen. Are the splash resources attached to the bootloader or did an error occur?)Úexc_infoé(z3Cannot connect to the bootloaders ipc server socketcs‡fdd„}trt|ˆƒ|S)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.
    cs,trtrtddƒdSts"tdƒ‚ˆ||ŽS)a
        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.
        rzUThe module has been disabled, so the use of the splash screen is no longer supported.Nz4This module is not initialized; did it fail to load?)rrrÚ RuntimeError)rr©ÚfuncrrÚwrapperysÿz"_check_connection.<locals>.wrapperr)r'r(rr&rÚ_check_connectionss 
r)c
Csl|dkr g}d|d |¡f}zt | d¡t¡Wn0tk
rf}ztd|ƒ|‚W5d}~XYnXdS)a
    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
    Nz%s(%s)ú zutf-8z%Unable to send '%s' to the bootloader)ÚjoinrÚsendallÚencoderrr)ÚcmdrZfull_cmdr rrrÚ _send_command’sr/cCs
tot S)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.
    )rrrrrrr¤s©rcCstd|gƒdS)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.
    rN)r/r0rrrr®s    cCs"trtst t¡t ¡dadS)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)rrrr,rrrrrrrºs
cCs
tƒdS)N)rrrrrÚ_exitÈsr1)N)#Ú__doc__ÚatexitÚosÚ_socketÚ__all__Úloggingr    Ú ImportErrorÚ    functoolsrrrrrrÚsocketÚAF_INETÚ SOCK_STREAMrr!ÚintÚenvironrÚKeyErrorÚ
ValueErrorZ_errrr)r/rÚstrrrÚregisterr1rrrrÚ<module>sP 
 
 
ý