objdictedit_postinst.py
author etisserant
Mon, 18 Feb 2008 10:35:14 +0100
changeset 397 f9e720b220ea
parent 358 4630ccf4932a
permissions -rwxr-xr-x
Fixed problem with spaces in paths in generated canfetival_config.py
358
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     1
#!/usr/bin/env python
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     3
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     4
# La première ligne doit commencer par #! et contenir python.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     5
# Elle sera adaptée au système de destination automatiquement
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     6
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     7
""" This is a part of Beremiz project.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     8
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
     9
    Post installation script for win32 system
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    10
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    11
    This script creat a shortcut for objdictedit.py in the desktop and the
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    12
    start menu, and remove them at the uninstallation
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    13
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    14
"""
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    15
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    16
import os
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    17
import sys
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    18
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    19
# Ce script sera aussi lancé lors de la désinstallation.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    20
# Pour n'exécuter du code que lors de l'installation :
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    21
if sys.argv[1] == '-install':
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    22
    # On récupère le dossier où mes fichiers seront installés (dossier où python est aussi installé sous windows)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    23
    python_path = sys.prefix
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    24
    # On récupère le chemin de pythonw.exe (l'exécutable python qui n'affiche pas de console).
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    25
    # Si vous voulez une console, remplacez pythonw.exe par python.exe
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    26
    pyw_path = os.path.abspath(os.path.join(python_path, 'pythonw.exe'))
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    27
    # On récupère le dossier coincoin
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    28
    objdictedit_dir = os.path.abspath(os.path.join(python_path, 'LOLITech', 'CanFestival-3','objdictgen'))
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    29
    ############################################################################
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    30
    #objdictedit_dir = os.path.abspath(os.path.join(python_path, 'share', \
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    31
                                                    #'objdictedit'))
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    32
    ############################################################################
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    33
    # On récupère les chemins de coincoin.py, et de coincoin.ico
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    34
    # (Ben oui, l'icone est au format ico, oubliez le svg, ici on en est encore à la préhistoire.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    35
    # Heureusement que the GIMP sait faire la conversion !)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    36
    ico_path = os.path.join(objdictedit_dir, 'objdictedit.ico')
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    37
    script_path = os.path.join(objdictedit_dir, 'objdictedit.py')
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    38
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    39
    # Création des raccourcis
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    40
    # Pour chaque raccourci, on essaye de le faire pour tous les utilisateurs (Windows NT/2000/XP),
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    41
    # sinon on le fait pour l'utilisateur courant (Windows 95/98/ME)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    42
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    43
    # Raccourcis du bureau
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    44
    # On essaye de trouver un bureau
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    45
    try:
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    46
        desktop_path = get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    47
    except OSError:
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    48
        desktop_path = get_special_folder_path("CSIDL_DESKTOPDIRECTORY")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    49
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    50
    # On créé le raccourcis
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    51
    create_shortcut(pyw_path, # programme à lancer
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    52
                    "Can Node Editor", # Description
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    53
                    os.path.join(desktop_path, 'objdictedit.lnk'),  # fichier du raccourcis (gardez le .lnk)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    54
                    script_path, # Argument (script python)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    55
                    objdictedit_dir, # Dossier courant
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    56
                    ico_path # Fichier de l'icone
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    57
                    )
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    58
    # On va cafter au programme de désinstallation qu'on a fait un fichier, pour qu'il soit supprimé
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    59
    # lors de la désinstallation
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    60
    file_created(os.path.join(desktop_path, 'objdictedit.lnk'))
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    61
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    62
    # Raccourcis dans le menu démarrer (idem qu'avant)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    63
    try:
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    64
        start_path = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    65
    except OSError:
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    66
        start_path = get_special_folder_path("CSIDL_PROGRAMS")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    67
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    68
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    69
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    70
    # Création du dossier dans le menu programme
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    71
    programs_path = os.path.join(start_path, "LOLITech")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    72
    try :
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    73
        os.mkdir(programs_path)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    74
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    75
    except OSError:
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    76
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    77
        pass
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    78
    directory_created(programs_path)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    79
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    80
    create_shortcut(pyw_path, # Cible
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    81
                    "Can Node Editor", #Description
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    82
                    os.path.join(programs_path, 'objdictedit.lnk'),  # Fichier
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    83
                    script_path, # Argument
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    84
                    objdictedit_dir, # Dossier de travail
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    85
                    ico_path # Icone
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    86
                    )
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    87
    file_created(os.path.join(programs_path, 'objdictedit.lnk'))
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    88
    
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    89
    # End (youpi-message)
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    90
    # Ce message sera affiché (très) furtivement dans l'installateur.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    91
    # Vous pouvez vous en servir comme moyen de communication secret, c'est très in.
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    92
    sys.stdout.write("Shortcuts created.")
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    93
    # Fin du bidule
4630ccf4932a add setup.py and objdictedit_postinst.py to build windows installer
greg
parents:
diff changeset
    94
    sys.exit()