3
bdV                 @   sh   d Z ddlZddlZdZdZdd Zdd Zd	d
 Zdd Zdd Z	e
dkrddej krZn
e	ee dS )a  
Aug 26th 2010, Dale Hamel, University of Manitoba
 Description: Determines whether the system is OS X or linux, and
 creates a symbolic link to the appropriate launcher

 Note: this script is partnered with creatlauncher.py
 createlauncher.py makes the launchers at installtime, and
 linklauncher.py creates the links whenever newuser is run.

 Synopsis: python3 linklauncher.py


@modified: May 15, 2023
@author: Dale Hamel, Brian Fristensky
@contact: brian.fristensky@umanitoba.ca

    Nzlinklauncher.py: z
	USAGE: linklauncher.pyc              C   sF   t jjd} t jj| rB| d }t jj|r>ttd |  nd}|S )z
        DEPRECATED
        Returns the location of the current user's desktop directory
        by reading the environment variable "HOME", and assuming that there
        is a "HOME/Desktop" directory
        HOMEz/DesktopzFound desktop at: N)osenvirongetpathexistsprintPROGRAM)home_dirdesktop_dir r   -/home/psgendb/BIRCHDEV/script/linklauncher.pyget_desktop   s    r   c             C   sD   | d }| dkr@t jj|r@t j| t jd| d  td dS )aN  
        Creates a link to 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
        z/admin/launchers/birch.desktopNzln -s z .z)Made symbolic link to launcher on desktop)r   r   isdirchdirsystemr   )	birch_dirr   	file_namer   r   r   link_gnome_launcher/   s
    

r   c             C   s4   | dkr0t j| t jd|  d  ttd  dS )ac  
        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
        Nzln -s z/admin/launchers/birch.app .z)Made symbolic link to launcher on desktop)r   r   r   r   r	   )r   r   r   r   r   link_apple_launcherA   s    
r   c             C   sn   t jjdt jjd }t j|d  tt j  | d }| d }d}t jd| d |  t jd	|  d
S )zY
        Creates a shortcut to the windows launcher script to run biolegato (birch)

    Z	HOMEDRIVEZHOMEPATHz/Desktopz/java/bioLegato/biolegato.batz!/public_html/birch_black_ico.icnsz/cygwin.batzmkshortcut -n bioLegato -i  zmkshortcut -n birchTerm N)r   r   r   r   r   getcwdr   )r   ZwindirZ	biolegatoZ
birch_iconZ
cygwin_batr   r   r   link_win_launcher]   s    r   c             C   s   t d|  tjjd}d|ks(d|kr^tjj|d}t| | tjj|ddd}t| | nJd	|ksvd
|ksvd|krtjj|d}t| | n|dkrt|  nt	  t t
d  d S )Nz
PLATFORM: r   linuxLinuxZDesktopz.localZshareZapplicationsZosxZDarwinZmacoszwinxp-32zcompleted execution normally.)r   r   r   r   r   joinr   r   r   exitr	   )BIRCHPLATFORMr
   r   r   r   r   mainr   s    

r   __main__z-test)__doc__r   sysr	   USAGEr   r   r   r   r   __name__argvr   r   r   r   r   r   <module>   s   