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