a
    ›­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 ¡ v 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 d¡} t j | ¡rB| d }t 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
        ÚHOMEú/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 |¡r@t  |¡ t  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.desktopNúln -s 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  |¡ t  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
        Nr   z/admin/launchers/birch.app .r   )r   r   r   r	   r
   )r   r   r   r   r   Úlink_apple_launcherA   s    
r   c                 C   sn   t j d¡t j d¡ }t  |d ¡ tt  ¡ ƒ | d }| d }d}t  d| d | ¡ t  d	| ¡ d
S )zY
        Creates a shortcut to the windows launcher script to run biolegato (birch)

    Z	HOMEDRIVEZHOMEPATHr   z/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 d¡}d|v s(d|v r^tj |d¡}t| |ƒ tj |ddd¡}t| |ƒ nJd	|v svd
|v svd|v rtj |d¡}t| |ƒ n|dkr¢t| ƒ nt	ƒ  t t
d ƒ d S )Nz
PLATFORM: r   ÚlinuxÚLinuxZDesktopz.localZshareZapplicationsZosxÚ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
   ZUSAGEr   r   r   r   r#   Ú__name__Úargvr!   r"   r   r   r   r   Ú<module>   s   