
    vKg                        S SK Jr  S SKrS SKrS SKrS SKrS SKr S SKrSSK	J
r
Jr  SSKJr  \R                  S:X  a  SS jrSS jrSS	 jrSS
 jrSS jr\S:X  a  \" 5         gg! \ a     NNf = f)    )annotationsN   )ClientConnectionconnect)versionwin32c                 :   SSK n U R                  S5      nU R                  S5      nSnU R                  R                  R	                  U5      nXB:X  a  [        S5      eU R                  5       nU R                  R                  R                  X@R                  U5      5      S:X  a  [        S5      e[        R                  U[        R                  5      nU R                  Xc-  5      nU R                  R                  R                  XG5      S:X  a  [        S5      eg)	zi
Enable VT-100 for console output on Windows.

See also https://github.com/python/cpython/issues/73245.

r   Ni   zunable to obtain stdout handlez$unable to query current console modezunable to set console mode)ctypesc_uintwindllkernel32GetStdHandleRuntimeErrorGetConsoleModebyrefint
from_bytessys	byteorderSetConsoleMode)r   STD_OUTPUT_HANDLEINVALID_HANDLE_VALUE"ENABLE_VIRTUAL_TERMINAL_PROCESSINGhandlecur_modepy_int_modenew_modes           S/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/__main__.pywin_enable_vt100r!      s     	"MM#.%}}R0-2*''445FG)?@@==?==!!00h9OPTUUEFF nnXs}}===!QR==!!00BaG;<< H    c                    [         R                  R                  SU  S35        [         R                  R                  5         g )Nz	7
[A[Lz
8[Br   stdoutwriteflushstrings    r    print_during_inputr*   3   s<    JJ	 ( 	  JJr"   c                    [         R                  R                  SU  S35        [         R                  R                  5         g )Nz[K
r$   r(   s    r    print_over_inputr-   G   s9    JJ	 (-		! JJr"   c                   U  HD  n[        U[        5      (       a  [        SU-   5        M(  [        SUR                  5       -   5        MF     UR	                  5       (       d`  [
        R                  S:X  a  [        R                  nO[        R                  n[        R                  " [        R                  " 5       U5        g g )Nz< z< (binary) r   )
isinstancestrr*   hexis_setr   platformsignalCTRL_C_EVENTSIGINToskillgetpid)	websocketstopmessagectrl_cs       r    print_incoming_messagesr>   S   s    gs##tg~.}w{{}<=	 
 ;;== <<7"((F]]F
		V$ r"   c                 v   [         R                  " SSSS9n U R                  5       nUR                  SSS9  UR                  SS	S
S9  U R	                  5       nUR
                  (       a  [        S[         35        g UR                  c  U R                  S5        [        R                  S:X  a   [        5          [#        UR                  5      n[        SUR                   S35        [(        R*                  " 5       n[(        R,                  " [.        WU4S9nUR1                  5           [3        S5      nUR5                  U5        M  ! [         aK  n[        R                  R                  SU S35        [        R                  R!                  5          S nANS nAff = f! [$         a<  n[        SUR                   SU S35        [        R&                  " S5         S nANS nAff = f! [6        [8        4 a.    UR;                  5         UR=                  5         [?        S5         Of = fURA                  5         g )Nzpython -m websocketszInteractive WebSocket client.F)progdescriptionadd_helpz	--version
store_true)actionuriz<uri>?)metavarnargszwebsockets z+the following arguments are required: <uri>r   zUnable to set terminal to VT100 mode. This is only supported since Win10 anniversary update. Expect weird symbols on the terminal.
Error: r,   zConnected to .zFailed to connect to z: r   )targetargsz> zConnection closed.)!argparseArgumentParseradd_mutually_exclusive_groupadd_argument
parse_argsr   printwebsockets_versionrE   errorr   r3   r!   r   stderrr&   r'   r   	Exceptionexit	threadingEventThreadr>   startinputsendKeyboardInterruptEOFErrorsetcloser-   join)parsergrouprK   excr:   r;   threadr<   s           r    mainrf   c   s   $$#3F
 //1E	{<8	ugS9D||./01xxBC ||w	+DHH%	
 	dhhZq)*??D %<ItCTUF
LLN/DkGNN7# 1  	JJ::=bB
 JJ	  %dhhZr#a89$ x( /
-./
 KKMsC   /
E :F  )G) 
FAFF 
G&*2G!!G&);H'&H'__main__)returnNone)r)   r0   rh   ri   )r:   r   r;   zthreading.Eventrh   ri   )
__future__r   rL   r7   r4   r   rW   readlineImportErrorsync.clientr   r   r   rR   r3   r!   r*   r-   r>   rf   __name__ r"   r    <module>rp      sx    "  	  
 	 3 2 <<7=<(	% 8v zF e  		s   A& &A/.A/