B
     h
                 @   s2   d dl Z d dlZd dlmZ G dd dejZdS )    N)servicec               @   s>   e Zd ZdZdddZdd Zdd	 Zed
d Zdd Z	dS )ServicezR
    Object that manages the starting and stopping of PhantomJS / Ghostdriver
    r   Nc             C   s   || _ | j dkrg | _ n|dd | _ |s.d}| ds\t \| _| _| j d| j  nd| _tjj	| ||t
|dd dS )a<  
        Creates a new instance of the Service

        :Args:
         - executable_path : Path to PhantomJS binary
         - port : Port the service is running on
         - service_args : A List of other command line options to pass to PhantomJS
         - log_path: Path for PhantomJS service to log to
        Nzghostdriver.logz--cookies-file=w)portlog_file)service_args_args_containtempfilemkstemp_cookie_temp_file_handle_cookie_temp_fileappendr   r   __init__open)selfexecutable_pathr   r   log_path r   aC:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\selenium\webdriver\phantomjs\service.pyr      s    


zService.__init__c                s    t tt fdd| jdkS )Nc                s
   |   S )N)
startswith)x)argr   r   <lambda>5       z'Service._args_contain.<locals>.<lambda>r   )lenlistfilterr   )r   r   r   )r   r   r   4   s    zService._args_containc             C   s   | j d| j g S )Nz--webdriver=%d)r   r   )r   r   r   r   command_line_args7   s    zService.command_line_argsc             C   s
   d| j  S )z9
        Gets the url of the GhostDriver Service
        zhttp://localhost:%d/wd/hub)r   )r   r   r   r   service_url:   s    zService.service_urlc             C   s"   | j rt| j t| j  d S )N)r   oscloser   remove)r   r   r   r   send_remote_shutdown_commandA   s    z$Service.send_remote_shutdown_command)r   NN)
__name__
__module____qualname____doc__r   r   r   propertyr   r"   r   r   r   r   r      s   
r   )r   r	   Zselenium.webdriver.commonr   r   r   r   r   r   <module>   s   