ó
äŒ^c           @   sß   d  d l  Z  d  d l Z  d  d l Z d  d l Z d „  Z e d „ Z e d „ Z e d k rÛ e	 e j
 ƒ d k  r‹ d GHd GHd	 GHe ƒ  n  e Z e  j j d
 ƒ rÄ e  j j d
 ƒ d k rÄ e Z n  e e j
 d e ƒ n  d S(   iÿÿÿÿNc          C   s"  t  j j d ƒ r' t  j j d ƒ }  n÷ t  j ƒ  d d k rF d }  nØ g  } t  j j d ƒ r t  j j d ƒ j t  j ƒ } n  xœ | D]” } x‹ d D]ƒ } t  j j | | ƒ } t  j j	 | ƒ rÜ t  j j
 | ƒ rÜ | }  Pq“ t  j j	 | d ƒ r“ t  j j
 | d ƒ r“ | d }  Pq“ q“ Wq† W|  S(   Nt
   BL_Browseri   t   Darwint   opent   PATHt   firefoxt	   seamonkeyt   mozillat   operat   netscapet   iexploret   explorers   .exe(   R   R   R   R   R   R	   R
   (   t   ost   environt   has_keyt   gett   unamet   splitt   pathsept   patht   joint   existst   isfile(   R    R   t   dirt   commandt	   full_path(    (    s(   /home/psgendb/BIRCHDEV/script/browser.pyt   detect_browser$   s"    
	!$,
c         C   s  t  ƒ  } |  j d ƒ s( |  j d ƒ rz |  j d ƒ rI |  j d ƒ }  n  d t j j t j j t j j |  ƒ ƒ ƒ }  n  d |  GH| rù | s¥ t	 j
 | |  g ƒ qþ d GHt	 j
 | d d g ƒ rØ t	 j
 | |  g ƒ qþ t	 j
 | d d |  d	 g ƒ n d
 GHd S(   s–  
    # browser.sh Version 10/ 2/09
    # Open a browser window to a specific URL
    #
    #
    # Synopsis: browser.py  URL
    #
    # URL must be fully qualified. For example, for a web site
    #     http://home.cc.umanitoba.ca/~frist
    #
    # For a file, the path does NOT need to begin with file:///


    @modified: Feb 17 2011
    @author: Graham Alvare
    @contact: alvare@cc.umanitoba.ca
    s   ://s   file://i   s   Opening document: s   abnormal execs   -remotes   ping()s	   "openurl(s   ,new-window)"t   failedN(   R   t   findt
   startswitht	   substringR   R   t   normpatht
   expandusert
   expandvarst
   subprocesst   call(   t   go_urlt   openurlt   browser_path(    (    s(   /home/psgendb/BIRCHDEV/script/browser.pyt   browserK   s    	1	
!c         C   s&   t  j ƒ  } | s" t |  | ƒ n  d  S(   N(   R   t   forkR&   (   R#   R$   t   pid(    (    s(   /home/psgendb/BIRCHDEV/script/browser.pyt   forkbrowser‹   s    t   __main__i   s   Missing URL parametert    s   Usage: browser.py  URLt   BROWSER_OPENURLi   (   R   t   os.pathR!   t   sysR   t   FalseR&   R)   t   __name__t   lent   argvt   exitR$   R   R   R   t   True(    (    (    s(   /home/psgendb/BIRCHDEV/script/browser.pyt   <module>   s    	'@

*	