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