
    g                         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 d dlmZ  ej        e          Z G d d          ZdS )    N)Path)List)Optional)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     v/var/www/html/nodeJS/PythonScripts/venv3.11/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          }||                     |          } 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env_pathallowedarchlocations          r   r   zSeleniumManager._get_binary9   s    X-667IJJ&u--?)55c::M#	"3444HALLMxXXX>>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<t||~~<$%`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: NrC   rD   z; code: )joinr   r.   r0   r1   
subprocessrunCREATE_NO_WINDOWstdoutdecoderstripstderrr   loads	Exceptionr   r   _process_logs
returncode)r	   commandcompleted_procrI   rL   outputerrrD   s           r   r   zSeleniumManager._runi   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   r3   r.   )rU   items     r   rO   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   rO    r   r   r   r   !   s         
 $    $ - - - - \-^ 49     \8 .d . . . \. . .r   r   )r   r   r,   r1   rF   r0   r)   pathlibr   typingr   r   selenium.commonr   	getLoggerr\   r   r   rb   r   r   <module>rg      s   "   				      



                       . . . . . .		8	$	$k. k. k. k. k. k. k. k. k. k.r   