2 # -*- coding: utf-8 -*-
4 # La première ligne doit commencer par #! et contenir python.
5 # Elle sera adaptée au système de destination automatiquement
7 """ This is a part of Beremiz project.
9 Post installation script for win32 system
11 This script creat a shortcut for objdictedit.py in the desktop and the
12 start menu, and remove them at the uninstallation
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', \
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')
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)
43 # Raccourcis du bureau
44 # On essaye de trouver un bureau
46 desktop_path = get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY")
48 desktop_path = get_special_folder_path("CSIDL_DESKTOPDIRECTORY")
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
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'))
62 # Raccourcis dans le menu démarrer (idem qu'avant)
64 start_path = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
66 start_path = get_special_folder_path("CSIDL_PROGRAMS")
70 # Création du dossier dans le menu programme
71 programs_path = os.path.join(start_path, "LOLITech")
73 os.mkdir(programs_path)
78 directory_created(programs_path)
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
87 file_created(os.path.join(programs_path, 'objdictedit.lnk'))
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.")