
    vKg                         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rS SKJr  S SK	J
r
  S SK	Jr  S SKJr  \R                  " \5      r " S S5      rg)    N)Path)List)Optional)WebDriverExceptionc                       \ rS rSrSrS\S\4S jr\S\	4S j5       r
\S\\   S\4S j5       r\S\\   4S	 j5       rS
rg)SeleniumManager!   z{Wrapper for getting information from the Selenium Manager binaries.

This implementation is still in beta, and may change.
argsreturnc                 T   [        U R                  5       5      /U-   n[        R                  5       [        R
                  :X  a  UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        U R                  U5      $ )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     j/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/selenium/webdriver/common/selenium_manager.pybinary_pathsSeleniumManager.binary_paths'   s     D$$&'(4/##%6KK	"()HJFyy    c                  z   [        [        5      R                  R                  S5      n [        R
                  " S5      nUb  U R                  U5      n Sn[        R                  " S5      =nb"  [        R                  SU5        [        U5      nOU R                  5       (       a  U nOSSSSSSS	.n[        R                  S
;   a  [        R                  " 5       OSn[        R                  S;   a$  [        R                  S[        R                  5        UR!                  [        R                  U45      nUc  [#        S[        R                   SU 35      e[        [        5      R                  R                  U5      nUb  UR%                  5       (       d  [#        SU 35      e[        R                  SU5        U$ )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env_pathallowedarchlocations          r   r   SeleniumManager._get_binary9   sz    X--667IJ&&u-?)55c:M#		"344HALLMxX>D!!## D $<"@#A%='?'?G *-9X)X8##%^cD||55giliuiuv{{CLL$#78H(+Z[^[g[gZhhijnio)pqq>((11(;D<t||~~$'YZ^Y_%`aa;TBr   c           
         SR                  U 5      n[        R                  SU5         [        R                  S:X  a%  [
        R                  " U S[
        R                  S9nO[
        R                  " U SS9nUR                  R                  S5      R                  S5      nUR                  R                  S5      R                  S5      nUS	:w  a  [        R                  " U5      O/ 0 S
.n[         R#                  US   5        US   nUR$                  (       a!  [        SU SUR$                   SU SU 35      eU$ ! [         a  n[        SU 35      UeSnAff = f)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)rB   zutf-8
 )logsresultzUnsuccessful command executed: NrF   rG   z; code: )joinr   r0   r2   r3   
subprocessrunCREATE_NO_WINDOWstdoutdecoderstripstderrr   loads	Exceptionr   r   _process_logs
returncode)r
   commandcompleted_procrL   rO   outputerrrG   s           r   r   SeleniumManager._runi   sG    ((4.,g6		[||w&!+TYcYtYt!u!+T!J#**11':AA$GF#**11':AA$GF+1R<TZZ'bTV=WF 	%%fVn5!$$$1'(>C\C\B]]_`f_ggijpiqr    	[$'Fwi%PQWZZ	[s   CD= =
EEE	log_itemsc                     U  HI  nUS   S:X  a  [         R                  US   5        M&  US   S;   d  M1  [         R                  US   5        MK     g )NlevelWARNmessage)r   INFO)r   r5   r0   )rY   items     r   rR   SeleniumManager._process_logs   sE    DG}&tI/g"33T)_-	 r    N)__name__
__module____qualname____firstlineno____doc__r   dictr   staticmethodr   r   r   r   rR   __static_attributes__ra   r   r   r   r   !   s{    
 $ $ - - -^ 49   8 .d . .r   r   )r   r   r.   r3   rI   r2   r+   pathlibr   typingr   r   selenium.commonr   	getLoggerrb   r   r   ra   r   r   <module>rn      sD   "   	   
     .			8	$k. k.r   