ó
²,]c           @   s7  y d  d l  Z  Wn n Xd  d l Z d  d l Z d  d l j Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 y d  d l  Z  Wn n Xy e j
 d d e j Wn n Xd  d l m Z d  d l m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z d	   Z d
   Z e d k r3e   n  d S(   i’’’’Ns
   libGL.so.1t   mode(   t   get_options(   t   get_conf_patht   running_in_mac_appt   running_under_pytest(   t   CONF(   t   lockfile(   t
   is_unicodec         C   sŁ   t  j d d  } xĄ t d  D]² } y x} |  D]u } t j t j t j t j  } | j d | f  t |  r | j	 d  } n  | j
 t j |   | j   q/ WWn$ t j k
 rĻ t j d  q n XPq Wd S(   s  
    Simple socket client used to send the args passed to the Spyder 
    executable to an already running instance.

    Args can be Python scripts or files with these extensions: .spydata, .mat,
    .npy, or .h5, which can be imported by the Variable Explorer.
    t   maint   open_files_portiČ   s	   127.0.0.1s   utf-8g      Š?N(   R   t   gett   ranget   sockett   AF_INETt   SOCK_STREAMt   IPPROTO_TCPt   connectR   t   encodet   sendt   ospt   abspatht   closet   errort   timet   sleep(   t   argst   portt   _xt   argt   client(    (    s/   lib/python2.7/site-packages/spyder/app/start.pyt   send_args_to_spyder(   s    c          C   sŚ  t    re y d d l m }  Wn! t k
 r@ d d l m }  n X|    } t | _ t | _ d } n t	   \ } } t
 t j d  t j d <t j d d  rt
 t j d d   } t t d | j d    } t |  d k rü | d	 t j d
 <q&| t j d <n d t j d
 <d t j d <t j d k rŃt j j d  } t j j d  } t |  r{t |  r{| } n, t |  rt |  r| } n
 d } } | t j d <| t j d <d t j d <na y d d l m } |   WnC t k
 r1y d t j d <d t j d <Wq2t k
 r-q2Xn Xt j d d  r©| j r©| j r©t   r©t j t j d d d  d  t  d  } t! j" |  }	 y |	 j#   }
 WnØ yf t j$ d k rłt% j& |  rd d l' } | j( | d t) qn t% j* |  rt j+ |  n  Wn n Xd d l, m- } t    rF| j.   S| j.   d Sn X|
 rd d l, m- } t    r| j.   S| j.   qÖ| r”t/ |  qÖd GHn- d d l, m- } t    rĢ| j.   S| j.   d S(    sŻ   
    Start Spyder application.

    If single instance mode is turned on (default behavior) and an instance of
    Spyder is already running, this will just parse and send command line
    options to the application.
    i’’’’(   t   Mocki   t   SPYDER_ARGSR   t   high_dpi_custom_scale_factort   high_dpi_custom_scale_factorst   ;i    t   QT_SCALE_FACTORt   QT_SCREEN_SCALE_FACTORSt    t   darwint   LANGt   LC_ALLs   en_US.UTF-8t   1t   EVENT_NOKQUEUE(   t	   getlocalet   Ct   single_instanceič  iŠ  iZ   g     Ć@s   spyder.lockt   ntNt   ignore_errors(   t
   mainwindowsk   Spyder is already running. If you want to open a new 
instance, please pass to it the --new-instance option(0   R   t   unittest.mockR   t   ImportErrort   mockt   Falset   new_instancet   reset_config_filest   NoneR   t   strt   syst   argvt   ost   environR   R
   t   listt   filtert   splitt   lent   platformt   boolt   localeR,   t
   ValueErrort	   ExceptionR   R   R   t   randomt	   randrangeR   R   t   FilesystemLockt   lockt   nameR   t   isdirt   shutilt   rmtreet   Truet   islinkt   unlinkt
   spyder.appR1   R   R   (   R   t   optionsR   t   factorst   fR(   R)   R,   t	   lock_fileRJ   t   lock_createdRM   R1   (    (    s/   lib/python2.7/site-packages/spyder/app/start.pyR   D   s    								
 	

	
	
t   __main__(   t   zmqt   ctypesR<   t   os.patht   pathR   RG   R   R:   R   t   CDLLt   RTLD_GLOBALt   spyder.app.cli_optionsR   t   spyder.config.baseR   R   R   t   spyder.config.mainR   t   spyder.utils.externalR   t   spyder.py3compatR   R   R   t   __name__(    (    (    s/   lib/python2.7/site-packages/spyder/app/start.pyt   <module>   s6   		