##// END OF EJS Templates
***
ralonso -
r87:88
parent child
Show More
@@ -1,361 +1,361
1 1 # -*- coding: utf-8 -*-
2 2
3 3 #class BKmanager:
4 4 # def __init__(self):
5 5
6 6 from subprocess import *
7 7 import sys
8 8 import os
9 9 import subprocess
10 10 import commands
11 11 import shutil
12 12 import functions2
13 13
14 14 #--------------------------------------------- Entero a cadena agregando ceros delante -------------------------------------------------
15 15
16 16 def i2s(var_n, var_length=4):
17 17 var_n2=str(var_n)
18 18 while len(var_n2) < var_length:
19 19 var_n2 = "0"+var_n2
20 20 return var_n2
21 21
22 22
23 23 #----------------------------------------- Se verifica que la ruta exista y sea un directorio -------------------------------------------------
24 24
25 25 def dir_exists(var_dir, self):
26 26 if os.path.isdir(var_dir):
27 27 return True
28 28 else:
29 29 self.txtInfo.append("Incorrect path:" + str(var_dir))
30 30 return False
31 31
32 32
33 33 #-------------------------------- Se buscan los archivos del tipo especificado y se cargan las fechas -----------------------------
34 34
35 35 def load_days(self):
36 36
37 37 self.var_list=[]
38 38 self.lstStartDay.clear()
39 39 self.lstStopDay.clear()
40 40
41 41 if self.statusDpath == False:
42 42 self.btnGbkp.setEnabled(False)
43 43 return
44 44
45 45 if self.var_Dtype == '':
46 46 return
47 47
48 48 var_cmd="find " + str(self.var_Dpath) + " -name *."+ str(self.var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
49 49 output=commands.getstatusoutput(var_cmd)[1]
50 50
51 51 #Si no se encuentra ningun archivo
52 52 if len(output) == 0:
53 53 self.txtInfo.append("File not found")
54 54 self.btnGbkp.setEnabled(False)
55 55 return
56 56
57 57 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
58 58 for i in range(0, (len(output)+1)/8):
59 59 self.var_list.append(output[8*i:8*(i+1)-1])
60 60
61 61 for i in self.var_list:
62 62 self.lstStartDay.addItem(i)
63 63 self.lstStopDay.addItem(i)
64 64 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
65 65
66 66 get_sub_list(self)
67 67 self.btnGbkp.setEnabled(True)
68 68
69 69
70 70 #-------------------------------------------------- Obtiene el rango de las fechas seleccionadas -----------------------------------------
71 71
72 72 def get_sub_list(self):
73 73 self.var_sublist=[]
74 74 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
75 75 self.var_sublist.append(i)
76 76
77 77
78 78 #----------------------------------------------------- Verifica los parametros faltantes -----------------------------------------------------------
79 79
80 80 def validate_parameters(self):
81 81 #Verifica que las ruta del proyecto sea valida
82 82 if self.statusRpath == False:
83 83 self.txtInfo.append("Incorrect proyect path")
84 84 return False
85 85
86 86 #Verifica la etiqueta
87 87 if len(self.var_Elabel) == 0:
88 88 self.txtInfo.append("Enter label")
89 89 return False
90 90
91 91 return True
92 92
93 93
94 94 #------------------------------------------------- Crea directorios en la ruta indicada -----------------------------------------------------------
95 95
96 96 def make_dirs(list_dirs, self):
97 97
98 98 for var_dir in list_dirs:
99 99 shutil.rmtree(self.var_Rpath+'/'+var_dir, True)
100 100 var_output=commands.getstatusoutput("mkdir -p "+self.var_Rpath+'/'+var_dir)
101 101 if var_output[0] != 0:
102 102 self.txtInfo.append("Error creating directory: "+var_dir+", output_error:" + str(var_output[0]))
103 103 return False
104 104 self.txtInfo.append('Directories created correctly')
105 105 return True
106 106
107 107 def remove_dir(var_dir, self):
108 108 var_output = commands.getstatusoutput('chmod -R 777 '+var_dir)
109 109 if var_output[0] != 0:
110 110 self.txtInfo.append("Error changing permissions: "+var_dir+", output_error:" + str(var_output[0]))
111 111 return False
112 112
113 113 var_output = commands.getstatusoutput('rm -rf '+var_dir)
114 114 if var_output[0] != 0:
115 115 self.txtInfo.append("Error deleting directory: "+var_dir+", output_error:" + str(var_output[0]))
116 116 return False
117 117 return True
118 118
119 119 def make_dir(var_dir, self):
120 120 var_output = commands.getstatusoutput('mkdir '+var_dir)
121 121 if var_output[0] != 0:
122 self.txtInfo.append("Error deleting directory: "+var_dir+", output_error:" + str(var_output[0]))
122 self.txtInfo.append("Error making directory: "+var_dir+", output_error:" + str(var_output[0]))
123 123 return False
124 124 return True
125 125
126 126 #-------------------------------------------- Busca los archivos con los parametros de busqueda ---------------------------------------
127 127
128 128 def list_files(self):
129 129 var_files_list=[]
130 130 for var_doy in self.var_sublist:
131 131 var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort"
132 132 var_output=commands.getstatusoutput(var_cmd)[1]
133 133 for var_file in var_output.split():
134 134 var_files_list.append(var_file) #Almacena cada archivo en la lista
135 135 return var_files_list
136 136
137 137
138 138 #--------------- Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD -----------------------
139 139
140 140 def make_files_dat(var_files_list, self):
141 141 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
142 142 var_n=1 #Numero del DVD actual
143 143 var_tmp=0 #Se usa para acumular el tamaΓ±o de los archivos de la lista
144 144 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
145 145
146 146 for i in var_files_list: #Se asignan en i los archivos de la lista
147 147
148 148 var_size_i=os.path.getsize(i)/1024+1 #tamaΓ±o en KB del archivo de la lista, se suma 1 KB para evitar problemas al momento de sumar
149 149 var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista
150 150
151 151 #Si el tamaΓ±o acumulado es mayor que el de el DVD
152 152 if var_tmp > (self.var_Dcapacity * 1024):
153 153 var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real
154 154 #se crea un archivo con numeral en el sufijo y extension .dat
155 155 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
156 156 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
157 157 for line in var_files_list_2:
158 158 var_tmp_path=line.split(self.var_Dpath)[1][:-13]
159 159 var_file.write(var_tmp_path+'='+line+'\n')
160 160 var_file.close()
161 161
162 162 var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual
163 163 var_files_list_2=[] #Se reinicia la lista
164 164 var_n += 1
165 165 var_files_list_2.append(i)
166 166
167 167 #se crea un archivo con numeral en el sufijo y extension .dat
168 168 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
169 169 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
170 170 for line in var_files_list_2:
171 171 var_tmp_path=line.split(self.var_Dpath)[1][:-13]
172 172 var_file.write(var_tmp_path+'='+line+'\n')
173 173 var_file.close()
174 174
175 175 self.txtInfo.append("configuration files created")
176 176 return var_n
177 177
178 178
179 179 #------------------------------ Genera los archivos .print con los cuales se creara los postscript -----------------------------------
180 180
181 181 def make_files_print(self):
182 182
183 183 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
184 184 var_Rpath_gpath=self.var_Rpath+"/gpath" #Ruta de los archivos postscript
185 185 var_labels=[]
186 186 for m in range (0, self.txtPSgraphic.value() - 1):
187 187 var_lines = "\n" * 9
188 188 var_labels.append(var_lines)
189 189
190 190 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print
191 191 for var_n in range(1, self.var_Discs + 1):
192 192
193 193 #se abren los archivos .dat en modo lectura
194 194 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r")
195 195 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
196 196 var_file.close()
197 197 list_files=[]
198 198 var_lines=[]
199 199
200 200 for j in range(0, len(lines)):
201 201
202 202 if j == 0:
203 203 var_first_folder = lines[j].split('=')[0]
204 204 var_first_file = (lines[j].split('=')[1])[:-1]
205 205 continue
206 206
207 207 var_tmp_folder = lines[j].split('=')[0]
208 208 var_tmp_file = (lines[j].split('=')[1])[:-1]
209 209
210 210 # Si el subfolder superior o el DOY del archivo actual y el anterior son diferentes
211 211 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
212 212 var_last_file = (lines[j-1].split('=')[1])[:-1]
213 213 list_files.append([var_first_folder, var_first_file, var_last_file])
214 214
215 215 var_first_folder = lines[j].split('=')[0]
216 216 var_first_file = (lines[j].split('=')[1])[:-1]
217 217
218 218 var_last_file = (lines[-1].split('=')[1])[:-1]
219 219 list_files.append([var_first_folder, var_first_file, var_last_file])
220 220
221 221 var_lines2 = lines_print(list_files, self.var_Elabel)
222 222
223 223 for k in range(0, len(var_lines2) / 5):
224 224 var_lines=["\n"]
225 225 var_lines.append(" "+self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_Discs)+"\n")
226 226 var_lines.append("Year Doy Folder"+" "*9+"Set"+" "*11+"Time range\n")
227 227 var_lines.extend(var_lines2[(5*k):(5*(k+1))])
228 228 var_lines.append("\n")
229 229 var_labels.append(var_lines)
230 230
231 231 for i in range(0, (len(var_labels) // 33) +1 ):
232 232 var_file=var_Rpath_gpath+"/"+self.var_Elabel+"_"+i2s(i+1)
233 233 file_ps = open(var_file+".print","w")
234 234 if i == (len(var_labels) // 33):
235 235 var_sub_labels = var_labels[33*i:]
236 236 else:
237 237 var_sub_labels = var_labels[33*i:33*(i+1)]
238 238
239 239 for label in var_sub_labels:
240 240 for line in label:
241 241 file_ps.write(line)
242 242 file_ps.close()
243 243 var_cmd="enscript "+var_file+".print -p "+var_file+".ps -f Times-Roman7 " \
244 244 +" -3R -j -B --margins=21.25:20.4:25.51:20 --media=A4"
245 245 var_output=commands.getstatusoutput(var_cmd)[0]
246 246
247 247
248 248 def lines_print(list_files, var_Elabel):
249 249 """
250 250 Devuelve las lineas del rango de archivos de cada etiqueta segun el formato
251 251 """
252 252 var_lines=[]
253 253 for i in list_files:
254 254
255 255 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
256 256 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
257 257 if i[0] == '/':
258 258 var_folder = var_Elabel
259 259 else:
260 260 var_folder = i[0].split('/')[-2]
261 261
262 262 var_first_file = i[1]
263 263 var_last_file = i[2]
264 264
265 265 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
266 266 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
267 267
268 268 var_lines.append(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+"-"
269 269 +var_last_file[-5:-2]+" "+var_date_first_file+"-"+var_date_last_file+"\n")
270 270 #Nos aseguramos que sea un mutiplo de 5
271 271 while (len(var_lines) % 5) != 0:
272 272 var_lines.append("\n")
273 273
274 274 return var_lines
275 275
276 276 #---------------------------------------comandos para el proceso de grabacion ------------------------------------------
277 277 def cmd_iso(self):
278 278 var_Rpath_ppath=self.var_Rpath+"/ppath"
279 279 var_Rpath_iso=self.var_Rpath+"/iso"
280 280 #comando para la creacion del archivo.iso
281 281 file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(self.var_disc_n)+".dat"
282 282 file_iso=var_Rpath_iso+"/"+i2s(self.var_disc_n)+".iso"
283 283 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
284 284 var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
285 285 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
286 286 return var_cmd
287 287
288 288 def cmd_burn(self):
289 289 var_Rpath_iso=self.var_Rpath+"/iso"
290 290 file_iso=var_Rpath_iso+"/"+i2s(self.var_disc_n)+".iso"
291 291
292 292 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
293 293 var_dev_tmp = self.var_devices[var_index]
294 294
295 295 # var_cmd = "wodim -v dev="+var_dev_tmp+" speed=16 "+ file_iso
296 296 var_cmd = "growisofs -dvd-compat -Z "+var_dev_tmp+"="+ file_iso
297 297 return var_cmd
298 298
299 299
300 300 def cmd_check(dev_sr, self):
301 301
302 302 var_Rpath_tmpdata=self.var_Rpath+"/tmpdata"
303 303
304 304 var_output=commands.getstatusoutput('df -hT | grep '+dev_sr)
305 305 if var_output[0] != 0:
306 306 return "FATAL ERROR"
307 307 else:
308 308 var_cmd = "cp -rfv "+var_output[1] .split()[-1]+"/ "+var_Rpath_tmpdata+"/"
309 309 return var_cmd
310 310
311 311 def cmd_manual_check(var_data_dir, var_TDpath):
312 312
313 313 var_cmd = "cp -rfv "+var_data_dir+"/ "+var_TDpath+"/"
314 314 return var_cmd
315 315
316 316
317 317 def remove_iso(self):
318 318 var_Rpath_iso=self.var_Rpath+"/iso"
319 319 file_iso=var_Rpath_iso+"/"+i2s(self.var_disc_n)+".iso"
320 320 # shutil.rmtree(self.var_Rpath+'/'+var_dir, True)
321 321 if os.path.isfile(file_iso):
322 322 os.remove(file_iso)
323 323
324 324 #Si es el ultimo disco se termina el proceso
325 325 def is_last_disc_and_copy(self):
326 326 if self.var_disc_n == self.var_Discs and self.var_copy_n == self.var_Copys:
327 327 self.function_final()
328 328 else:
329 329 next_disc(self)
330 330
331 331 #Define cual es el siguiente disco a grabar y que paso seguir
332 332 def next_disc(self, error = False):
333 333 if self.var_copy_n == self.var_Copys:
334 334 #borrado del iso
335 335 self.txtInfo.append("Deleting iso file: "+i2s(self.var_disc_n)+".iso")
336 336 remove_iso(self)
337 337
338 338 self.var_disc_n += 1
339 339 self.var_copy_n = 1
340 340 self.var_step = 0
341 341
342 342 else:
343 343 self.var_copy_n += 1
344 344 self.var_step = 1
345 345
346 346 functions2.make_burning_conf(self) # Si el proceso no ha sido detenido manualmente
347 347 #crea el archivo burning.conf para el seguimiento de los discos grabados
348 348
349 349 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
350 350
351 351 self.txtInfo.append("NEXT DISC: "+str(self.var_disc_n)+" COPY: "+str(self.var_copy_n)
352 352 +" INDEX: "+str(var_index)+" STEP: "+str(self.var_step))
353 353 self.txtInfo.append("\n")
354 354
355 355 if var_index == 0 :
356 356 self.function_eject()
357 357
358 358 elif self.var_step == 0:
359 359 self.function_iso()
360 360 elif self.var_step == 1:
361 361 self.function_burn()
@@ -1,305 +1,290
1 1 # -*- coding: utf-8 -*-
2 2
3 3
4 4 from subprocess import *
5 5 import sys
6 6 import os
7 7 import subprocess
8 8 import commands
9 9
10 10 #----------------------------------------------------- Deteccion de los dispositivos de grabacion ---------------------------------------------------------------
11 11
12 12 def detect_devices(self):
13 13 """
14 14 Deteccion de los dispositvos de grabacion
15 15 """
16 16 #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ?
17 17 var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'"
18 18
19 19 var_output = commands.getstatusoutput(var_cmd)
20 20 if var_output[0] != 0:
21 21 self.txtInfo.append("No recording devices")
22 22 else:
23 23 var_devices = var_output[1].split('\n')
24 24
25 25 var_tmp=[]
26 26 for i in range(0, 4):
27 27 if i < len(var_devices):
28 28 var_len = len(var_devices[i])
29 29 var_tmp.append(var_devices[i][1:var_len - 1])
30 30 else:
31 31 var_tmp.append('')
32 32
33 33 #Se escriben los dispostivos correspodientes, si existen
34 34 self.txtDeviceA.setText(str(var_tmp[0]))
35 35 self.txtDeviceB.setText(str(var_tmp[1]))
36 36 self.txtDeviceC.setText(str(var_tmp[2]))
37 37 self.txtDeviceD.setText(str(var_tmp[3]))
38 38 #Se desactivan los que no existen
39 39 if len(var_tmp[0]) == 0 :
40 40 self.chkDevA.setChecked(False)
41 41 self.chkDevA.setEnabled(False)
42 42 if len(var_tmp[1]) == 0 :
43 43 self.chkDevB.setChecked(False)
44 44 self.chkDevB.setEnabled(False)
45 45 if len(var_tmp[2]) == 0 :
46 46 self.chkDevC.setChecked(False)
47 47 self.chkDevC.setEnabled(False)
48 48 if len(var_tmp[3]) == 0 :
49 49 self.chkDevD.setChecked(False)
50 50 self.chkDevD.setEnabled(False)
51 51
52 52 #----------------------------------- expulsa los dispositivos de grabacion --------------------------------------------
53 53
54 54 def eject_devices(self):
55 55 for var_dev in self.var_devices:
56 56 var_cmd = 'eject ' + var_dev
57 57 commands.getstatusoutput(var_cmd)
58 58
59 59 #Expulsa el dispositivo de grabacion actual
60 60 def eject_one_device(self):
61 61 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
62 62 var_dev = self.var_devices[var_index]
63 63 var_cmd = 'eject ' + var_dev
64 64 commands.getstatusoutput(var_cmd)
65 65
66 66 def eject_t_one_device(self):
67 67 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
68 68 var_dev = self.var_devices[var_index]
69 69 var_cmd = 'eject -t ' + var_dev
70 70 commands.getstatusoutput(var_cmd)
71 71
72 72 def get_dev_sr(self):
73 73 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
74 74 var_dev = self.var_devices[var_index]
75 75 var_output=commands.getstatusoutput('ls -lh '+var_dev)
76 76 if var_output[0] != 0:
77 77 return "FATAL ERROR"
78 78 else:
79 79 var_dev_sr = "/dev/"+var_output[1] .split()[-1]
80 80 return var_dev_sr
81 81
82 82
83 83 #----------------------------------- devuelve una lista con las carpetas en las cuales estan montados los dispositivos --------------------------------------------
84 84 def mounted_devices():
85 85
86 var_type = "tmpfs"
86 var_type = "iso9660"
87 87 var_output=commands.getstatusoutput('df -hT | grep '+ var_type)
88 88
89 89 if var_output[0] != 0:
90 90 return "FATAL ERROR"
91 91
92 92 else:
93 93 if len(var_output[1]) == 0:
94 94 return "FATAL ERROR"
95 95
96 96 list_dirs = []
97 97 for var_dir in var_output[1].split('\n'):
98 98 list_dirs.append(var_dir.split()[-1])
99 99
100 100 return list_dirs
101 101
102
102
103 103 #----------------------------------- listado de los dispositivos de grabacion seleccionados --------------------------------------------
104 104
105 105 def selected_devices(self):
106 106 self.var_devices=[]
107 107 if self.chkDevA.isChecked():
108 108 self.var_devices.append(str(self.txtDeviceA.text()))
109 109 if self.chkDevB.isChecked():
110 110 self.var_devices.append(str(self.txtDeviceB.text()))
111 111 if self.chkDevC.isChecked():
112 112 self.var_devices.append(str(self.txtDeviceC.text()))
113 113 if self.chkDevD.isChecked():
114 114 self.var_devices.append(str(self.txtDeviceD.text()))
115 115
116 116 if len(self.var_devices) == 0:
117 117 return False
118 118 else:
119 119 return True
120 120
121 121
122 122 #----------------------------------------------------- Inicializacion para pruebas---------------------------------------------------------------
123 123
124 124 def set_parameters_test(self):
125 125 """
126 126 Se usa para inicializar ciertos parametros para pruebas
127 127 """
128 128 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS')
129 129 self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager')
130 130 self.txtElabel.setText('EW_DRIFTS_pruebas')
131 131 self.lstDcapacity.setCurrentIndex(4)
132 132 self.txtDcapacity.setValue(100.0)
133 133 self.txtDcapacity.setReadOnly(False)
134 134
135 135 def set_devices_test(self):
136 136 self.txtDeviceA.setText("/dev/scd0")
137 137 self.txtDeviceB.setText("/dev/scd1")
138 138 self.txtDeviceC.setText("/dev/scd2")
139 139 self.txtDeviceD.setText("/dev/scd3")
140 140
141 141
142 142
143 143 #----------------------------------------------------- crea parameters.conf ---------------------------------------------------------------
144 144
145 145 def make_parameters_conf(self):
146 146 var_file = open("parameters.conf","w")
147 147 var_file.write(self.var_Dpath+"\n") #0 Ruta de los datos
148 148 var_file.write(self.var_Rpath+"\n") #1 Ruta del proyecto
149 149 var_file.write(str(self.var_lstDtype)+"\n") #2 opcion Data Type
150 150 var_file.write(self.var_Dtype+"\n") #3 extension Data Type
151 151 var_file.write(self.var_Elabel+"\n") #4 etiqueta
152 152 var_file.write(str(self.var_Copys)+"\n") #5 Numero de copias
153 153 var_file.write(str(self.var_lstDcapacity)+"\n") #6 opcion Device Capacity
154 154 var_file.write(str(self.var_Dcapacity)+"\n") #7 tamaΓ±o Device Capacity
155 155 var_file.write(str(self.var_Discs)+"\n") #8 Numero de discos a grabar
156 156 # var_file.write(str(self.lstStartDay.currentIndex())+"\n") #9 Indice fecha inicial
157 157 # var_file.write(str(self.lstStopDay.currentIndex())+"\n") #10 Indice fecha final
158 158 var_file.close()
159 159
160 160 #----------------------------------------------------- carga parameters.conf ---------------------------------------------------------------
161 161
162 162 def get_parameters_conf(self):
163 163 var_file = open("parameters.conf","r")
164 164 lines = var_file.readlines()
165 165 self.txtDpath.setText(lines[0][:-1]) #0
166 166 self.txtRpath.setText(lines[1][:-1]) #1
167 167 self.lstDtype.setCurrentIndex(int(lines[2])) #2
168 168 self.txtDtype.setText(lines[3][:-1]) #3
169 169 self.txtElabel.setText(lines[4][:-1]) #4
170 170 self.txtCopys.setValue(int(lines[5][:-1])) #5
171 171 self.lstDcapacity.setCurrentIndex(int(lines[6])) #6
172 172 self.txtDcapacity.setValue(float(lines[7])) #7
173 173 self.var_Discs = int(lines[8]) #8
174 174 # var_StartDay = int(lines[6]) #9
175 175 # var_StopDay = int(lines[7]) #10
176 176 ################################
177 177 self.var_Copys = self.txtCopys.value() #5
178 178 ################################
179 179
180 180 var_file.close()
181 181
182 182
183 183 #-------------------------- actualiza el valor de las variables con los parametros seleccionados -----------------------------
184 184
185 185 def set_vars(self):
186 186 self.var_Dpath = str(self.txtDpath.text()) #0
187 187 self.var_Rpath = str(self.txtRpath.text()) #1
188 188 self.var_lstDtype = self.lstDtype.currentIndex() #2
189 189 self.var_Dtype = str(self.txtDtype.text()) #3
190 190 self.var_Elabel = str(self.txtElabel.text()) #4
191 191 self.var_Copys = self.txtCopys.value() #5
192 192 self.var_lstDcapacity = self.lstDcapacity.currentIndex() #6
193 193 self.var_Dcapacity = self.txtDcapacity.value() #7
194 194 self.var_Discs = self.var_Discs #8
195 195
196 196
197 197 #-------------------------- crea burning.conf -----------------------------
198 198
199 199 def make_burning_conf(self):
200 200 var_file = open("burning.conf","w")
201 201 var_n_burned_discs = ( ( (self.var_disc_n - 1) * self.var_Copys) + self.var_copy_n - 1 )
202 202 var_file.write(str(var_n_burned_discs)+"\n") #0 Numero de discos ya grabados
203 203 var_file.write(str(self.var_disc_n)+"\n") #1 Disco actual para grabar
204 204 var_file.write(str(self.var_copy_n)+"\n") #2 Numero de copia actual para grabar
205 205 var_file.close()
206 206
207 207 #----------------------------------------------------- carga burning.conf ---------------------------------------------------------------
208 208
209 209 def get_burning_conf(self):
210 210 var_file = open("burning.conf","r")
211 211 lines = var_file.readlines()
212 212 self.var_burned_discs = int(lines[0]) #0
213 213 self.var_disc_n = int(lines[1])
214 214 self.var_copy_n = int(lines[2])
215 215 var_file.close()
216 216
217 217 #---------------------------------------------- Habilitacion y deshabilitacion de items -------------------------------------------------------
218 218
219 219 def enabled_items1(var_bool, self):
220 220 self.tabParameters.setEnabled(not(var_bool))
221 221 self.lstDcapacity.setEnabled(not(var_bool))
222 222 self.txtDcapacity.setEnabled(not(var_bool))
223 223 self.actionChange_Parameters.setEnabled(var_bool)
224 224 self.btnGbkp.setEnabled(not(var_bool))
225 225 self.btnRestart.setEnabled(var_bool)
226 226 self.btnStartburn.setEnabled(var_bool)
227 227
228 228
229 229 def enabled_items2(var_bool, self):
230 230 self.btnRestart.setEnabled(not(var_bool))
231 231 self.btnStartburn.setEnabled(not(var_bool))
232 232 self.btnStopburn.setEnabled(var_bool)
233 233 self.chkCheck.setEnabled(not(var_bool))
234 234 self.chkCheck.setChecked(False)
235 235
236 236 self.actionChange_Parameters.setEnabled(False)
237 237
238
239 def enabled_items3(var_bool, self):
240 self.btnRestart.setEnabled(not(var_bool))
241 self.btnStartburn.setEnabled(not(var_bool))
242 self.btnStopburn.setEnabled(var_bool)
243 self.chkCheck.setEnabled(not(var_bool))
244 self.chkCheck.setChecked(False)
245
246
247 self.actionChange_Parameters.setEnabled(False)
248
249 self.actionChange_Parameters.setEnabled(False)
250
251 self.actionChange_Parameters.setEnabled(False)
252
253 238
254 239 #---------------------------------------------- Actualiza estado en los labels -------------------------------------------------------
255 240
256 241 def update_message(type, message, self, index=-1):
257 242 if index == -1:
258 243 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
259 244 else:
260 245 var_index = index
261 246
262 247 var_message = message
263 248 # var_message = "BURNING"
264 249 # var_message = "COMPLETED"
265 250 # var_message = "ERROR"
266 251 # var_message = "CHECKING"
267 252 # var_message = "CHECKED"
268 253
269 254 if type == 1:
270 255
271 256 if var_index == 0:
272 257 self.txtBstatusA.setText(var_message)
273 258 self.txtBdiscA.setText(str(self.var_disc_n))
274 259 self.txtBcopyA.setText(str(self.var_copy_n))
275 260
276 261 if var_index == 1:
277 262 self.txtBstatusB.setText(var_message)
278 263 self.txtBdiscB.setText(str(self.var_disc_n))
279 264 self.txtBcopyB.setText(str(self.var_copy_n))
280 265
281 266 if var_index == 2:
282 267 self.txtBstatusC.setText(var_message)
283 268 self.txtBdiscC.setText(str(self.var_disc_n))
284 269 self.txtBcopyC.setText(str(self.var_copy_n))
285 270
286 271 if var_index == 3:
287 272 self.txtBstatusD.setText(var_message)
288 273 self.txtBdiscD.setText(str(self.var_disc_n))
289 274 self.txtBcopyD.setText(str(self.var_copy_n))
290 275
291 276 if type == 2:
292 277
293 278 if var_index == 0:
294 279 self.txtCHstatusA.setText(var_message)
295 280
296 281 if var_index == 1:
297 282 self.txtCHstatusB.setText(var_message)
298 283
299 284 if var_index == 2:
300 285 self.txtCHstatusC.setText(var_message)
301 286
302 287 if var_index == 3:
303 288 self.txtCHstatusD.setText(var_message)
304 289
305 290
@@ -1,758 +1,772
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 Ui_Parameters import Ui_Parameters
12 12 from Ui_About import Ui_About
13 13 from PyQt4 import QtGui
14 14 from subprocess import *
15 15 import sys
16 16 import os
17 17 #import subprocess
18 18 import time
19 19 import commands
20 20 from functions import functions
21 21 from functions import functions2
22 22
23 23 class MainWindow(QMainWindow, Ui_MainWindow):
24 24 """
25 25 Class documentation goes here.
26 26 """
27 27
28 28 def __init__(self, parent = None):
29 29 QMainWindow.__init__(self, parent)
30 30 self.setupUi(self)
31 31 self.setupUi2()
32 32
33 33 def setupUi2(self):
34 34
35 35 self.txtInfo.append("cambio 1")
36 36
37 37 self.allTrue = False
38 38
39 39 if self.allTrue == True:
40 40 self.var_real_principal = True
41 41 self.var_real_detect_devices = True
42 42 self.var_real_iso = True
43 43 self.var_real_burn = True
44 44 self.var_real_check = True
45 45 self.var_real_eject = True
46 46 self.var_real_manual_check = True
47 47 self.var_real_show_cmd = True
48 48
49 49 else:
50 50 self.var_real_principal = False
51 51 self.var_real_detect_devices = False
52 52 self.var_real_iso = False
53 53 self.var_real_burn = False
54 54 self.var_real_check = False
55 55 self.var_real_eject = False
56 self.var_real_manual_check = False
56 self.var_real_manual_check = True
57 57 self.var_real_show_cmd = True
58 58
59 59 if self.var_real_detect_devices == True:
60 60 # Reconocimiento de los dispositivos de grabacion
61 61 functions2.detect_devices(self)
62 62 else:
63 63 functions2.set_devices_test(self)
64 64
65 65 #Inicialiazacion de variables
66 66 self.var_Discs = 0 #Numero de discos del proyecto
67 67 self.var_Copys = 0 #Numero de copias
68 68 self.var_disc_n = 0 # disco actual
69 69 self.var_copy_n = 0 # copia actual
70 70 self.var_burned_discs = 0 #numero de discos ya grabados
71 71
72 72 self.bool_first_iso = False
73 73 self.var_step = 0 # numero de paso en el proceso
74 74 self.bool_state_burning = False #si es True se puede grabar
75 75 self.blank_discs = False # Si es true significa que se acaban de ingresar discos en blanco
76 76
77 77 self.var_list=[] # Lista de DOYs
78 78 self.var_sublist=[] # Sub-lista de DOYs seleccionados
79 79 self.var_devices=[] #Lista de dispositivos seleccionados
80 80
81 81 #Revisa si existe el archivo de confirguracion y lo carga
82 82 if os.path.isfile("parameters.conf"):
83 83 functions2.get_parameters_conf(self)
84 84 self.bool_first_iso = True
85 85 self.txtInfo.append("Parameters were loaded from configuration file")
86 86 self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys))
87 87
88 88 elif self.var_real_principal == False:
89 89 functions2.set_parameters_test(self) #Establece ciertos parametros, para pruebas
90 90
91 91 functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados
92 92
93 93 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
94 94 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
95 95 functions.load_days(self)
96 96
97 97 if os.path.isfile("parameters.conf"):
98 98 functions2.enabled_items1(True, self) #Se bloquean los parametros de configuracion
99 99
100 100 if os.path.isfile("burning.conf"):
101 101 functions2.get_burning_conf(self)
102 102 self.txtInfo.append("Current disc: "+str(self.var_disc_n))
103 103 self.txtInfo.append("Current copy: "+str(self.var_copy_n))
104 104 self.txtInfo.append("Burned discs: "+str(self.var_burned_discs))
105 105 self.btnStartburn.setText("Continue")
106 106 self.actionChange_Parameters.setEnabled(False)
107 107
108 108 self.connect(self.actionChange_Parameters, QtCore.SIGNAL("triggered()"), self.changeParameters)
109 109 self.connect(self.actionAbout, QtCore.SIGNAL("triggered()"), self.about)
110 110
111 111 self.process_iso = QtCore.QProcess()
112 112 self.connect(self.process_iso, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_iso)
113 113 self.connect(self.process_iso, QtCore.SIGNAL('readyReadStandardError()'), self.readError_iso)
114 114 self.connect(self.process_iso, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_iso)
115 115
116 116 self.process_burn = QtCore.QProcess()
117 117 self.connect(self.process_burn, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_burn)
118 118 self.connect(self.process_burn, QtCore.SIGNAL('readyReadStandardError()'), self.readError_burn)
119 119 self.connect(self.process_burn, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_burn)
120 120
121 121 self.process_check = QtCore.QProcess()
122 122 self.connect(self.process_check, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_check)
123 123 self.connect(self.process_check, QtCore.SIGNAL('readyReadStandardError()'), self.readError_check)
124 124 self.connect(self.process_check, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_check)
125 125
126 126 self.process_manual_check = QtCore.QProcess()
127 127 self.connect(self.process_manual_check, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_manual_check)
128 128 self.connect(self.process_manual_check, QtCore.SIGNAL('readyReadStandardError()'), self.readError_manual_check)
129 129 self.connect(self.process_manual_check, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_manual_check)
130 130
131 131 def changeParameters(self):
132 132 dlg=QtGui.QDialog()
133 133 dlgui=Ui_Parameters()
134 134 dlgui.setupUi(dlg)
135 135 if (dlg.exec_() == QtGui.QDialog.Accepted):
136 136 if dlgui.txtDisc.value() > self.var_Discs or dlgui.txtCopy.value() > dlgui.txtNcopys.value():
137 137 self.txtInfo.append("Wrong parameters")
138 138 else:
139 139 self.var_Copys = dlgui.txtNcopys.value()
140 140 self.var_disc_n = dlgui.txtDisc.value()
141 141 self.var_copy_n = dlgui.txtCopy.value()
142 142 self.txtInfo.append("Changed parameters")
143 143 self.var_burned_discs = ( ( (self.var_disc_n - 1) * self.var_Copys) + self.var_copy_n -1 )
144 144 self.bool_first_iso = True
145 145 self.txtInfo.append("Current disc: "+str(self.var_disc_n))
146 146 self.txtInfo.append("Current copy: "+str(self.var_copy_n))
147 147 self.txtInfo.append("Nro Copys: "+str(self.var_Copys))
148 148 functions2.make_parameters_conf(self)
149 149 self.txtCopys.setValue(self.var_Copys) #Actualizo mananualmente el valor Copys
150 150
151 151
152 152
153 153 def about(self):
154 154 dlg_about=QtGui.QDialog()
155 155 dlgui_about=Ui_About()
156 156 dlgui_about.setupUi(dlg_about)
157 157 dlg_about.exec_()
158 158
159 159
160 160 #==============================================================================
161 161 # Manejo de los eventos
162 162 #==============================================================================
163 163
164 164 #----------------------------------------------------- Obtencion de la ruta de los datos ---------------------------------------------------------------
165 165
166 166 @pyqtSignature("")
167 167 def on_btnDpath_clicked(self):
168 168 """
169 169 Permite seleccionar graficamente el direcorio de los datos a grabar
170 170 """
171 171 self.var_Dpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
172 172 self.txtDpath.setText(self.var_Dpath)
173 173 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
174 174 functions.load_days(self)
175 175
176 176
177 177 @pyqtSignature("")
178 178 def on_txtDpath_editingFinished(self):
179 179 """
180 180 Carga la ruta editada y verifica que sea correcta y carga la lista de dias
181 181 """
182 182 self.var_Dpath=str(self.txtDpath.text()) #Se carga la variable con la ruta recien editada
183 183 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
184 184 functions.load_days(self)
185 185
186 186
187 187 #----------------------------------------------------- Obtencion de las ruta del proyecto ---------------------------------------------------------------
188 188
189 189 @pyqtSignature("")
190 190 def on_btnRpath_clicked(self):
191 191 """
192 192 Permite seleccionar graficamente el direcorio del proyecto
193 193 """
194 194 self.var_Rpath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
195 195 self.txtRpath.setText(self.var_Rpath)
196 196 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
197 197
198 198
199 199 @pyqtSignature("")
200 200 def on_txtRpath_editingFinished(self):
201 201 """
202 202 Valida la ruta del proyecto
203 203 """
204 204 self.var_Rpath = str(self.txtRpath.text()) #Se carga la variable con la ruta recien editada
205 205 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
206 206
207 207
208 208 #----------------------------------------------------- Tipo de datos ---------------------------------------------------------------
209 209
210 210 @pyqtSignature("int")
211 211 def on_lstDtype_activated(self, index):
212 212 """
213 213 Permite elegir entre los tipos de archivos
214 214 """
215 215 self.txtDtype.setReadOnly(True)
216 216 if index == 0:
217 217 self.var_Dtype ='r'
218 218 elif index == 1:
219 219 self.var_Dtype ='pdata'
220 220 elif index == 2:
221 221 self.var_Dtype ='sswma'
222 222 else :
223 223 self.var_Dtype =''
224 224 self.txtDtype.setReadOnly(False)
225 225
226 226 self.txtDtype.setText(self.var_Dtype)
227 227 functions.load_days(self) #llamada a funcion
228 228
229 229 @pyqtSignature("")
230 230 def on_txtDtype_editingFinished(self):
231 231 self.var_Dtype=str(self.txtDtype.text())
232 232 functions.load_days(self) #llamada a funcion
233 233
234 234
235 235 #----------------------------------------------------- Etiqueta ---------------------------------------------------------------
236 236
237 237 @pyqtSignature("")
238 238 def on_txtElabel_editingFinished(self):
239 239 self.var_Elabel = str(self.txtElabel.text())
240 240
241 241 #----------------------------------------------------- Numero de copias ---------------------------------------------------------------
242 242 @pyqtSignature("")
243 243 def on_txtCopys_editingFinished(self):
244 244 self.var_Copys = self.txtCopys.value()
245 245
246 246 #----------------------------------------------------- Seleccion del rango de fechas ---------------------------------------------------------------
247 247
248 248 @pyqtSignature("int") #CLOSED
249 249 def on_lstStartDay_activated(self, index):
250 250 """
251 251 Cambia la lista de opciones en lstStopDay
252 252 """
253 253 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
254 254 self.lstStopDay.clear()
255 255
256 256 for i in self.var_list[index:]:
257 257 self.lstStopDay.addItem(i)
258 258
259 259 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
260 260
261 261 functions.get_sub_list(self)
262 262
263 263
264 264 @pyqtSignature("int") #CLOSED
265 265 def on_lstStopDay_activated(self, index):
266 266 """
267 267 Cambia la lista de opciones en lstStartDay
268 268 """
269 269 var_StartDay_index=self.lstStartDay.currentIndex()
270 270 var_end_index = self.lstStopDay.count() - index
271 271 self.lstStartDay.clear()
272 272
273 273 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
274 274 self.lstStartDay.addItem(i)
275 275
276 276 self.lstStartDay.setCurrentIndex(var_StartDay_index)
277 277
278 278 functions.get_sub_list(self)
279 279
280 280
281 281 #----------------------------------------------------- Capacidad del dispositivo de grabacion ---------------------------------------------------------------
282 282
283 283 @pyqtSignature("")
284 284 def on_txtDcapacity_editingFinished(self):
285 285 self.var_Dcapacity = self.txtDcapacity.value()
286 286
287 287
288 288 @pyqtSignature("int") #CLOSED
289 289 def on_lstDcapacity_activated(self, index):
290 290 """
291 291 Permite elegir el tamaΓ±o del disco
292 292 """
293 293 if index == 0:
294 294 var_size=25.0
295 295 elif index == 1:
296 296 var_size=8.5
297 297 elif index == 2:
298 298 var_size=4.7
299 299 elif index == 3:
300 300 var_size=0.7
301 301
302 302 if index != 4:
303 303 self.txtDcapacity.setValue(var_size*10**9/1024**2)
304 304 self.txtDcapacity.setReadOnly(True)
305 305 else:
306 306 self.txtDcapacity.setValue(100.0)
307 307 self.txtDcapacity.setReadOnly(False)
308 308
309 309 self.var_lstDcapacity = self.lstDcapacity.currentIndex()
310 310 self.var_Dcapacity = self.txtDcapacity.value()
311 311
312 312 #----------------------------------------------------- Testeo de las unidades de grabacion ---------------------------------------------------------------
313 313
314 314 @pyqtSignature("")
315 315 def on_btnTdevA_clicked(self):
316 316 var_dev = str(self.txtDeviceA.text())
317 317 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
318 318 commands.getstatusoutput(var_cmd)
319 319
320 320 @pyqtSignature("")
321 321 def on_btnTdevB_clicked(self):
322 322 var_dev = str(self.txtDeviceB.text())
323 323 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
324 324 commands.getstatusoutput(var_cmd)
325 325
326 326 @pyqtSignature("")
327 327 def on_btnTdevC_clicked(self):
328 328 var_dev = str(self.txtDeviceC.text())
329 329 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
330 330 commands.getstatusoutput(var_cmd)
331 331
332 332 @pyqtSignature("")
333 333 def on_btnTdevD_clicked(self):
334 334 var_dev = str(self.txtDeviceD.text())
335 335 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
336 336 commands.getstatusoutput(var_cmd)
337 337
338 338
339 339 #==============================================================================
340 340 # Botones para la generacion de los archivos de configuracion
341 341 #==============================================================================
342 342
343 343 #----------------------------------------------------- Generacion de la configuracion usando los parametros ---------------------------------------------------------------
344 344
345 345 @pyqtSignature("")
346 346 def on_btnGbkp_clicked(self):
347 347 """
348 348 Generacion de archivos de configuracion usando los parametros
349 349 """
350 350
351 351 if functions.validate_parameters(self) == False:
352 352 return
353 353
354 354 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
355 355 list_dirs=['gpath','iso','ppath', 'tmpdata']
356 356 bool_make_dirs = functions.make_dirs(list_dirs, self)
357 357 if bool_make_dirs == False:
358 358 return
359 359
360 360 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
361 361
362 362 self.var_Discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
363 363
364 364 functions.make_files_print(self) # Se crean los archivos .print
365 365
366 366 functions2.make_parameters_conf(self) # se crea el archivo parameters.conf
367 367
368 368 self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys))
369 369
370 370 #Se bloquean los parametros de configuracion
371 371 functions2.enabled_items1(True, self)
372 372 self.var_disc_n = 1
373 373 self.var_copy_n = 1
374 374 self.bool_first_iso = True
375 375 self.var_burned_discs = 0 #numero de discos grabados
376 376
377 377
378 378 #----------------------------------------------------- Permite reiniciar la configuracion ---------------------------------------------------------------
379 379
380 380 @pyqtSignature("")
381 381 def on_btnRestart_clicked(self):
382 382 """
383 383 Permite que se puedan cambiar los parametros
384 384 """
385 385 if os.path.isfile("parameters.conf"):
386 386 os.remove("parameters.conf")
387 387 if os.path.isfile("burning.conf"):
388 388 os.remove("burning.conf")
389 389
390 390 functions2.enabled_items1(False, self)
391 391 self.btnStartburn.setText("Start Burn")
392 392 self.txtInfo.clear()
393 393
394 394
395 395
396 396 #==============================================================================
397 397 # Acciones de los procesos
398 398 #==============================================================================
399 399
400 400 #------------------------------------------------ Funciones del proceso de creacion del iso ------------------------------------------------------
401 401
402 402 def readOuput_iso(self):
403 403 self.txtProgress.setText("stdout iso: " + QtCore.QString(self.process_iso.readAllStandardOutput()))
404 404
405 405 def readError_iso(self):
406 406 self.txtProgress.setText("stderr iso: " + QtCore.QString(self.process_iso.readAllStandardError()))
407 407
408 408 def finished_iso(self):
409 409 self.txtProgress.clear()
410 410
411 411 if not(self.bool_state_burning):
412 412 return
413 413
414 414 if self.process_iso.exitCode() == 0:
415 415 self.txtInfo.append("------Iso file: "+functions.i2s(self.var_disc_n)+" created successfully\n")
416 416 self.var_step = 1
417 417 self.function_burn()
418 418
419 419 else:
420 420 self.txtInfo.append("#####Error creating iso file "+functions.i2s(self.var_disc_n)
421 421 +" , code "+QtCore.QString(self.process_iso.exitCode()))
422 422 self.txtInfo.append("Please check the data")
423 423 self.txtInfo.append("FATAL ERROR")
424 424
425 425 #----------------------------------------------------- Funciones del proceso de grabado ---------------------------------------------------------------
426 426
427 427 def readOuput_burn(self):
428 428 self.txtProgress.setText("stdout burn: " + QtCore.QString(self.process_burn.readAllStandardOutput()))
429 429
430 430 def readError_burn(self):
431 431 self.txtProgress.setText("stderr burn: " + QtCore.QString(self.process_burn.readAllStandardError()))
432 432
433 433 def finished_burn(self):
434 434 self.txtProgress.clear()
435 435
436 436 #Si se paro el proceso manualmente se termina
437 437 if not(self.bool_state_burning):
438 438 return
439 439
440 440 if self.process_burn.exitCode() == 0:
441 441 self.txtInfo.append("-----Complete recording, disc: "+str(self.var_disc_n)+" copy: "+str(self.var_copy_n))
442 442 functions2.update_message(1, "COMPLETED", self)
443 443 self.var_step = 2
444 444 self.function_check()
445 445
446 446 else:
447 447 self.txtInfo.append("#######Error recording, disc: "+functions.i2s(self.var_disc_n)+" copy: "
448 448 +functions.i2s(self.var_copy_n)+", code "+QtCore.QString(self.process_burn.exitCode()))
449 449 functions2.update_message(1, "ERROR", self)
450 450
451 451 functions.is_last_disc_and_copy(self)
452 452
453 453
454 454 #----------------------------------------------------- Funciones del proceso de verificacion ---------------------------------------------------------------
455 455
456 456 def readOuput_check(self):
457 457 self.txtProgress.setText("stdout check: " + QtCore.QString(self.process_check.readAllStandardOutput()))
458 458
459 459 def readError_check(self):
460 460 self.txtProgress.setText("stderr check: " + QtCore.QString(self.process_check.readAllStandardError()))
461 461
462 462 def finished_check(self):
463 463 self.txtProgress.clear()
464 464
465 465 if not(self.bool_state_burning):
466 466 return
467 467
468 468 if self.process_check.exitCode() == 0:
469 469 self.txtInfo.append("--------Complete checking, disc: "+str(self.var_disc_n)+" copy: "+str(self.var_copy_n))
470 470 functions2.update_message(2, "CHECKED", self)
471 471
472 472 else:
473 473 self.txtInfo.append("#######Error checking, disc: "+functions.i2s(self.var_disc_n)+" copy: "
474 474 +functions.i2s(self.var_copy_n)+", code "+QtCore.QString(self.process_check.exitCode()))
475 475 functions2.update_message(2, "ERROR", self)
476 476
477 477 #borrar el contenido de tmpdata
478 478 var_tmpdata=self.var_Rpath+"/tmpdata"
479 479
480 480 bool_return = functions.remove_dir(var_tmpdata, self)
481 481 if not(bool_return):
482 482 self.txtInfo.append("Error deleting directory: "+var_tmpdata)
483 483 self.bool_state_burning = False
484 484 return
485 485
486 486 bool_return = functions.make_dir(var_tmpdata, self)
487 487 if not(bool_return):
488 488 self.txtInfo.append("Error creating directory:"+ var_tmpdata)
489 489 self.bool_state_burning = False
490 490 return
491 491
492 492 functions.is_last_disc_and_copy(self)
493 493
494 494 #----------------------------------------------------- Funciones del proceso de verificacion manual ---------------------------------------------------------------
495 495
496 496 def readOuput_manual_check(self):
497 497 self.txtProgress.setText("stdout check: " + QtCore.QString(self.process_manual_check.readAllStandardOutput()))
498 498
499 499 def readError_manual_check(self):
500 500 self.txtProgress.setText("stderr check: " + QtCore.QString(self.process_manual_check.readAllStandardError()))
501 501
502 502 def finished_manual_check(self):
503 503 self.txtProgress.clear()
504 504
505 505 if not(self.bool_state_manual_check):
506 506 return
507 507
508 508 if self.process_manual_check.exitCode() == 0:
509 509 self.txtInfo.append("--------Complete checking, disc: "+str(self.var_n_check_dirs + 1))
510 510 functions2.update_message(2, "CHECKED", self, index=self.var_n_check_dirs)
511 511
512 512 else:
513 513 self.txtInfo.append("#######Error checking, disc: "+str(self.var_n_check_dirs + 1)
514 514 +", code "+QtCore.QString(self.process_manual_check.exitCode()))
515 515 functions2.update_message(2, "ERROR", self, index=self.var_n_check_dirs)
516 516
517 517 #borrar el contenido de tmpdata
518 var_tmpdata=self.var_Rpath+"/tmpdata"
518 var_tmpdata=self.var_TDpath+"/tmpdata"
519 519
520 520 bool_return = functions.remove_dir(var_tmpdata, self)
521 521 if not(bool_return):
522 522 self.txtInfo.append("Error deleting directory: "+var_tmpdata)
523 523 self.bool_state_burning = False
524 524 return
525 525
526 bool_return = functions.make_dir(var_tmpdata, self)
527 if not(bool_return):
528 self.txtInfo.append("Error creating directory:"+ var_tmpdata)
529 self.bool_state_burning = False
530 return
531
532 if self.var_n_check_dirs >= len(self.list_check_dirs) :
526
527
528 self.var_n_check_dirs +=1
529
530 if self.var_n_check_dirs >= len(self.list_check_dirs) :
533 531 self.bool_state_manual_check = False
534 return
535
536 self.var_n_check_dirs +=1
537 self.manual_check()
532 self.function_manual_check_final()
533 return
534
535
536 self.function_manual_check()
538 537
539 538
540 539 #==============================================================================
541 540 # Botones para el proceso de grabacion
542 541 #==============================================================================
543 542
544 543 #----------------------------------------------------- Iniciar proceso de grabacion ---------------------------------------------------------------
545 544
546 545 @pyqtSignature("")
547 546 def on_btnStartburn_clicked(self):
548 547 """
549 548 Se inicia el proceso de grabacion
550 549 """
551 550 #Verifica que exista algun dispositivo de grabacion seleccionado
552 551 if not(functions2.selected_devices(self)):
553 552 self.txtInfo.append("There is no recording device selected")
554 553 return
555 554
556 555 # #Lista los dispositivos de grabacion a usar
557 556 # for dev in self.var_devices:
558 557 # self.txtInfo.append("recording device :"+dev)
559 558
560 559 self.bool_state_burning = True
561 560 functions2.enabled_items2(True, self)
562 561
563 562 if self.bool_first_iso == True:
564 563 self.txtInfo.append("BUTTON: on_btnStartburn_clicked")
565 564 self.var_step = 4
566 565 self.function_eject()
567 566 return
568 567
569 568 if self.var_step == 0:
570 569 self.function_iso()
571 570 return
572 571
573 572 if self.var_step == 1:
574 573 self.function_burn()
575 574 return
576 575
577 576 #----------------------------------------------------- Funcion para el grabado ---------------------------------------------------------------
578 577
579 578 def function_iso(self):
580 579 #Creacion del archivo.iso para la grabacion
581 580 if self.var_step == 0:
582 581 self.txtInfo.append("########## Disc number: "+str(self.var_disc_n)+"##########")
583 582 self.txtInfo.append("------Creating iso file number: "+str(self.var_disc_n))
584 583
585 584 var_cmd = functions.cmd_iso(self)
586 585
587 586 if self.var_real_show_cmd == True:
588 587 self.txtInfo.append("CMD: "+var_cmd)
589 588
590 589 if self.var_real_iso == False:
591 590 self.txtInfo.append('**function_iso')
592 591 var_cmd="echo 'function_iso'"
593 592
594 593 self.process_iso.start(var_cmd)
595 594
596 595 def function_burn(self):
597 596 #Grabacion de los DVDs
598 597
599 598 if self.var_step == 1:
600 599 self.txtInfo.append("------Recording disc: "+str(self.var_disc_n)+", copy:"+str(self.var_copy_n))
601 600 functions2.update_message(1, "BURNING", self)
602 601
603 602 var_cmd = functions.cmd_burn(self)
604 603
605 604 if self.var_real_show_cmd == True:
606 605 self.txtInfo.append("CMD: "+var_cmd)
607 606
608 607 if self.var_real_burn == False:
609 608 self.txtInfo.append('**function_burn')
610 609 var_cmd="echo 'function_burn'"
611 610
612 611 self.process_burn.start(var_cmd)
613 612
614 613 def function_check(self):
615 614 #Verificacion de los discos
616 615 if self.var_step == 2:
617 616 self.txtInfo.append("-----------checking disc:"+str(self.var_disc_n)+", copy:"+str(self.var_copy_n))
618 617
619 618 functions2.eject_one_device(self)
620 619 functions2.eject_t_one_device(self)
621 620 self.txtInfo.append("Waiting ...")
622 621 time .sleep(20)
623 622
624 623 functions2.update_message(2, "CHECKING", self)
625 624
626 625 dev_sr = functions2.get_dev_sr(self)
627 626 var_cmd = functions.cmd_check(dev_sr, self)
628 627
629 628 if self.var_real_show_cmd == True:
630 629 self.txtInfo.append("CMD: "+var_cmd)
631 630
632 631 if self.var_real_check == False:
633 632 self.txtInfo.append('**function_check')
634 633 var_cmd="echo 'function_check'"
635 634
636 635 self.process_check.start(var_cmd)
637 636
638 637 #OK
639 638 def function_eject(self):
640 639 self.txtInfo.append("Ejecting recording devices")
641 640 self.txtInfo.append("Please insert blank discs")
642 641
643 642 if self.var_real_eject == True:
644 643 functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion
645 644 else:
646 645 self.txtInfo.append("**functions2.eject_devices")
647 646
648 647 self.btnStartburn.setText("Continue")
649 648 self.btnStartburn.setEnabled(True)
650 649
651 650 if self.bool_first_iso == True:
652 651 self.bool_first_iso = False
653 652 self.var_step = 0
654 653
655 654 elif self.var_copy_n == 1:
656 655 self.var_step = 0
657 656
658 657 else:
659 658 self.var_step = 1
660 659
661 660 def function_final(self):
662 661 self.txtInfo.append("Recording process is complete")
663 662 if os.path.isfile("parameters.conf"):
664 663 os.remove("parameters.conf")
665 664 if os.path.isfile("burning.conf"):
666 665 os.remove("burning.conf")
667 666
668 667
669 668
670 669 #----------------------------------------------------- Detener proceso de grabacion ---------------------------------------------------------------
671 670
672 671 @pyqtSignature("")
673 672 def on_btnStopburn_clicked(self):
674 673 """
675 674 Slot documentation goes here.
676 675 """
677 676 self.bool_state_burning = False
678 677
679 678 if self.var_step == 0:
680 679 self.process_iso.terminate() #Termina el proceso, si puede
681 680 # self.process_iso.kill() #Mata el proceso, no es la forma adecuada, solo usar si terminate() no funciona
682 681 elif self.var_step == 1:
683 682 self.process_burn.terminate()
684 683 elif self.var_step == 2:
685 684 self.process_check.terminate()
686 685
687 686 self.txtInfo.append("Stopped recording")
688 687 functions2.enabled_items2(False, self)
689 688 self.bool_first_iso = True
690 689
691 690
692 691
693 692 #==============================================================================
694 693 # Proceso verificacion manual
695 694 #==============================================================================
696 695
697 696
698 697 #----------------------------------------------------- Proceso de verificaion manual ---------------------------------------------------------------
699 698
700 699
701 700 @pyqtSignature("")
702 701 def on_btnTDpath_clicked(self):
703 702 """
704 703 Slot documentation goes here.
705 704 """
706 705 self.var_TDpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
707 706 self.txtTDpath.setText(self.var_TDpath)
708 707 self.statusTDpath = functions.dir_exists(self.var_TDpath, self)
709 708 if self.statusTDpath:
710 709 self.btnCHstart.setEnabled(True)
711 710
712 711
713 712 @pyqtSignature("")
714 713 def on_btnCHstart_clicked(self):
715 714 """
716 715 Slot documentation goes here.
717 716 """
718 717 list_dirs = functions2.mounted_devices()
719 718 if list_dirs == "FATAL ERROR":
720 719 self.txtInfo.append("ERROR")
721 720 return
722 721
723 722 for i in list_dirs:
724 723 self.txtInfo.append(i)
725 724
726 725 self.list_check_dirs = list_dirs #contiene los directorios donde estan montados los discos a verificar
727 726 self.var_n_check_dirs = 0
728 727 self.bool_state_manual_check = True
729 728
730 729 self.btnTDpath.setEnabled(False) #Deshabilito el boton que permite cambiar la ruta de verificacion
731 730 self.btnCHstart.setText("STOP") #Cambio el texto del boton
731 self.txtInfo.append(self.btnCHstart.text())
732 732
733 733 self.function_manual_check()
734 734
735 735
736 736 def function_manual_check(self):
737 737
738 738 #Verificacion de los discos
739 739 if self.bool_state_manual_check == True:
740 740
741 self.txtInfo.append("-----------manually checking disc: "+self.var_n_check_dirs
742 +" data"+self.list_check_dirs[self.var_n_check_dirs])
741 self.txtInfo.append("-----------manually checking disc: "+str(self.var_n_check_dirs + 1)
742 +" directory: "+self.list_check_dirs[self.var_n_check_dirs])
743 743
744 744 functions2.update_message(2, "CHECKING", self, index=self.var_n_check_dirs)
745
745
746 #Crea la carpeta tmpdata dentro de la ruta elegida
747 var_tmpdata=self.var_TDpath+"/tmpdata"
748 bool_return = functions.make_dir(var_tmpdata, self)
749 if not(bool_return):
750 self.txtInfo.append("Error creating directory:"+ var_tmpdata)
751 self.bool_state_burning = False
752 return
753
746 754 var_data_dir = self.list_check_dirs[self.var_n_check_dirs] #Carpeta donde esta montado el disco actual
747 755
748 var_cmd = functions.cmd_manual_check(var_data_dir, self.var_TDpath)
756 var_cmd = functions.cmd_manual_check(var_data_dir, var_tmpdata)
749 757
750 758 if self.var_real_show_cmd == True:
751 759 self.txtInfo.append("CMD: "+var_cmd)
752 760
753 761 if self.var_real_manual_check == False:
754 762 self.txtInfo.append('**function_manual_check')
755 763 var_cmd="echo 'function_manual_check'"
756 764
757 765 self.process_manual_check.start(var_cmd)
758
766
767
768 def function_manual_check_final(self):
769 self.txtInfo.append("Manual check process is complete")
770 self.btnCHstart.setText("START") #Cambio el texto del boton
771
772
General Comments 0
You need to be logged in to leave comments. Login now