
    i=              	       6   S r SSKrSSKrSSKJr  SSKJrJr  SSK	J
r
  SSKJr  \R                  \4rS\4S jrSS	\\\\S4   S
\\   S\\   4S jjrS	\S
\S\4S jrSS
\S	\\   S\4S jjr  SS
\\\4   S	\\   S\\   S\4S jjrS\\
   S\\   4S jrg)zUtility functions.    N)Iterable)OptionalUnion)AnyKey)Keysreturnc                     Sn  [         R                   " [         R                  [         R                  5      n U R                  S5         U R                  5       S   n U R                  5         U$ ! [         a    U (       a  U R                  5          [         R                   " [         R                  [         R                  5      n U R                  S5         N! [         a#    U (       a  U R                  5         [        S5      ef = ff = f! [         a  n[        SU S35      eSnAff = f! U R                  5         f = f)ziDetermines a free port using sockets.

First try IPv4, but use IPv6 if it can't bind (IPv6-only system).
N)	127.0.0.1r   )z::1r   z5Can't find free port (Unable to bind to IPv4 or IPv6)   zCan't find free port: ())
socketAF_INETSOCK_STREAMbindOSErrorcloseAF_INET6RuntimeErrorgetsockname	Exception)free_socketportes      LC:\des-py\RoboSAPF\venv\Lib\site-packages\selenium\webdriver\common\utils.py	free_portr      s   
 KXmmFNNF4F4FG)*++-a0 	K#  
X	X --9K9KLKZ( 	X!!#VWW	X
X  ;4QCq9::; 	sC   AA/ 	D /!DAC-DD
D)D$$D))D, ,D>hostr   c                     [         R                  " U S5      nSnU H  u  n    pVSnU(       a  [        U[	        US   5      5      nU(       a$  U[         R
                  :X  a  [	        US   5      s  $ U(       d  M]  U(       a  Mf  U[         R                  :X  d  M|  [	        US   5      nM     U$ ! [         R                   a     gf = f)a7  Resolve a hostname to an IP, preferring IPv4 addresses.

We prefer IPv4 so that we don't change behavior from previous IPv4-only
implementations, and because some drivers (e.g., FirefoxDriver) do not
support IPv6 connections.

If the optional port number is provided, only IPs that listen on the given
port are considered.

Args:
    host: hostname
    port: port number

Returns:
    A single IP address, as a string. If any IPv4 address is found, one is
    returned. Otherwise, if any IPv6 address is found, one is returned. If
    neither, then None is returned.
NTr   )r   getaddrinfogaierroris_connectablestrr   r   )r   r   	addrinfosipfamily_sockaddrconnectables           r   find_connectable_ipr(   =   s    &&&tT2	 
B%.!1a(s8A;/?@K6V^^3x{##;rrf&?Xa[!B &/ I ?? s   B- -CCc                 X    SU ;   a  U R                  S5      (       d  SU  SU 3$ U  SU 3$ )zJoins a hostname and port together.

This is a minimal implementation intended to cope with IPv6 literals. For
example, _join_host_port('::1', 80) == '[::1]:80'.

Args:
    host: hostname or IP
    port: port number
:[z]:)
startswith)r   r   s     r   join_host_portr-   b   s=     d{4??3//4&4&!!V1TF    c                    Sn [         R                  " X4S5      nSnU(       a0   UR                  [         R                  5        UR                  5         U$ ! [         a    Sn NGf = f! [
         a     N0f = f! U(       aB   UR                  [         R                  5        O! [
         a     Of = fUR                  5         f f = f)zvTries to connect to the server at port to see if it is running.

Args:
    port: port number
    host: hostname or IP
Nr   TF)r   create_connection_is_connectable_exceptionsshutdown	SHUT_RDWRr   r   )r   r   socket_results       r   r    r    q   s     G**D<;   !1!12 MMOM &      !1!12 MMO sX   A A) A&#A9 %A&&A9 )
A65A69CB"!C"
B/,C.B//Cschemec                      [         R                  R                  U SU SU  S35       nUR                  5       S:H  sSSS5        $ ! , (       d  f       g= f! [         a     gf = f)zSends a request to the HTTP server at the /status endpoint to see if it
responds successfully.

Args:
    port: port number
    host: hostname or IP
    scheme: URL scheme
z://r*   z/status   NF)urllibrequesturlopengetcoder   )r   r   r6   ress       r   is_url_connectabler>      sZ    ^^##vhc$qg$FG3;;=C' HGG s-   (A A	A 
AA A 
A%$A%valuec                    / nU  H|  n[        U[        5      (       a  UR                  [        U5      5        M4  [        U[        [
        45      (       a  UR                  [        U5      5        Mk  UR                  U5        M~     U$ )z7Processes the values that will be typed in the element.)
isinstancer   appendr!   intfloatextend)r?   
charactersvals      r   keys_to_typingrH      si    Jc4  c#h'c5\**c#h'c"  r.   )N)	localhost)r
   http)__doc__r   urllib.requestr9   collections.abcr   typingr   r   selenium.typesr   selenium.webdriver.common.keysr   errorConnectionResetErrorr1   rC   r   r!   bytes	bytearrayr(   r-   boolr    r>   listrH    r.   r   <module>rX      s  $    $ " ! /$ll,@A 3 <"eC	4$?@ "QT "aijman "J C C  HSM D 2 &"
S/
3- SM 
	((6* tCy r.   