
     fz                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ  ej        e          Z G d d          ZdS )    N)Path)List)WebDriverExceptionc                       e Zd ZdZdedefdZedefd            Z	edee
         defd            Zedee         fd            Zd	S )
SeleniumManagerzWrapper for getting information from the Selenium Manager binaries.

    This implementation is still in beta, and may change.
    argsreturnc                    t          |                                           g|z   }t                                          t          j        k    r|                    d           |                    d           |                    d           |                    d           |                    d           |                     |          S )zDetermines the locations of the requested assets.

        :Args:
         - args: the commands to send to the selenium manager binary.
        :Returns: dictionary of assets and their path
        z--debugz--language-bindingpythonz--outputjson)str_get_binaryloggergetEffectiveLevelloggingDEBUGappend_run)selfr   s     m/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.pybinary_pathszSeleniumManager.binary_paths&   s     D$$&&''(4/##%%66KK	"""()))HJFyy    c                     t          t                    j                            d          } t	          j        d          }||                     |          } t          j        d          x}+t          
                    d|           t          |          }n|                                 r| }nddddddd	}t          j        d
v rt          j                    nd}t          j        dv r%t                              dt          j                   |                    t          j        |f          }|t#          dt          j         d|           t          t                    j                            |          }|                                st#          d|           t          
                    d|           |S )zDetermines the path of the correct Selenium Manager binary.

        :Returns: The Selenium Manager executable location

        :Raises: WebDriverException if the platform is unsupported
        zselenium-managerEXENSE_MANAGER_PATHz2Selenium Manager set by env SE_MANAGER_PATH to: %szmacos/selenium-managerzwindows/selenium-manager.exezlinux/selenium-manager))darwinany)win32r   )cygwinr   )linuxx86_64)freebsdr!   )openbsdr!   )r    r"   r#   r   )r"   r#   zFSelenium Manager binary may not be compatible with %s; verify settingsz/Unsupported platform/architecture combination: /z2Unable to obtain working Selenium Manager binary; z$Selenium Manager binary found at: %s)r   __file__parentjoinpath	sysconfigget_config_varwith_suffixosgetenvr   debugexistssysplatformmachinewarninggetr   is_file)compiled_pathexepathallowedarchlocations         r   r   zSeleniumManager._get_binary8   s    X-667IJJ&u--?)55c::MI/000D=LLMtTTT::DD!!## 	< DD $<"@#A%='?'? G *-9X)X)X8#%%%^cD|555giliuvvv{{CL$#788H()p[^[g)p)pjn)p)pqqq>>(11(;;D||~~ 	b$%`Z^%`%`aaa;TBBBr   c           
         d                     |           }t                              d|           	 t          j        dk    r"t          j        | dt
          j                  }nt          j        | d          }|j        	                    d          
                    d          }|j        	                    d          
                    d          }|d	k    rt          j        |          ng i d
}n%# t          $ r}t          d|           |d}~ww xY wt                               |d                    |d         }|j        r t          d| d|j         d| d|           |S )zExecutes the Selenium Manager Binary.

        :Args:
         - args: the components of the command being executed.
        :Returns: The log string containing the driver location.
         zExecuting process: %sr   T)capture_outputcreationflags)r=   zutf-8
 )logsresultzUnsuccessful command executed: NrA   rB   z; code: )joinr   r-   r/   r0   
subprocessrunCREATE_NO_WINDOWstdoutdecoderstripstderrr   loads	Exceptionr   r   _process_logs
returncode)r   commandcompleted_procrG   rJ   outputerrrB   s           r   r   zSeleniumManager._runf   s    ((4..,g666		[|w&&!+TYcYt!u!u!u!+T!J!J!J#*11'::AA$GGF#*11'::AA$GGF+1R<<TZ'''bTV=W=WFF 	[ 	[ 	[$%Pw%P%PQQWZZ	[ 	%%fVn555!$ 	$r'rr>C\rr`frrjprr   s   CC4 4
D>DD	log_itemsc                     | D ]Y}|d         dk    r!t                               |d                    /|d         dv r t                               |d                    Zd S )NlevelWARNmessage)r   INFO)r   r2   r-   )rS   items     r   rM   zSeleniumManager._process_logs   sj     	. 	.DG}&&tI////g"333T)_---		. 	.r   N)__name__
__module____qualname____doc__r   dictr   staticmethodr   r   r   r   rM    r   r   r   r       s         
 $    $ + + + + \+Z 49     \8 .d . . . \. . .r   r   )r   r   r+   r0   rD   r/   r(   pathlibr   typingr   selenium.commonr   	getLoggerrZ   r   r   r`   r   r   <module>re      s   "   				      



                 . . . . . .		8	$	$i. i. i. i. i. i. i. i. i. i.r   