##// END OF EJS Templates
falta expulsion bandejas...
ralonso -
r61:62
parent child
Show More
@@ -1,397 +1,402
1 1 # -*- coding: utf-8 -*-
2 2
3 3 """
4 4 Module implementing MainWindow.
5 5 """
6 6
7 7 from PyQt4.QtGui import QMainWindow
8 8 from PyQt4.QtCore import pyqtSignature
9 9 from PyQt4 import QtCore
10 10 from Ui_MainWindow import Ui_MainWindow
11 11 from PyQt4 import QtGui
12 12 from subprocess import *
13 13 import sys
14 14 import os
15 15 #import subprocess
16 16 import commands
17 17 from functions import functions
18 18 from functions import functions2
19 19
20 20 class MainWindow(QMainWindow, Ui_MainWindow):
21 21 """
22 22 Class documentation goes here.
23 23 """
24 24
25 25 def __init__(self, parent = None):
26 26 QMainWindow.__init__(self, parent)
27 27 self.setupUi(self)
28 28 self.setupUi2()
29 29 #sys.stdout = self #redirige salida estandar
30 30
31 31 def setupUi2(self):
32 32
33 functions2.detect_devices(self) #busca los dispositivos de grabacion
33 # functions2.detect_devices(self) #busca los dispositivos de grabacion
34 34
35 35 self.var_Discs = 0 #Numero de discos del proyecto
36 36 self.var_Copys = 0 #Numero de copias
37 37 self.var_disc_n = 0
38 38 self.var_copy_n = 0
39 39
40 40 self.var_list=[]
41 41 self.var_sublist=[]
42 42
43 43 self.var_devices=[]
44 44
45 45 self.var_step = 0
46 46 self.bool_state_burning = False
47 47
48 48
49 49 #Revisa si existe el archivo de confirguracion
50 50 if os.path.isfile("parameters.conf"):
51 51 self.txtInfo.append("Archivo de configuracion encontrado")
52 52 functions2.get_parameters_conf(self)
53 53 self.txtInfo.append("El proyecto es de "+str(self.var_Discs)+" discos")
54 54 else:
55 55 self.txtInfo.append("Elija los parametros de configuracion")
56 56 functions2.set_parameters_test(self) #Establece ciertos parametros, para pruebas
57 57
58 58 functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados
59 59
60 60 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
61 61 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
62 62 functions.load_days(self)
63 63
64 64 if os.path.isfile("parameters.conf"):
65 65 functions2.enabled_items1(True, self) #Se bloquean los parametros de configuracion
66 66
67 67
68 68 self.var_process = QtCore.QProcess()
69 69 self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput)
70 70 self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardError()'), self.readError)
71 71 self.connect(self.var_process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished)
72 72
73 73
74 74 def write(self, txt):
75 75 self.txtInfo.append(str(txt))
76 76
77 77
78 78 #----------------------------------------------------- Funciones del proceso ---------------------------------------------------------------
79 79
80 80 def readOuput(self):
81 81 self.txtSburn.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput()))
82 82
83 83 def readError(self):
84 84 self.txtSburn.insertPlainText("stderr: " + QtCore.QString(self.var_process.readAllStandardError()))
85 85
86 86 def finished(self):
87 self.txtInfo.append("proceso terminado finished() "+QtCore.QString(self.var_process.exitCode()))
87 self.txtInfo.append("proceso terminado finished() "+QtCore.QString(self.var_process.exitCode())+"\n")
88 88 if self.var_disc_n <= self.var_Discs and self.bool_state_burning:
89 89 self.burning()
90 90
91 91
92 92 #----------------------------------------------------- Obtencion de la ruta de los datos ---------------------------------------------------------------
93 93
94 94 @pyqtSignature("")
95 95 def on_btnDpath_clicked(self):
96 96 """
97 97 Permite seleccionar graficamente el direcorio de los datos a grabar
98 98 """
99 99 self.var_Dpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
100 100 self.txtDpath.setText(self.var_Dpath)
101 101 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
102 102 functions.load_days(self)
103 103
104 104
105 105 @pyqtSignature("")
106 106 def on_txtDpath_editingFinished(self):
107 107 """
108 108 Carga la ruta editada y verifica que sea correcta y carga la lista de dias
109 109 """
110 110 self.var_Dpath=str(self.txtDpath.text()) #Se carga la variable con la ruta recien editada
111 111 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
112 112 functions.load_days(self)
113 113
114 114
115 115 #----------------------------------------------------- Obtencion de las ruta del proyecto ---------------------------------------------------------------
116 116
117 117 @pyqtSignature("")
118 118 def on_btnRpath_clicked(self):
119 119 """
120 120 Permite seleccionar graficamente el direcorio del proyecto
121 121 """
122 122 self.var_Rpath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
123 123 self.txtRpath.setText(self.var_Rpath)
124 124 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
125 125
126 126
127 127 @pyqtSignature("")
128 128 def on_txtRpath_editingFinished(self):
129 129 """
130 130 Valida la ruta del proyecto
131 131 """
132 132 self.var_Rpath = str(self.txtRpath.text()) #Se carga la variable con la ruta recien editada
133 133 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
134 134
135 135
136 136 #----------------------------------------------------- Tipo de datos ---------------------------------------------------------------
137 137
138 138 @pyqtSignature("int")
139 139 def on_lstDtype_activated(self, index):
140 140 """
141 141 Permite elegir entre los tipos de archivos
142 142 """
143 143 self.txtDtype.setReadOnly(True)
144 144 if index == 0:
145 145 self.var_Dtype ='r'
146 146 elif index == 1:
147 147 self.var_Dtype ='pdata'
148 148 elif index == 2:
149 149 self.var_Dtype ='sswma'
150 150 else :
151 151 self.var_Dtype =''
152 152 self.txtDtype.setReadOnly(False)
153 153
154 154 self.txtDtype.setText(self.var_Dtype)
155 155 functions.load_days(self) #llamada a funcion
156 156
157 157 @pyqtSignature("")
158 158 def on_txtDtype_editingFinished(self):
159 159 self.var_Dtype=str(self.txtDtype.text())
160 160 functions.load_days(self) #llamada a funcion
161 161
162 162
163 163 #----------------------------------------------------- Etiqueta ---------------------------------------------------------------
164 164
165 165 @pyqtSignature("")
166 166 def on_txtElabel_editingFinished(self):
167 167 self.var_Elabel = str(self.txtElabel.text())
168 168
169 169 #----------------------------------------------------- Numero de copias ---------------------------------------------------------------
170 170 @pyqtSignature("")
171 171 def on_txtCopys_editingFinished(self):
172 172 self.var_Copys = self.txtCopys.value()
173 173
174 174 #----------------------------------------------------- Seleccion del rango de fechas ---------------------------------------------------------------
175 175
176 176 @pyqtSignature("int") #CLOSED
177 177 def on_lstStartDay_activated(self, index):
178 178 """
179 179 Cambia la lista de opciones en lstStopDay
180 180 """
181 181 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
182 182 self.lstStopDay.clear()
183 183
184 184 for i in self.var_list[index:]:
185 185 self.lstStopDay.addItem(i)
186 186
187 187 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
188 188
189 189 functions.get_sub_list(self)
190 190
191 191
192 192 @pyqtSignature("int") #CLOSED
193 193 def on_lstStopDay_activated(self, index):
194 194 """
195 195 Cambia la lista de opciones en lstStartDay
196 196 """
197 197 var_StartDay_index=self.lstStartDay.currentIndex()
198 198 var_end_index = self.lstStopDay.count() - index
199 199 self.lstStartDay.clear()
200 200
201 201 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
202 202 self.lstStartDay.addItem(i)
203 203
204 204 self.lstStartDay.setCurrentIndex(var_StartDay_index)
205 205
206 206 functions.get_sub_list(self)
207 207
208 208
209 209 #----------------------------------------------------- Capacidad del dispositivo de grabacion ---------------------------------------------------------------
210 210
211 211 @pyqtSignature("")
212 212 def on_txtDcapacity_editingFinished(self):
213 213 self.var_Dcapacity = self.txtDcapacity.value()
214 214
215 215
216 216 @pyqtSignature("int") #CLOSED
217 217 def on_lstDcapacity_activated(self, index):
218 218 """
219 219 Permite elegir el tamaΓ±o del disco
220 220 """
221 221 if index == 0:
222 222 var_size=25.0
223 223 elif index == 1:
224 224 var_size=8.5
225 225 elif index == 2:
226 226 var_size=4.7
227 227 elif index == 3:
228 228 var_size=0.7
229 229
230 230 if index != 4:
231 231 self.txtDcapacity.setValue(var_size*10**9/1024**2)
232 232 self.txtDcapacity.setReadOnly(True)
233 233 else:
234 234 self.txtDcapacity.setValue(100.0)
235 235 self.txtDcapacity.setReadOnly(False)
236 236
237 237 self.var_lstDcapacity = self.lstDcapacity.currentIndex()
238 238 self.var_Dcapacity = self.txtDcapacity.value()
239 239
240 240
241 241 #==============================================================================
242 242 # Botones para la generacion de los archivos de configuracion y el proceso de grabacion
243 243 #==============================================================================
244 244
245 245 #----------------------------------------------------- Generacion de la configuracion usando los parametros ---------------------------------------------------------------
246 246
247 247 @pyqtSignature("")
248 248 def on_btnGbkp_clicked(self):
249 249 """
250 250 Generacion de archivos de configuracion usando los parametros
251 251 """
252 252
253 253 if functions.validate_parameters(self) == False:
254 254 return
255 255
256 256 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
257 257 list_dirs=['gpath','iso','ppath']
258 258 bool_make_dirs = functions.make_dirs(list_dirs, self)
259 259 if bool_make_dirs == False:
260 260 return
261 261
262 262 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
263 263 self.var_Discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
264 264 functions.make_files_print(self) # Se crean los archivos .print
265 265 functions2.make_parameters_conf(self) # se crea el archivo parameters.conf
266 266
267 267 #Se bloquean los parametros de configuracion
268 268 functions2.enabled_items1(True, self)
269 269
270 270
271 271
272 272 #----------------------------------------------------- Permite reiniciar la configuracion ---------------------------------------------------------------
273 273
274 274 @pyqtSignature("")
275 275 def on_btnRestart_clicked(self):
276 276 """
277 277 Permite que se puedan cambiar los parametros
278 278 """
279 279 functions2.enabled_items1(False, self)
280 280 os.remove("parameters.conf")
281 281
282 282
283 283 #----------------------------------------------------- Iniciar proceso de grabacion ---------------------------------------------------------------
284 284
285 285 @pyqtSignature("")
286 286 def on_btnStartburn_clicked(self):
287 287 """
288 288 Se inicia el proceso de grabacion
289 289 """
290 290
291 291 #Verifica que exista algun dispositivo de grabacion seleccionado
292 292 if not(functions2.selected_devices(self)):
293 293 self.txtInfo.append("No hay ningun dispositivo de grabacion seleccionado ")
294 294 return
295 295
296 296 #Lista los dispositivos de grabacion a usar
297 297 for dev in self.var_devices:
298 298 self.txtInfo.append("dispositivo :"+dev)
299 299
300 300 #Asigna las variables con los valores iniciales
301 301 self.var_disc_n = 0 # numero de disco actual para grabacion
302 302 self.var_copy_n = 0
303 303 self.var_step = 0
304 304 self.bool_state_burning = True
305 305
306 306 functions2.enabled_items2(True, self)
307 307 self.burning()
308 308
309 309 def burning(self):
310 310
311 311 var_Rpath_ppath=self.var_Rpath+"/ppath"
312 312 var_Rpath_iso=self.var_Rpath+"/iso"
313 file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso"
314 313
315 314 #Creacion del archivo.iso para la grabacion
316 315 if self.var_step == 0:
317 316
318 317 self.var_disc_n += 1 # numero de disco actual para grabacion
318 self.var_copy_n = 0
319 319
320 320 #Si ya se grabaron todos los discos
321 321 if self.var_disc_n > self.var_Discs:
322 322 self.bool_state_burning = False
323 323 self.txtInfo.append("GRABACION TERMINADA")
324 324 return
325 325
326 self.txtInfo.append("Creando el iso del disco numero: "+str(self.var_disc_n))
326 self.txtInfo.append("########## DISCO NUMERO: "+str(self.var_disc_n)+"##########")
327 self.txtInfo.append("--------Creando el iso del disco numero: "+str(self.var_disc_n))
327 328
328 329 #comando para la creacion del archivo.iso
329 330 file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(self.var_disc_n)+".dat"
331 file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso"
330 332 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
331 333 var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
332 334 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
333 335 self.var_step = 1 #Se ira al paso de la grabacion en la siguiente llamada
334 336
335 337 #Grabacion de los DVDs
336 338 elif self.var_step == 1:
337 339 self.var_copy_n += 1 # numero de copia actual
338 340 self.txtInfo.append("Grabando la copia numero: "+str(self.var_copy_n))
339 341
340 342 #Si esta es la ultima copia se pasara al siguiente disco en la siguiente llamada a la funcion
341 343 if self.var_copy_n == self.var_Copys:
342 344 self.var_step = 0
343 345
344 var_index = (((self.var_disc_n - 1) * self.var_Discs) + self.var_copy_n) % len(self.var_devices)
346 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) ) % len(self.var_devices)
345 347
346 348 if var_index == 0:
347 349 self.txtInfo.append("EXPULSANDO BANDEJAS")
348 350
349 var_dev_tmp=self.var_devices[var_index]
351 var_dev_tmp = self.var_devices[var_index]
352 file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso"
350 353 var_cmd = "wodim -v dev="+var_dev_tmp+" speed=16 "+ file_iso
351 354
352 355
353 356 self.var_process.start('ls')
354 357 self.txtInfo.append(var_cmd)
355 358
356 359 # self.txtInfo.append("creando iso")
357 360 # self.var_process.start(var_cmd)
358 361
359 362
360 363 #----------------------------------------------------- Detener proceso de grabacion ---------------------------------------------------------------
361 364
362 365 @pyqtSignature("")
363 366 def on_btnStopburn_clicked(self):
364 367 """
365 368 Slot documentation goes here.
366 369 """
367 370 self.bool_state_burning = False
368 371 self.var_process.terminate() #Termina el proceso, si puede
369 # self.var_process.kill() #Mata el proceso, no es la forma adecuada
372 # self.var_process.kill() #Mata el proceso, no es la forma adecuada, solo usar si terminate() no funciona
373
374 self.txtInfo.append("SE DETUVO LA GRABACION MANUALMENTE")
370 375 functions2.enabled_items2(False, self)
371 376
372 377
373 378 #----------------------------------------------------- Testeo de las unidades de grabacion ---------------------------------------------------------------
374 379
375 380 @pyqtSignature("")
376 381 def on_btnTdevA_clicked(self):
377 382 var_dev = str(self.txtDeviceA.text())
378 383 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
379 384 commands.getstatusoutput(var_cmd)
380 385
381 386 @pyqtSignature("")
382 387 def on_btnTdevB_clicked(self):
383 388 var_dev = str(self.txtDeviceB.text())
384 389 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
385 390 commands.getstatusoutput(var_cmd)
386 391
387 392 @pyqtSignature("")
388 393 def on_btnTdevC_clicked(self):
389 394 var_dev = str(self.txtDeviceC.text())
390 395 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
391 396 commands.getstatusoutput(var_cmd)
392 397
393 398 @pyqtSignature("")
394 399 def on_btnTdevD_clicked(self):
395 400 var_dev = str(self.txtDeviceD.text())
396 401 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
397 402 commands.getstatusoutput(var_cmd)
General Comments 0
You need to be logged in to leave comments. Login now