Module setup_pyxmaker
[hide private]
[frames] | no frames]

Source Code for Module setup_pyxmaker

  1  #!/usr/bin/env python 
  2  #-*- coding:utf-8 -* 
  3   
  4   
  5  """ 
  6          Manage the interface with Inno Setup 
  7           
  8          G{importgraph} 
  9  """ 
 10   
 11   
 12  #       Pyxmaker 
 13  #       Copyright (C) 2013 GALODE A. 
 14  # 
 15  #       This file is part of Expymaker. 
 16  #  
 17  #       Pyxmaker is free software: you can redistribute it and/or modify 
 18  #       it under the terms of the GNU General Public License as published by 
 19  #       the Free Software Foundation, either version 3 of the License, or 
 20  #       (at your option) any later version. 
 21  #  
 22  #       Pyxmaker is distributed in the hope that it will be useful, 
 23  #       but WITHOUT ANY WARRANTY; without even the implied warranty of 
 24  #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 25  #       GNU General Public License for more details. 
 26  # 
 27  #       You should have received a copy of the GNU General Public License 
 28  #       along with Pyxmaker.  If not, see <http://www.gnu.org/licenses/> 
 29   
 30   
 31  import os 
 32  import sys 
 33  import shutil 
 34  import subprocess 
 35   
 36   
 37   
 38   
 39  #=======================================================================# 
 40  #                               classe gérant la connexion avec Inno Setup                             # 
 41  #=======================================================================# 
42 -class SetupPyxmaker():
43 """ 44 Class which interface Pyxmaker and Inno Setup 45 46 G{classtree} 47 """ 48 49 50 #===================================================# 51 # Init # 52 #===================================================#
53 - def __init__(self):
54 None
55 56 57 58 59 #===================================================# 60 # Creation de la structure de dossiers # 61 #===================================================#
62 - def p_struct_creation(self, dict_param):
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 # Creation du script # 83 #===================================================#
84 - def p_script_creation(self, dict_param):
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 # Creation de l'install # 138 #===================================================#
139 - def f_setup_creation(self, dict_param):
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 #cwd indique le chemin ou s'execute la commande 166 proc.wait() 167 #on attend la fin de l'execution de la commande 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 # Deplacement de l'install genere # 181 #===================================================#
182 - def p_setup_move(self, dict_param):
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 # Effacement des dossiers temporaires # 204 #===================================================#
205 - def p_struct_del(self, dict_param):
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 # Main de la classe # 226 #=======================================================================# 227 if __name__ == "__main__": 228 None 229