Ñò
˜7¶Qc           @   s  d  Z  d d k Z d d k Z d d k Z e i i d ƒ Z e i i e ƒ d d k	 l
 Z
 d Z d Z e
 e e ƒ Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z e d j oV e i ƒ  p d e i j o qe i i d ƒ Z e i i d ƒ Z e e e ƒ n d S(   sÒ  
Aug 26th 2010, Dale Hamel, University of Manitoba
 Description: Determines whether the system is OS X or linux, and creates
 the appropriate launcher on the user's desktop.

 Synopsis: python createlauncher.py
 Notes: To create the apple launcher appropriately, there MUST be a template
 application "biolegato.app" in the current working directory in a folder
 called "osx_launcher"

@modified: May 14, 2011
@author: Dale Hamel
@contact: umhameld@cc.umanitoba.ca

iÿÿÿÿNt   BIRCHLIB(   t   Birchmods   createlauncher.py: s   
	USAGE: createlauncher.pyc         C   sW   d |  d } |  d } |  d j o. t i i | ƒ o t | | ƒ t d GHn d S(   sE  
        Creates a launcher of the form biolegato.desktop for use on
        linux desktops such as GNOME (v2+) and KDE (v3.5+). May also work
        on other desktops such as qt, etc, but not yet tested

        @desktop_dir: the location of the user's desktop directory,
        where the launcher will be placed

        s$   [Desktop Entry]
Name=Biolegato
Icon=sj   /public_html/birch_black_ico.icns
Type=Application
Exec=bash -lc birch
StartupNotify=true
Terminal=false

s   /admin/launchers/birch.desktops   Created freedesktop launcherN(   t   Nonet   ost   patht   lexistst   write_launchert   PROGRAM(   t	   birch_dirt   launcher_strt	   file_name(    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyt   make_gnome_launcher!   s
    
!c         C   sÅ   t  i ƒ  } | } t  i i |  d ƒ p˜ t  i |  d ƒ t  i ƒ  } t d | GHt  i d |  d ƒ t  i |  d ƒ t  i ƒ  } t d | GHt  i d |  d ƒ t d	 GHt  i d
 ƒ n d S(   sk  
        Makes a launcher application for OS X (tested on 10.5.8) of the format
        biolegato.app. The launcher is just a wrapper for an apple script
        that calls the system biolegato, and should use system paths.

        The this method copies a template launcher called "biolegato.app"
        to the desktop that is assumed to be in the current working directory
        in adirectory called "osx_launcher", if this changes then this method
        will need to be updated.

        Once the launcher is copied, all the contents of the BIRCH directory
        specified by the environment variable $BIRCH will be symbolically
        linked into the applications resource directory under:
        
        ~/biolegato.app/Contents/Resources"

        @desktop_dir: the location of the user's desktop directory,
        where the launcher will be placed
        s   /admin/launchers/biolegato.apps   /script/osx_launchers   Changed directory to: s   cp -r -p -f biolegato.app s   /admin/launcherss1   /admin/launchers/biolegato.app/Contents/Resourcess   ln -s s   /* .s   Made symbolic links:
s   ls -l | grep lrwxr-xr-x N(   R   t   getcwdR   R   t   chdirR   t   system(   R   t   base_dirt   curr_dir(    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyt   make_apple_launcher6   s    	c         C   sÃ   d d  k  } d d  k } d d k l } | i ƒ  } | i i | d ƒ } | i i |  d d ƒ } |  } | i i |  d d ƒ } | d ƒ }	 |	 i | ƒ }
 | |
 _ | |
 _	 | |
 _
 |
 i ƒ  d  S(	   Niÿÿÿÿ(   t   Dispatchs	   BIRCH.lnkt   scripts	   birch.batt   public_htmls   smallbirch.gifs   WScript.Shell(   R   t   winshellt   win32com.clientR   t   desktopR   t   joint   CreateShortCutt
   Targetpatht   WorkingDirectoryt   IconLocationt   save(   t   BIRCHR   R   R   R   R   t   targett   wDirt   icont   shellt   shortcut(    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyt   make_win_launchera   s    			c         C   sM   t  d |  GHt |  d ƒ } | i | ƒ | i t  d GHt i |  d ƒ d S(   s  
        Writes the contents of launcher_str to a file specified by
        file_name, and makes that file executable

        @file_name: the fully qualified name (including path) of the file to write.
        @launcher_str: the contents to write to the file

        s   Writing contents to file: t   ws)   Setting file permissions to executable...iÿ  N(   R   t   opent   writet   closeR   t   chmod(   R
   R	   t   out_file(    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyR   s   s    	c         C   s…   | d j o$ | i  d ƒ d j  o t |  ƒ nG | d j o t |  ƒ n, | d j o t |  ƒ n t d GHt ƒ  t d GHd  S(   Ns
   osx-x86_64t   wini    s   winxp-32s0   Platform not detected or not supported, exittings   Completed execution normally.(   t   findR   R   R$   R   t   exit(   R   t   PLATFORM(    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyt   mainŠ   s    $	t   __main__s   -testt   BIRCH_PLATFORMR   (   t   __doc__R   t   os.patht   syst   environt   gett   blibR   t   appendt   birchlibR   R   t   USAGEt   BMR   R   R$   R   R/   t   __name__t
   documentort   argvR.   R   (    (    (    s8   /home/psgendb/BIRCHDEV/install-scripts/createlauncher.pyt   <module>   s&   		+			