forked from agateau/yokadi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
w32_postinst.py
76 lines (61 loc) · 2.25 KB
/
w32_postinst.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Post installation script for win32 system
Thanks to the coin coin projet for the inspiration for this postinstall script
@author: Sébastien Renard ([email protected])
@license:GPL v3 or newer
"""
from os.path import abspath, join
from os import mkdir
import sys
# pylint: disable-msg=E0602
# Description string
desc="Command line oriented todo list system"
# Shortcut name
lnk="yokadi.lnk"
# Only do things at install stage, not uninstall
if sys.argv[1] == "-install":
# Get python.exe path
py_path = abspath(join(sys.prefix, "python.exe"))
# Yokadi wrapper path
yokadi_dir=abspath(join(sys.prefix, "scripts"))
yokadi_path=join(yokadi_dir, "yokadi")
#TODO: create a sexy yokadi .ico file to be put in share dir
# Find desktop
try:
desktop_path = get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY")
except OSError:
desktop_path = get_special_folder_path("CSIDL_DESKTOPDIRECTORY")
# Desktop shortcut creation
create_shortcut(py_path, # program to launch
desc,
join(desktop_path, lnk), # shortcut file
yokadi_path, # Argument (pythohn script)
yokadi_dir, # Current work dir
"" # Ico file (nothing for now)
)
# Tel install process that we create a file so it can removed it during uninstallation
file_created(join(desktop_path, lnk))
# Start menu shortcut creation
try:
start_path = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
except OSError:
start_path = get_special_folder_path("CSIDL_PROGRAMS")
# Menu folder creation
programs_path = join(start_path, "Yokadi")
try:
mkdir(programs_path)
except OSError:
pass
directory_created(programs_path)
create_shortcut(py_path, # program to launch
desc,
join(programs_path, lnk), # Shortcut file
yokadi_path, # Argument (python script)
yokadi_dir, # Cuurent work dir
"" # Icone
)
file_created(join(programs_path, lnk))
# End of script
sys.exit()