1
2
3
4
5 """
6 Manage the interface with cx_freeze
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 whichinterface Pyxmaker and cx_freeze
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 src = dict_param["DIR_PJ"]
77 dst = dict_param["PJ_PATH"]
78 shutil.rmtree(dict_param["STRUCT_PATH"], True)
79 shutil.copytree(src, dst)
80
81
82
83
84
85
86
88 """
89 Allow to create the setup directory in the output repertory
90
91 PARAMETERS
92 ==========
93 dict_param
94 ----------
95 A dictionnary with all needed parameters
96
97 RETURNS
98 =======
99 None
100 """
101 path = os.path.join(dict_param["SCRIPTS_PATH"], "script_cxf.py")
102 with open(path, 'r') as fichier:
103 script = fichier.read()
104 fichier.close()
105
106 script = script.replace("$$INCLUDES$$", dict_param["CXF_INCLUDE"])
107 script = script.replace("$$EXCLUDES$$", dict_param["CXF_EXCLUDE"])
108 script = script.replace("$$PACKAGES$$", dict_param["CXF_PACKAGE"])
109 script = script.replace("$$INCLUDE_FILES$$", dict_param["CXF_INCLUDE_FILE"])
110 script = script.replace("$$NAME_EXEC$$",dict_param["EXECUTABLE"])
111 script = script.replace("$$NAME$$",dict_param["NAME"])
112 script = script.replace("$$VERSION$$",dict_param["VERSION"])
113 script = script.replace("$$DESCRIPTION$$",dict_param["DESCRIPTION"])
114 script = script.replace("$$AUTHOR$$",dict_param["AUTHOR"])
115 script = script.replace("$$AUTHOR_MAIL$$",dict_param["AUTHOR_MAIL"])
116 script = script.replace("$$MAINTAINER$$",dict_param["MAINTAINER"])
117 script = script.replace("$$MAINTAINER_MAIL$$",dict_param["MAINTAINER_MAIL"])
118 script = script.replace("$$WEBSITE$$",dict_param["WEBSITE"])
119 script = script.replace("$$WINCONS$$",dict_param["WINCONS"])
120
121 if dict_param["ICON_EXEC"] <> "":
122 script = script.replace("$$ICON_EXEC$$",dict_param["ICON_EXEC"])
123 else:
124 script = script.replace("\n icon = \"$$ICON_EXEC$$\",","")
125
126 if dict_param["ICON"] <> "":
127 script = script.replace("$$ICON$$",dict_param["ICON"])
128 else:
129 script = script.replace("\n icon = \"$$ICON$$\",","")
130
131 path = os.path.join(dict_param["PJ_PATH"], "script.py")
132 with open(path, "w") as fichier:
133 fichier.write(script)
134 fichier.close()
135
136
137
138
139
140
141
143 """
144 Allow to create the setup directory in the output repertory
145
146 PARAMETERS
147 ==========
148 dict_param
149 ----------
150 A dictionnary with all needed parameters
151
152 RETURNS
153 =======
154 None
155 """
156 cmd0 = dict_param["PJ_PATH"]
157 cmd0 = r"%s"%(cmd0,)
158 cmd1 = "python script.py build & exit\n"
159 stdout_file = open(os.path.join(dict_param["STRUCT_PATH"],"cxf_log.log"), "w+")
160 proc = subprocess.Popen(cmd1, shell=True, cwd=cmd0, stdout=stdout_file, stderr=subprocess.STDOUT)
161 proc.communicate()
162 stdout_file.seek(0)
163 stdout = stdout_file.read()
164
165 proc.wait()
166
167
168 with open(os.path.join(dict_param["STRUCT_PATH"],"cxf_log.log"), "r") as log:
169 contenu = log.read().lower()
170 if contenu.find("cannot") <> -1 or contenu.find("problem") <> -1 or \
171 contenu.find("error") <> -1:
172 return 2
173 elif contenu.count("warning") > 2:
174 return 2
175 else:
176 return 0
177
178 log.close()
179
180
181
182
183
185 """
186 Allow to generate the zip that contains the standalone version
187
188 PARAMETERS
189 ==========
190 dict_param
191 ----------
192 A dictionnary with all needed parameters
193
194 RETURNS
195 =======
196 None
197 """
198 path_dir = os.path.join(dict_param["PJ_PATH"],"build")
199 exe = os.listdir(path_dir)[0]
200 path_zip = os.path.join(dict_param["STRUCT_PATH"], dict_param["NAME"] + "_" + dict_param["VERSION"] + "_" + "standalone")
201 shutil.make_archive(path_zip, "zip", path_dir + exe)
202
203
204
205
206
207
208
210 """
211 Allow to create the setup directory in the output repertory
212
213 PARAMETERS
214 ==========
215 dict_param
216 ----------
217 A dictionnary with all needed parameters
218
219 RETURNS
220 =======
221 None
222 """
223 shutil.rmtree(dict_param["PJ_PATH"], True)
224
225
226
227
228
229
230
231 if __name__ == "__main__":
232 None
233