1
2
3
4
5 """
6 Manage the interface with Inno Setup
7
8 G{importgraph}
9 """
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 import os
32 import sys
33 import shutil
34 import subprocess
35
36
37
38
39
40
41
43 """
44 Class which interface Pyxmaker and Inno Setup
45
46 G{classtree}
47 """
48
49
50
51
52
55
56
57
58
59
60
61
63 """
64 Allow to create the setup directory in the output repertory
65
66 PARAMETERS
67 ==========
68 dict_param
69 ----------
70 A dictionnary with all needed parameters
71
72 RETURNS
73 =======
74 None
75 """
76 os.mkdir(dict_param["SETUP_PATH"])
77
78
79
80
81
82
83
85 """
86 Allow to create the inno setup script adapted for the software
87
88 PARAMETERS
89 ==========
90 dict_param
91 ----------
92 A dictionnary with all needed parameters
93
94 RETURNS
95 =======
96 None
97 """
98 path = os.path.join(dict_param["SCRIPTS_PATH"], "script_innos.iss")
99 with open(path, 'r') as fichier:
100 script = fichier.read()
101 fichier.close()
102 script = script.replace("$$NAME$$", dict_param["NAME"])
103 script = script.replace("$$VERSION$$", dict_param["VERSION"])
104 script = script.replace("$$AUTHOR$$", dict_param["AUTHOR"])
105 script = script.replace("$$WEBSITE$$", dict_param["WEBSITE"])
106 script = script.replace("$$EXEC$$",dict_param["SETUP_EXEC_WITHOUT_PY"])
107 script = script.replace("$$UID$$",dict_param["SETUP_UID"])
108 script = script.replace("$$LICENCE$$",dict_param["SETUP_LICENCE"])
109 script = script.replace("$$BEFORE$$",dict_param["SETUP_BEFORE"])
110 script = script.replace("$$AFTER$$",dict_param["SETUP_AFTER"])
111 script = script.replace("$$SETUP_MENU$$",dict_param["SETUP_MENU"])
112 script = script.replace("$$OUTPUT_DIR$$",dict_param["SETUP_EXE_PATH"])
113 script = script.replace("$$SETUP_NAME$$",dict_param["SETUP_NAME"])
114
115 path_b = os.path.join(dict_param["PJ_PATH"],"build")
116 script = script.replace("$$PATH$$",path_b + os.listdir(path_b)[0])
117
118 if dict_param["SETUP_ICON"] <> "":
119 script = script.replace("$$SETUP_ICON$$",dict_param["SETUP_ICON"])
120 else:
121 script = script.replace("SetupIconFile=$$SETUP_ICON$$","")
122
123 if dict_param["SETUP_PASSWD"] <> "":
124 script = script.replace("$$SETUP_PASSWD$$",dict_param["SETUP_PASSWD"])
125 else:
126 script = script.replace("Password=$$SETUP_PASSWD$$","")
127
128 path = os.path.join(dict_param["SETUP_PATH"],"script.iss")
129 with open(path, "w") as fichier:
130 fichier.write(script)
131 fichier.close()
132
133
134
135
136
137
138
140 """
141 Allow to generate the install setup
142
143 PARAMETERS
144 ==========
145 dict_param
146 ----------
147 A dictionnary with all needed parameters
148
149 RETURNS
150 =======
151 None
152 """
153 path0 = r"%s"%(dict_param["SETUP_PATH"],)
154
155 listing = os.listdir(r"C:\Program Files")
156 for i in range(len(listing)):
157 if listing[i][0:4].lower() == "inno":
158 path1 = r"%s"%(os.path.join("\"C:\Program Files", listing[i]),)
159 cmd1 = path1 + "\iscc.exe\" " + path0 + "\\script.iss & exit\n"
160 stdout_file = open(os.path.join(dict_param["STRUCT_PATH"],"setup_log.log"), "w+")
161 proc = subprocess.Popen(cmd1, shell=True, stdout=stdout_file, stderr=subprocess.STDOUT)
162 proc.communicate()
163 stdout_file.seek(0)
164 stdout = stdout_file.read()
165
166 proc.wait()
167
168
169 with open(dict_param["STRUCT_PATH"] + "setup_log.log", "r") as log:
170 contenu = log.read()
171 if contenu.find("Successful compile"):
172 return True
173 else:
174 return False
175
176 log.close()
177
178
179
180
181
183 """
184 Allow to move the setup between 2 directories
185
186 PARAMETERS
187 ==========
188 dict_param
189 ----------
190 A dictionnary with all needed parameters
191
192 RETURNS
193 =======
194 None
195 """
196 shutil.copy(os.path.join(dict_param["SETUP_EXE_PATH"], dict_param["SETUP_NAME"] + ".exe"), \
197 os.path.join(dict_param["STRUCT_PATH"],dict_param["SETUP_NAME"] + ".exe"))
198
199
200
201
202
203
204
206 """
207 Allow to delete the temporary directories
208
209 PARAMETERS
210 ==========
211 dict_param
212 ----------
213 A dictionnary with all needed parameters
214
215 RETURNS
216 =======
217 None
218 """
219 shutil.rmtree(dict_param["SETUP_PATH"], True)
220
221
222
223
224
225
226
227 if __name__ == "__main__":
228 None
229