@@ -1,259 +1,269 | |||
|
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 | |
|
13 | 13 | #--------------------------------------------- Entero a cadena agregando ceros delante ------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | def i2s(var_n, var_length=4): |
|
16 | 16 | var_n2=str(var_n) |
|
17 | 17 | while len(var_n2) < var_length: |
|
18 | 18 | var_n2 = "0"+var_n2 |
|
19 | 19 | return var_n2 |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | #----------------------------------------- Se verifica que la ruta exista y sea un directorio ------------------------------------------------- |
|
23 | 23 | |
|
24 | 24 | def dir_exists(var_dir, self): |
|
25 | 25 | if os.path.isdir(var_dir): |
|
26 | 26 | return True |
|
27 | 27 | else: |
|
28 | 28 | self.txtInfo.append("Incorrect path:" + str(var_dir)) |
|
29 | 29 | return False |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | #-------------------------------- Se buscan los archivos del tipo especificado y se cargan las fechas ----------------------------- |
|
33 | 33 | |
|
34 | 34 | def load_days(self): |
|
35 | 35 | |
|
36 | 36 | self.var_list=[] |
|
37 | 37 | self.lstStartDay.clear() |
|
38 | 38 | self.lstStopDay.clear() |
|
39 | 39 | |
|
40 | 40 | if self.statusDpath == False: |
|
41 | 41 | self.btnGbkp.setEnabled(False) |
|
42 | 42 | return |
|
43 | 43 | |
|
44 | 44 | if self.var_Dtype == '': |
|
45 | 45 | return |
|
46 | 46 | |
|
47 | 47 | var_cmd="find " + str(self.var_Dpath) + " -name *."+ str(self.var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq" |
|
48 | 48 | output=commands.getstatusoutput(var_cmd)[1] |
|
49 | 49 | |
|
50 | 50 | #Si no se encuentra ningun archivo |
|
51 | 51 | if len(output) == 0: |
|
52 | 52 | self.txtInfo.append("File not found") |
|
53 | 53 | self.btnGbkp.setEnabled(False) |
|
54 | 54 | return |
|
55 | 55 | |
|
56 | 56 | #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox) |
|
57 | 57 | for i in range(0, (len(output)+1)/8): |
|
58 | 58 | self.var_list.append(output[8*i:8*(i+1)-1]) |
|
59 | 59 | |
|
60 | 60 | for i in self.var_list: |
|
61 | 61 | self.lstStartDay.addItem(i) |
|
62 | 62 | self.lstStopDay.addItem(i) |
|
63 | 63 | self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1) |
|
64 | 64 | |
|
65 | 65 | get_sub_list(self) |
|
66 | 66 | self.btnGbkp.setEnabled(True) |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | #-------------------------------------------------- Obtiene el rango de las fechas seleccionadas ----------------------------------------- |
|
70 | 70 | |
|
71 | 71 | def get_sub_list(self): |
|
72 | 72 | self.var_sublist=[] |
|
73 | 73 | for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]: |
|
74 | 74 | self.var_sublist.append(i) |
|
75 | 75 | |
|
76 | 76 | |
|
77 | 77 | #----------------------------------------------------- Verifica los parametros faltantes ----------------------------------------------------------- |
|
78 | 78 | |
|
79 | 79 | def validate_parameters(self): |
|
80 | 80 | #Verifica que las ruta del proyecto sea valida |
|
81 | 81 | if self.statusRpath == False: |
|
82 | 82 | self.txtInfo.append("Incorrect proyect path") |
|
83 | 83 | return False |
|
84 | 84 | |
|
85 | 85 | #Verifica la etiqueta |
|
86 | 86 | if len(self.var_Elabel) == 0: |
|
87 | 87 | self.txtInfo.append("Enter label") |
|
88 | 88 | return False |
|
89 | 89 | |
|
90 | 90 | return True |
|
91 | 91 | |
|
92 | 92 | |
|
93 | 93 | #------------------------------------------------- Crea directorios en la ruta indicada ----------------------------------------------------------- |
|
94 | 94 | |
|
95 | 95 | def make_dirs(list_dirs, self): |
|
96 | 96 | """ |
|
97 | 97 | |
|
98 | 98 | """ |
|
99 | 99 | |
|
100 | 100 | for var_dir in list_dirs: |
|
101 | 101 | shutil.rmtree(self.var_Rpath+'/'+var_dir, True) |
|
102 | 102 | var_output=commands.getstatusoutput("mkdir -p "+self.var_Rpath+'/'+var_dir)[0] |
|
103 | 103 | if var_output != 0: |
|
104 | 104 | self.txtInfo.append("Error creating directory: "+var_dir+", output_error:" + str(var_output)) |
|
105 | 105 | return False |
|
106 | 106 | self.txtInfo.append('Directories created correctly') |
|
107 | 107 | return True |
|
108 | 108 | |
|
109 | 109 | |
|
110 | 110 | #-------------------------------------------- Busca los archivos con los parametros de busqueda --------------------------------------- |
|
111 | 111 | |
|
112 | 112 | def list_files(self): |
|
113 | 113 | var_files_list=[] |
|
114 | 114 | for var_doy in self.var_sublist: |
|
115 | 115 | var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort" |
|
116 | 116 | var_output=commands.getstatusoutput(var_cmd)[1] |
|
117 | 117 | for var_file in var_output.split(): |
|
118 | 118 | var_files_list.append(var_file) #Almacena cada archivo en la lista |
|
119 | 119 | return var_files_list |
|
120 | 120 | |
|
121 | 121 | |
|
122 | 122 | #--------------- Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD ----------------------- |
|
123 | 123 | |
|
124 | 124 | def make_files_dat(var_files_list, self): |
|
125 | 125 | var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar |
|
126 | 126 | var_n=1 #Numero del DVD actual |
|
127 | 127 | var_tmp=0 #Se usa para acumular el tamaΓ±o de los archivos de la lista |
|
128 | 128 | var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD |
|
129 | 129 | |
|
130 | 130 | for i in var_files_list: #Se asignan en i los archivos de la lista |
|
131 | 131 | |
|
132 | 132 | 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 |
|
133 | 133 | var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista |
|
134 | 134 | |
|
135 | 135 | #Si el tamaΓ±o acumulado es mayor que el de el DVD |
|
136 | 136 | if var_tmp > (self.var_Dcapacity * 1024): |
|
137 | 137 | var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real |
|
138 | 138 | #se crea un archivo con numeral en el sufijo y extension .dat |
|
139 | 139 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w") |
|
140 | 140 | #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat |
|
141 | 141 | for line in var_files_list_2: |
|
142 | 142 | var_tmp_path=line.split(self.var_Dpath)[1][:-13] |
|
143 | 143 | var_file.write(var_tmp_path+'='+line+'\n') |
|
144 | 144 | var_file.close() |
|
145 | 145 | |
|
146 | 146 | var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual |
|
147 | 147 | var_files_list_2=[] #Se reinicia la lista |
|
148 | 148 | var_n += 1 |
|
149 | 149 | var_files_list_2.append(i) |
|
150 | 150 | |
|
151 | 151 | #se crea un archivo con numeral en el sufijo y extension .dat |
|
152 | 152 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w") |
|
153 | 153 | #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat |
|
154 | 154 | for line in var_files_list_2: |
|
155 | 155 | var_tmp_path=line.split(self.var_Dpath)[1][:-13] |
|
156 | 156 | var_file.write(var_tmp_path+'='+line+'\n') |
|
157 | 157 | var_file.close() |
|
158 | 158 | |
|
159 | 159 | self.txtInfo.append("configuration files created") |
|
160 | 160 | return var_n |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | #------------------------------ Genera los archivos .print con los cuales se creara los postscript ----------------------------------- |
|
164 | 164 | |
|
165 | 165 | def make_files_print(self): |
|
166 | 166 | |
|
167 | 167 | var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar |
|
168 | 168 | var_Rpath_gpath=self.var_Rpath+"/gpath" #Ruta de los archivos postscript |
|
169 | 169 | var_labels=[] |
|
170 | 170 | for m in range (0, self.txtPSgraphic.value() - 1): |
|
171 | 171 | var_lines = "\n" * 9 |
|
172 | 172 | var_labels.append(var_lines) |
|
173 | 173 | |
|
174 | 174 | # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print |
|
175 | 175 | for var_n in range(1, self.var_Discs + 1): |
|
176 | 176 | |
|
177 | 177 | #se abren los archivos .dat en modo lectura |
|
178 | 178 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r") |
|
179 | 179 | lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista |
|
180 | 180 | var_file.close() |
|
181 | 181 | list_files=[] |
|
182 | 182 | var_lines=[] |
|
183 | 183 | |
|
184 | 184 | for j in range(0, len(lines)): |
|
185 | 185 | |
|
186 | 186 | if j == 0: |
|
187 | 187 | var_first_folder = lines[j].split('=')[0] |
|
188 | 188 | var_first_file = (lines[j].split('=')[1])[:-1] |
|
189 | 189 | continue |
|
190 | 190 | |
|
191 | 191 | var_tmp_folder = lines[j].split('=')[0] |
|
192 | 192 | var_tmp_file = (lines[j].split('=')[1])[:-1] |
|
193 | 193 | |
|
194 | 194 | # Si el subfolder superior o el DOY del archivo actual y el anterior son diferentes |
|
195 | 195 | if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]): |
|
196 | 196 | var_last_file = (lines[j-1].split('=')[1])[:-1] |
|
197 | 197 | list_files.append([var_first_folder, var_first_file, var_last_file]) |
|
198 | 198 | |
|
199 | 199 | var_first_folder = lines[j].split('=')[0] |
|
200 | 200 | var_first_file = (lines[j].split('=')[1])[:-1] |
|
201 | 201 | |
|
202 | 202 | var_last_file = (lines[-1].split('=')[1])[:-1] |
|
203 | 203 | list_files.append([var_first_folder, var_first_file, var_last_file]) |
|
204 | 204 | |
|
205 | 205 | var_lines2 = lines_print(list_files, self.var_Elabel) |
|
206 | 206 | |
|
207 | 207 | for k in range(0, len(var_lines2) / 5): |
|
208 | 208 | var_lines=["\n"] |
|
209 | 209 | var_lines.append(" "+self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_Discs)+"\n") |
|
210 | 210 | var_lines.append("Year Doy Folder"+" "*6+"Set"+" "*9+"Time range\n") |
|
211 | 211 | var_lines.extend(var_lines2[(5*k):(5*(k+1))]) |
|
212 | 212 | var_lines.append("\n") |
|
213 | 213 | var_labels.append(var_lines) |
|
214 | 214 | |
|
215 | 215 | for i in range(0, (len(var_labels) // 33) +1 ): |
|
216 | 216 | var_file=var_Rpath_gpath+"/"+self.var_Elabel+"_"+i2s(i+1) |
|
217 | 217 | file_ps = open(var_file+".print","w") |
|
218 | 218 | if i == (len(var_labels) // 33): |
|
219 | 219 | var_sub_labels = var_labels[33*i:] |
|
220 | 220 | else: |
|
221 | 221 | var_sub_labels = var_labels[33*i:33*(i+1)] |
|
222 | 222 | |
|
223 | 223 | for label in var_sub_labels: |
|
224 | 224 | for line in label: |
|
225 | 225 | file_ps.write(line) |
|
226 | 226 | file_ps.close() |
|
227 | 227 | var_cmd="enscript "+var_file+".print -p "+var_file+".ps -f Times-Roman7 " \ |
|
228 | 228 | +" -3R -j -B --margins=21.25:20.4:25.51:20 --media=A4" |
|
229 | 229 | var_output=commands.getstatusoutput(var_cmd)[0] |
|
230 | 230 | |
|
231 | 231 | |
|
232 | 232 | def lines_print(list_files, var_Elabel): |
|
233 | 233 | """ |
|
234 | 234 | Devuelve las lineas del rango de archivos de cada etiqueta segun el formato |
|
235 | 235 | """ |
|
236 | 236 | var_lines=[] |
|
237 | 237 | for i in list_files: |
|
238 | 238 | |
|
239 | 239 | # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/ |
|
240 | 240 | # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio |
|
241 | 241 | if i[0] == '/': |
|
242 | 242 | var_folder = var_Elabel |
|
243 | 243 | else: |
|
244 | 244 | var_folder = i[0].split('/')[-2] |
|
245 | 245 | |
|
246 | 246 | var_first_file = i[1] |
|
247 | 247 | var_last_file = i[2] |
|
248 | 248 | |
|
249 | 249 | var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1] |
|
250 | 250 | var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1] |
|
251 | 251 | |
|
252 | 252 | var_lines.append(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" " |
|
253 | 253 | +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n") |
|
254 | 254 | #Nos aseguramos que sea un mutiplo de 5 |
|
255 | 255 | while (len(var_lines) % 5) != 0: |
|
256 | 256 | var_lines.append("\n") |
|
257 | 257 | |
|
258 | 258 | return var_lines |
|
259 | 259 | |
|
260 | def cmd_iso(self): | |
|
261 | var_Rpath_ppath=self.var_Rpath+"/ppath" | |
|
262 | var_Rpath_iso=self.var_Rpath+"/iso" | |
|
263 | #comando para la creacion del archivo.iso | |
|
264 | file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(self.var_disc_n)+".dat" | |
|
265 | file_iso=var_Rpath_iso+"/"+i2s(self.var_disc_n)+".iso" | |
|
266 | var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r ' | |
|
267 | var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel | |
|
268 | var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso | |
|
269 | return var_cmd |
@@ -1,165 +1,192 | |||
|
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 | # self.txtInfo.append("dispositivos encontrados") |
|
24 | 24 | var_devices = var_output[1].split('\n') |
|
25 | 25 | |
|
26 | 26 | var_tmp=[] |
|
27 | 27 | for i in range(0, 4): |
|
28 | 28 | if i < len(var_devices): |
|
29 | 29 | var_len = len(var_devices[i]) |
|
30 | 30 | var_tmp.append(var_devices[i][1:var_len - 1]) |
|
31 | 31 | else: |
|
32 | 32 | var_tmp.append('') |
|
33 | 33 | |
|
34 | 34 | #Se escriben los dispostivos correspodientes, si existen |
|
35 | 35 | self.txtDeviceA.setText(str(var_tmp[0])) |
|
36 | 36 | self.txtDeviceB.setText(str(var_tmp[1])) |
|
37 | 37 | self.txtDeviceC.setText(str(var_tmp[2])) |
|
38 | 38 | self.txtDeviceD.setText(str(var_tmp[3])) |
|
39 | 39 | #Se desactivan los que no existen |
|
40 | 40 | if len(var_tmp[0]) == 0 : |
|
41 | 41 | self.chkDevA.setChecked(False) |
|
42 | 42 | self.chkDevA.setEnabled(False) |
|
43 | 43 | if len(var_tmp[1]) == 0 : |
|
44 | 44 | self.chkDevB.setChecked(False) |
|
45 | 45 | self.chkDevB.setEnabled(False) |
|
46 | 46 | if len(var_tmp[2]) == 0 : |
|
47 | 47 | self.chkDevC.setChecked(False) |
|
48 | 48 | self.chkDevC.setEnabled(False) |
|
49 | 49 | if len(var_tmp[3]) == 0 : |
|
50 | 50 | self.chkDevD.setChecked(False) |
|
51 | 51 | self.chkDevD.setEnabled(False) |
|
52 | 52 | |
|
53 | 53 | #----------------------------------- expulsa los dispositivos de grabacion -------------------------------------------- |
|
54 | 54 | |
|
55 | 55 | def eject_devices(self): |
|
56 | self.txtInfo.append("Ejecting recording devices") | |
|
57 | return | |
|
56 | 58 | for var_dev in self.var_devices: |
|
57 | 59 | var_cmd = 'eject ' + var_dev |
|
58 | 60 | commands.getstatusoutput(var_cmd) |
|
59 | 61 | |
|
60 | 62 | #----------------------------------- listado de los dispositivos de grabacion seleccionados -------------------------------------------- |
|
61 | 63 | |
|
62 | 64 | def selected_devices(self): |
|
63 | 65 | self.var_devices=[] |
|
64 | 66 | if self.chkDevA.isChecked(): |
|
65 | 67 | self.var_devices.append(str(self.txtDeviceA.text())) |
|
66 | 68 | if self.chkDevB.isChecked(): |
|
67 | 69 | self.var_devices.append(str(self.txtDeviceB.text())) |
|
68 | 70 | if self.chkDevC.isChecked(): |
|
69 | 71 | self.var_devices.append(str(self.txtDeviceC.text())) |
|
70 | 72 | if self.chkDevD.isChecked(): |
|
71 | 73 | self.var_devices.append(str(self.txtDeviceD.text())) |
|
72 | 74 | |
|
73 | 75 | if len(self.var_devices) == 0: |
|
74 | 76 | return False |
|
75 | 77 | else: |
|
76 | 78 | return True |
|
77 | 79 | |
|
78 | 80 | |
|
79 | 81 | #----------------------------------------------------- Inicializacion para pruebas--------------------------------------------------------------- |
|
80 | 82 | |
|
81 | 83 | def set_parameters_test(self): |
|
82 | 84 | """ |
|
83 | 85 | Se usa para inicializar ciertos parametros para pruebas |
|
84 | 86 | """ |
|
85 | 87 | self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS') |
|
86 | 88 | self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager') |
|
87 | 89 | self.txtElabel.setText('EW_DRIFTS_pruebas') |
|
88 | 90 | self.lstDcapacity.setCurrentIndex(4) |
|
89 | 91 | self.txtDcapacity.setValue(100.0) |
|
90 | 92 | self.txtDcapacity.setReadOnly(False) |
|
91 | 93 | self.txtDeviceA.setText("/dev/scd0") |
|
92 | 94 | self.txtDeviceB.setText("/dev/scd1") |
|
93 | 95 | self.txtDeviceC.setText("/dev/scd2") |
|
94 | 96 | self.txtDeviceD.setText("/dev/scd3") |
|
95 | 97 | |
|
96 | 98 | |
|
97 | 99 | |
|
98 | 100 | #----------------------------------------------------- crea parameters.conf --------------------------------------------------------------- |
|
99 | 101 | |
|
100 | 102 | def make_parameters_conf(self): |
|
101 | 103 | var_file = open("parameters.conf","w") |
|
102 | 104 | var_file.write(self.var_Dpath+"\n") #0 Ruta de los datos |
|
103 | 105 | var_file.write(self.var_Rpath+"\n") #1 Ruta del proyecto |
|
104 | 106 | var_file.write(str(self.var_lstDtype)+"\n") #2 opcion Data Type |
|
105 | 107 | var_file.write(self.var_Dtype+"\n") #3 extension Data Type |
|
106 | 108 | var_file.write(self.var_Elabel+"\n") #4 etiqueta |
|
107 | 109 | var_file.write(str(self.var_Copys)+"\n") #5 Numero de copias |
|
108 | 110 | var_file.write(str(self.var_lstDcapacity)+"\n") #6 opcion Device Capacity |
|
109 | 111 | var_file.write(str(self.var_Dcapacity)+"\n") #7 tamaΓ±o Device Capacity |
|
110 | 112 | var_file.write(str(self.var_Discs)+"\n") #8 Numero de discos a grabar |
|
111 | 113 | # var_file.write(str(self.lstStartDay.currentIndex())+"\n") #9 Indice fecha inicial |
|
112 | 114 | # var_file.write(str(self.lstStopDay.currentIndex())+"\n") #10 Indice fecha final |
|
113 | 115 | |
|
114 | 116 | var_file.close() |
|
115 | 117 | |
|
116 | 118 | #----------------------------------------------------- carga parameters.conf --------------------------------------------------------------- |
|
117 | 119 | |
|
118 | 120 | def get_parameters_conf(self): |
|
119 | 121 | var_file = open("parameters.conf","r") |
|
120 | 122 | lines = var_file.readlines() |
|
121 | 123 | self.txtDpath.setText(lines[0][:-1]) #0 |
|
122 | 124 | self.txtRpath.setText(lines[1][:-1]) #1 |
|
123 | 125 | self.lstDtype.setCurrentIndex(int(lines[2])) #2 |
|
124 | 126 | self.txtDtype.setText(lines[3][:-1]) #3 |
|
125 | 127 | self.txtElabel.setText(lines[4][:-1]) #4 |
|
126 | 128 | self.txtCopys.setValue(int(lines[5][:-1])) #5 |
|
127 | 129 | self.lstDcapacity.setCurrentIndex(int(lines[6])) #6 |
|
128 | 130 | self.txtDcapacity.setValue(float(lines[7])) #7 |
|
129 | 131 | self.var_Discs = int(lines[8]) #8 |
|
130 | 132 | # var_StartDay = int(lines[6]) #9 |
|
131 | 133 | # var_StopDay = int(lines[7]) #10 |
|
134 | ################################ | |
|
135 | self.var_Copys = self.txtCopys.value() #5 | |
|
136 | ################################ | |
|
137 | ||
|
132 | 138 | var_file.close() |
|
133 | 139 | |
|
134 | 140 | |
|
135 | 141 | |
|
136 | 142 | #-------------------------- actualiza el valor de las variables con los parametros seleccionados ----------------------------- |
|
137 | 143 | |
|
138 | 144 | def set_vars(self): |
|
139 | 145 | self.var_Dpath = str(self.txtDpath.text()) #0 |
|
140 | 146 | self.var_Rpath = str(self.txtRpath.text()) #1 |
|
141 | 147 | self.var_lstDtype = self.lstDtype.currentIndex() #2 |
|
142 | 148 | self.var_Dtype = str(self.txtDtype.text()) #3 |
|
143 | 149 | self.var_Elabel = str(self.txtElabel.text()) #4 |
|
144 | 150 | self.var_Copys = self.txtCopys.value() #5 |
|
145 | 151 | self.var_lstDcapacity = self.lstDcapacity.currentIndex() #6 |
|
146 | 152 | self.var_Dcapacity = self.txtDcapacity.value() #7 |
|
147 | 153 | self.var_Discs = self.var_Discs #8 |
|
154 | ||
|
155 | ||
|
156 | #-------------------------- crea burning.conf ----------------------------- | |
|
157 | ||
|
158 | def make_burning_conf(self): | |
|
159 | var_file = open("burning.conf","w") | |
|
160 | var_n_burned_discs = ( ( (self.var_disc_n - 1) * self.var_Copys) + self.var_copy_n -1 ) | |
|
161 | var_file.write(str(var_n_burned_discs)+"\n") #0 Numero de discos ya grabados | |
|
162 | var_file.write(str(self.var_disc_n)+"\n") #1 Disco actual para grabar | |
|
163 | var_file.write(str(self.var_copy_n)+"\n") #2 Numero de copia actual para grabar | |
|
164 | var_file.close() | |
|
165 | ||
|
166 | #----------------------------------------------------- carga burning.conf --------------------------------------------------------------- | |
|
167 | ||
|
168 | def get_burning_conf(self): | |
|
169 | var_file = open("burning.conf","r") | |
|
170 | lines = var_file.readlines() | |
|
171 | self.var_burned_discs = int(lines[0]) #0 | |
|
172 | self.var_disc_n = int(lines[1]) | |
|
173 | self.var_copy_n = int(lines[2]) | |
|
174 | var_file.close() | |
|
148 | 175 | |
|
149 | 176 | #---------------------------------------------- Habilitacion y deshabilitacion de items ------------------------------------------------------- |
|
150 | 177 | |
|
151 | 178 | def enabled_items1(var_bool, self): |
|
152 | 179 | self.tabParameters.setEnabled(not(var_bool)) |
|
153 | 180 | self.lstDcapacity.setEnabled(not(var_bool)) |
|
154 | 181 | self.txtDcapacity.setEnabled(not(var_bool)) |
|
155 | 182 | self.actionChange_Parameters.setEnabled(var_bool) |
|
156 | 183 | self.btnGbkp.setEnabled(not(var_bool)) |
|
157 | 184 | self.btnRestart.setEnabled(var_bool) |
|
158 | 185 | self.btnStartburn.setEnabled(var_bool) |
|
159 | 186 | |
|
160 | 187 | |
|
161 | 188 | def enabled_items2(var_bool, self): |
|
162 | 189 | self.btnRestart.setEnabled(not(var_bool)) |
|
163 | 190 | self.btnStartburn.setEnabled(not(var_bool)) |
|
164 | 191 | self.btnStopburn.setEnabled(var_bool) |
|
165 | 192 | self.chkCheck.setEnabled(not(var_bool)) |
@@ -1,169 +1,165 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE Project SYSTEM "Project-4.6.dtd"> |
|
3 | 3 | <!-- eric4 project file for project jro_backup_manager --> |
|
4 |
<!-- Saved: 2010-05-24, |
|
|
4 | <!-- Saved: 2010-05-24, 15:03:39 --> | |
|
5 | 5 | <!-- Copyright (C) 2010 , --> |
|
6 | 6 | <Project version="4.6"> |
|
7 | 7 | <Language>en</Language> |
|
8 | 8 | <ProgLanguage mixed="0">Python</ProgLanguage> |
|
9 | 9 | <ProjectType>Qt4</ProjectType> |
|
10 | 10 | <Description></Description> |
|
11 | 11 | <Version>0.1</Version> |
|
12 | 12 | <Author></Author> |
|
13 | 13 | <Email></Email> |
|
14 | 14 | <Sources> |
|
15 | 15 | <Source>__init__.py</Source> |
|
16 | 16 | <Source>ui/Ui_MainWindow.py</Source> |
|
17 | 17 | <Source>ui/MainWindow.py</Source> |
|
18 | 18 | <Source>main.py</Source> |
|
19 | 19 | <Source>ui/__init__.py</Source> |
|
20 | 20 | <Source>functions/__init__.py</Source> |
|
21 | 21 | <Source>functions/functions.py</Source> |
|
22 | 22 | <Source>functions/functions2.py</Source> |
|
23 | 23 | <Source>functions/func_doc.py</Source> |
|
24 | <Source>ui/Ui_About2.py</Source> | |
|
25 | <Source>ui/Ui_Parameters2.py</Source> | |
|
26 | 24 | <Source>ui/Ui_About.py</Source> |
|
27 | 25 | <Source>ui/Ui_Parameters.py</Source> |
|
28 | 26 | </Sources> |
|
29 | 27 | <Forms> |
|
30 | 28 | <Form>ui/MainWindow.ui</Form> |
|
31 | <Form>ui/About2.ui</Form> | |
|
32 | <Form>ui/Parameters2.ui</Form> | |
|
33 | 29 | <Form>ui/About.ui</Form> |
|
34 | 30 | <Form>ui/Parameters.ui</Form> |
|
35 | 31 | </Forms> |
|
36 | 32 | <Translations> |
|
37 | 33 | </Translations> |
|
38 | 34 | <Resources> |
|
39 | 35 | </Resources> |
|
40 | 36 | <Interfaces> |
|
41 | 37 | </Interfaces> |
|
42 | 38 | <Others> |
|
43 | 39 | </Others> |
|
44 | 40 | <MainScript>main.py</MainScript> |
|
45 | 41 | <Vcs> |
|
46 | 42 | <VcsType>Subversion</VcsType> |
|
47 | 43 | <VcsOptions> |
|
48 | 44 | <dict> |
|
49 | 45 | <key> |
|
50 | 46 | <string>add</string> |
|
51 | 47 | </key> |
|
52 | 48 | <value> |
|
53 | 49 | <list> |
|
54 | 50 | <string></string> |
|
55 | 51 | </list> |
|
56 | 52 | </value> |
|
57 | 53 | <key> |
|
58 | 54 | <string>checkout</string> |
|
59 | 55 | </key> |
|
60 | 56 | <value> |
|
61 | 57 | <list> |
|
62 | 58 | <string></string> |
|
63 | 59 | </list> |
|
64 | 60 | </value> |
|
65 | 61 | <key> |
|
66 | 62 | <string>commit</string> |
|
67 | 63 | </key> |
|
68 | 64 | <value> |
|
69 | 65 | <list> |
|
70 | 66 | <string></string> |
|
71 | 67 | </list> |
|
72 | 68 | </value> |
|
73 | 69 | <key> |
|
74 | 70 | <string>diff</string> |
|
75 | 71 | </key> |
|
76 | 72 | <value> |
|
77 | 73 | <list> |
|
78 | 74 | <string></string> |
|
79 | 75 | </list> |
|
80 | 76 | </value> |
|
81 | 77 | <key> |
|
82 | 78 | <string>export</string> |
|
83 | 79 | </key> |
|
84 | 80 | <value> |
|
85 | 81 | <list> |
|
86 | 82 | <string></string> |
|
87 | 83 | </list> |
|
88 | 84 | </value> |
|
89 | 85 | <key> |
|
90 | 86 | <string>global</string> |
|
91 | 87 | </key> |
|
92 | 88 | <value> |
|
93 | 89 | <list> |
|
94 | 90 | <string></string> |
|
95 | 91 | </list> |
|
96 | 92 | </value> |
|
97 | 93 | <key> |
|
98 | 94 | <string>history</string> |
|
99 | 95 | </key> |
|
100 | 96 | <value> |
|
101 | 97 | <list> |
|
102 | 98 | <string></string> |
|
103 | 99 | </list> |
|
104 | 100 | </value> |
|
105 | 101 | <key> |
|
106 | 102 | <string>log</string> |
|
107 | 103 | </key> |
|
108 | 104 | <value> |
|
109 | 105 | <list> |
|
110 | 106 | <string></string> |
|
111 | 107 | </list> |
|
112 | 108 | </value> |
|
113 | 109 | <key> |
|
114 | 110 | <string>remove</string> |
|
115 | 111 | </key> |
|
116 | 112 | <value> |
|
117 | 113 | <list> |
|
118 | 114 | <string></string> |
|
119 | 115 | </list> |
|
120 | 116 | </value> |
|
121 | 117 | <key> |
|
122 | 118 | <string>status</string> |
|
123 | 119 | </key> |
|
124 | 120 | <value> |
|
125 | 121 | <list> |
|
126 | 122 | <string></string> |
|
127 | 123 | </list> |
|
128 | 124 | </value> |
|
129 | 125 | <key> |
|
130 | 126 | <string>tag</string> |
|
131 | 127 | </key> |
|
132 | 128 | <value> |
|
133 | 129 | <list> |
|
134 | 130 | <string></string> |
|
135 | 131 | </list> |
|
136 | 132 | </value> |
|
137 | 133 | <key> |
|
138 | 134 | <string>update</string> |
|
139 | 135 | </key> |
|
140 | 136 | <value> |
|
141 | 137 | <list> |
|
142 | 138 | <string></string> |
|
143 | 139 | </list> |
|
144 | 140 | </value> |
|
145 | 141 | </dict> |
|
146 | 142 | </VcsOptions> |
|
147 | 143 | <VcsOtherData> |
|
148 | 144 | <dict> |
|
149 | 145 | <key> |
|
150 | 146 | <string>standardLayout</string> |
|
151 | 147 | </key> |
|
152 | 148 | <value> |
|
153 | 149 | <bool>True</bool> |
|
154 | 150 | </value> |
|
155 | 151 | </dict> |
|
156 | 152 | </VcsOtherData> |
|
157 | 153 | </Vcs> |
|
158 | 154 | <FiletypeAssociations> |
|
159 | 155 | <FiletypeAssociation pattern="*.ui" type="FORMS" /> |
|
160 | 156 | <FiletypeAssociation pattern="*.idl" type="INTERFACES" /> |
|
161 | 157 | <FiletypeAssociation pattern="*.qm" type="TRANSLATIONS" /> |
|
162 | 158 | <FiletypeAssociation pattern="*.ptl" type="SOURCES" /> |
|
163 | 159 | <FiletypeAssociation pattern="*.pyw" type="SOURCES" /> |
|
164 | 160 | <FiletypeAssociation pattern="*.ui.h" type="FORMS" /> |
|
165 | 161 | <FiletypeAssociation pattern="*.ts" type="TRANSLATIONS" /> |
|
166 | 162 | <FiletypeAssociation pattern="*.py" type="SOURCES" /> |
|
167 | 163 | <FiletypeAssociation pattern="*.qrc" type="RESOURCES" /> |
|
168 | 164 | </FiletypeAssociations> |
|
169 | 165 | </Project> No newline at end of file |
@@ -1,484 +1,517 | |||
|
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 commands |
|
19 | 19 | from functions import functions |
|
20 | 20 | from functions import functions2 |
|
21 | 21 | |
|
22 | 22 | class MainWindow(QMainWindow, Ui_MainWindow): |
|
23 | 23 | """ |
|
24 | 24 | Class documentation goes here. |
|
25 | 25 | """ |
|
26 | 26 | |
|
27 | 27 | def __init__(self, parent = None): |
|
28 | 28 | QMainWindow.__init__(self, parent) |
|
29 | 29 | self.setupUi(self) |
|
30 | 30 | |
|
31 | 31 | self.setupUi2() |
|
32 | 32 | #sys.stdout = self #redirige salida estandar |
|
33 | 33 | |
|
34 | 34 | def setupUi2(self): |
|
35 | 35 | |
|
36 | 36 | # functions2.detect_devices(self) #busca los dispositivos de grabacion |
|
37 | 37 | |
|
38 | 38 | self.var_Discs = 0 #Numero de discos del proyecto |
|
39 | 39 | self.var_Copys = 0 #Numero de copias |
|
40 | 40 | self.var_disc_n = 0 |
|
41 | 41 | self.var_copy_n = 0 |
|
42 | self.var_burned_discs = 0 | |
|
42 | 43 | |
|
43 | 44 | self.var_list=[] |
|
44 | 45 | self.var_sublist=[] |
|
45 | 46 | |
|
46 | 47 | self.var_devices=[] |
|
47 | 48 | |
|
48 | 49 | self.var_step = 0 |
|
49 | 50 | self.bool_state_burning = False |
|
50 | 51 | self.blank_discs = False |
|
51 | 52 | |
|
52 | 53 | |
|
53 | 54 | #Revisa si existe el archivo de confirguracion |
|
54 | 55 | if os.path.isfile("parameters.conf"): |
|
56 | functions2.get_parameters_conf(self) | |
|
55 | 57 | self.txtInfo.append("Parameters were loaded from configuration file") |
|
56 | functions2.get_parameters_conf(self) | |
|
57 | 58 | self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys)) |
|
58 | 59 | |
|
59 | 60 | else: |
|
60 | 61 | # self.txtInfo.append("Elija los parametros de configuracion") |
|
61 | 62 | functions2.set_parameters_test(self) #Establece ciertos parametros, para pruebas |
|
62 | 63 | |
|
63 | 64 | functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados |
|
64 | 65 | |
|
65 | 66 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
66 | 67 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
67 | 68 | functions.load_days(self) |
|
68 | 69 | |
|
69 | 70 | if os.path.isfile("parameters.conf"): |
|
70 | 71 | functions2.enabled_items1(True, self) #Se bloquean los parametros de configuracion |
|
71 | ||
|
72 | ||
|
73 | if os.path.isfile("burning.conf"): | |
|
74 | functions2.get_burning_conf(self) | |
|
75 | self.txtInfo.append("Current disc: "+str(self.var_disc_n)) | |
|
76 | self.txtInfo.append("Current copy: "+str(self.var_copy_n)) | |
|
77 | self.btnStartburn.setText("Continue") | |
|
78 | ||
|
79 | self.txtDeviceA.setText("/dev/scd0") | |
|
80 | self.txtDeviceB.setText("/dev/scd1") | |
|
81 | self.txtDeviceC.setText("/dev/scd2") | |
|
82 | self.txtDeviceD.setText("/dev/scd3") | |
|
83 | ||
|
72 | 84 | self.connect(self.actionChange_Parameters, QtCore.SIGNAL("triggered()"), self.changeParameters) |
|
73 | 85 | self.connect(self.actionAbout, QtCore.SIGNAL("triggered()"), self.about) |
|
74 | 86 | |
|
75 | 87 | self.var_process = QtCore.QProcess() |
|
76 | 88 | self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput) |
|
77 | 89 | self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardError()'), self.readError) |
|
78 | 90 | self.connect(self.var_process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished) |
|
79 | 91 | |
|
80 | 92 | self.var_process_check = QtCore.QProcess() |
|
81 | 93 | self.connect(self.var_process_check, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_check) |
|
82 | 94 | self.connect(self.var_process_check, QtCore.SIGNAL('readyReadStandardError()'), self.readError_check) |
|
83 | 95 | self.connect(self.var_process_check, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_check) |
|
84 | 96 | |
|
85 | 97 | def write(self, txt): |
|
86 | 98 | self.txtInfo.append(str(txt)) |
|
87 | 99 | |
|
88 | 100 | def changeParameters(self): |
|
89 | 101 | dlg=QtGui.QDialog() |
|
90 | 102 | dlgui=Ui_Parameters() |
|
91 | 103 | dlgui.setupUi(dlg) |
|
92 | 104 | if (dlg.exec_() == QtGui.QDialog.Accepted): |
|
93 | 105 | if dlgui.txtDisc.value() > self.var_Discs or dlgui.txtCopy.value() > dlgui.txtNcopys.value(): |
|
94 | 106 | self.txtInfo.append("Wrong parameters") |
|
95 | 107 | else: |
|
96 | 108 | self.var_Copys = dlgui.txtNcopys.value() |
|
97 | 109 | self.var_disc_n = dlgui.txtDisc.value() |
|
98 | 110 | self.var_copy_n = dlgui.txtCopy.value() |
|
99 | 111 | self.txtInfo.append("Changed parameters") |
|
100 | 112 | |
|
101 | 113 | |
|
102 | 114 | def about(self): |
|
103 | 115 | dlg_about=QtGui.QDialog() |
|
104 | 116 | dlgui_about=Ui_About() |
|
105 | 117 | dlgui_about.setupUi(dlg_about) |
|
106 | 118 | dlg_about.exec_() |
|
107 | 119 | |
|
108 | 120 | #----------------------------------------------------- Funciones del proceso --------------------------------------------------------------- |
|
109 | 121 | |
|
110 | 122 | def readOuput(self): |
|
111 | 123 | self.txtInfo.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput())) |
|
112 | 124 | |
|
113 | 125 | def readError(self): |
|
114 | self.txtInfo.setText("stderr: " + QtCore.QString(self.var_process.readAllStandardError())) | |
|
126 | self.txtInfo.insertPlainText("stderr: " + QtCore.QString(self.var_process.readAllStandardError())) | |
|
115 | 127 | |
|
116 | 128 | def finished(self): |
|
117 |
self.txtInfo. |
|
|
118 | if self.var_disc_n <= self.var_Discs and self.bool_state_burning: | |
|
129 | self.txtInfo.insertPlainText("process completed"+QtCore.QString(self.var_process.exitCode())+"\n") | |
|
130 | ||
|
131 | ||
|
132 | if self.var_process.exitCode() != 0: | |
|
133 | self.txtInfo.append("ERROR") | |
|
134 | ||
|
135 | if self.bool_state_burning: | |
|
136 | if self.var_step == 0: | |
|
137 | self.var_step = 1 #Se ira al paso de la grabacion en la siguiente llamada | |
|
138 | ||
|
139 | elif self.var_step == 1: | |
|
140 | self.var_copy_n += 1 | |
|
141 | ||
|
119 | 142 | self.burning() |
|
120 | 143 | |
|
121 | 144 | |
|
122 | 145 | #----------------------------------------------------- Funciones del proceso de verificacion --------------------------------------------------------------- |
|
123 | 146 | |
|
124 | 147 | def readOuput_check(self): |
|
125 | 148 | self.txtInfo.insertPlainText("stdout check: " + QtCore.QString(self.var_process_check.readAllStandardOutput())) |
|
126 | 149 | |
|
127 | 150 | def readError_check(self): |
|
128 | 151 | self.txtInfo.setText("stderr check: " + QtCore.QString(self.var_process_check.readAllStandardError())) |
|
129 | 152 | |
|
130 | 153 | def finished_check(self): |
|
131 |
self.txtInfo.append("proces |
|
|
154 | self.txtInfo.append("check process completed "+QtCore.QString(self.var_process_check.exitCode())+"\n") | |
|
132 | 155 | |
|
133 | 156 | |
|
134 | 157 | #----------------------------------------------------- Obtencion de la ruta de los datos --------------------------------------------------------------- |
|
135 | 158 | |
|
136 | 159 | @pyqtSignature("") |
|
137 | 160 | def on_btnDpath_clicked(self): |
|
138 | 161 | """ |
|
139 | 162 | Permite seleccionar graficamente el direcorio de los datos a grabar |
|
140 | 163 | """ |
|
141 | 164 | self.var_Dpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) |
|
142 | 165 | self.txtDpath.setText(self.var_Dpath) |
|
143 | 166 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
144 | 167 | functions.load_days(self) |
|
145 | 168 | |
|
146 | 169 | |
|
147 | 170 | @pyqtSignature("") |
|
148 | 171 | def on_txtDpath_editingFinished(self): |
|
149 | 172 | """ |
|
150 | 173 | Carga la ruta editada y verifica que sea correcta y carga la lista de dias |
|
151 | 174 | """ |
|
152 | 175 | self.var_Dpath=str(self.txtDpath.text()) #Se carga la variable con la ruta recien editada |
|
153 | 176 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
154 | 177 | functions.load_days(self) |
|
155 | 178 | |
|
156 | 179 | |
|
157 | 180 | #----------------------------------------------------- Obtencion de las ruta del proyecto --------------------------------------------------------------- |
|
158 | 181 | |
|
159 | 182 | @pyqtSignature("") |
|
160 | 183 | def on_btnRpath_clicked(self): |
|
161 | 184 | """ |
|
162 | 185 | Permite seleccionar graficamente el direcorio del proyecto |
|
163 | 186 | """ |
|
164 | 187 | self.var_Rpath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) |
|
165 | 188 | self.txtRpath.setText(self.var_Rpath) |
|
166 | 189 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
167 | 190 | |
|
168 | 191 | |
|
169 | 192 | @pyqtSignature("") |
|
170 | 193 | def on_txtRpath_editingFinished(self): |
|
171 | 194 | """ |
|
172 | 195 | Valida la ruta del proyecto |
|
173 | 196 | """ |
|
174 | 197 | self.var_Rpath = str(self.txtRpath.text()) #Se carga la variable con la ruta recien editada |
|
175 | 198 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
176 | 199 | |
|
177 | 200 | |
|
178 | 201 | #----------------------------------------------------- Tipo de datos --------------------------------------------------------------- |
|
179 | 202 | |
|
180 | 203 | @pyqtSignature("int") |
|
181 | 204 | def on_lstDtype_activated(self, index): |
|
182 | 205 | """ |
|
183 | 206 | Permite elegir entre los tipos de archivos |
|
184 | 207 | """ |
|
185 | 208 | self.txtDtype.setReadOnly(True) |
|
186 | 209 | if index == 0: |
|
187 | 210 | self.var_Dtype ='r' |
|
188 | 211 | elif index == 1: |
|
189 | 212 | self.var_Dtype ='pdata' |
|
190 | 213 | elif index == 2: |
|
191 | 214 | self.var_Dtype ='sswma' |
|
192 | 215 | else : |
|
193 | 216 | self.var_Dtype ='' |
|
194 | 217 | self.txtDtype.setReadOnly(False) |
|
195 | 218 | |
|
196 | 219 | self.txtDtype.setText(self.var_Dtype) |
|
197 | 220 | functions.load_days(self) #llamada a funcion |
|
198 | 221 | |
|
199 | 222 | @pyqtSignature("") |
|
200 | 223 | def on_txtDtype_editingFinished(self): |
|
201 | 224 | self.var_Dtype=str(self.txtDtype.text()) |
|
202 | 225 | functions.load_days(self) #llamada a funcion |
|
203 | 226 | |
|
204 | 227 | |
|
205 | 228 | #----------------------------------------------------- Etiqueta --------------------------------------------------------------- |
|
206 | 229 | |
|
207 | 230 | @pyqtSignature("") |
|
208 | 231 | def on_txtElabel_editingFinished(self): |
|
209 | 232 | self.var_Elabel = str(self.txtElabel.text()) |
|
210 | 233 | |
|
211 | 234 | #----------------------------------------------------- Numero de copias --------------------------------------------------------------- |
|
212 | 235 | @pyqtSignature("") |
|
213 | 236 | def on_txtCopys_editingFinished(self): |
|
214 | 237 | self.var_Copys = self.txtCopys.value() |
|
215 | 238 | |
|
216 | 239 | #----------------------------------------------------- Seleccion del rango de fechas --------------------------------------------------------------- |
|
217 | 240 | |
|
218 | 241 | @pyqtSignature("int") #CLOSED |
|
219 | 242 | def on_lstStartDay_activated(self, index): |
|
220 | 243 | """ |
|
221 | 244 | Cambia la lista de opciones en lstStopDay |
|
222 | 245 | """ |
|
223 | 246 | var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex() |
|
224 | 247 | self.lstStopDay.clear() |
|
225 | 248 | |
|
226 | 249 | for i in self.var_list[index:]: |
|
227 | 250 | self.lstStopDay.addItem(i) |
|
228 | 251 | |
|
229 | 252 | self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index) |
|
230 | 253 | |
|
231 | 254 | functions.get_sub_list(self) |
|
232 | 255 | |
|
233 | 256 | |
|
234 | 257 | @pyqtSignature("int") #CLOSED |
|
235 | 258 | def on_lstStopDay_activated(self, index): |
|
236 | 259 | """ |
|
237 | 260 | Cambia la lista de opciones en lstStartDay |
|
238 | 261 | """ |
|
239 | 262 | var_StartDay_index=self.lstStartDay.currentIndex() |
|
240 | 263 | var_end_index = self.lstStopDay.count() - index |
|
241 | 264 | self.lstStartDay.clear() |
|
242 | 265 | |
|
243 | 266 | for i in self.var_list[:len(self.var_list) - var_end_index + 1]: |
|
244 | 267 | self.lstStartDay.addItem(i) |
|
245 | 268 | |
|
246 | 269 | self.lstStartDay.setCurrentIndex(var_StartDay_index) |
|
247 | 270 | |
|
248 | 271 | functions.get_sub_list(self) |
|
249 | 272 | |
|
250 | 273 | |
|
251 | 274 | #----------------------------------------------------- Capacidad del dispositivo de grabacion --------------------------------------------------------------- |
|
252 | 275 | |
|
253 | 276 | @pyqtSignature("") |
|
254 | 277 | def on_txtDcapacity_editingFinished(self): |
|
255 | 278 | self.var_Dcapacity = self.txtDcapacity.value() |
|
256 | 279 | |
|
257 | 280 | |
|
258 | 281 | @pyqtSignature("int") #CLOSED |
|
259 | 282 | def on_lstDcapacity_activated(self, index): |
|
260 | 283 | """ |
|
261 | 284 | Permite elegir el tamaΓ±o del disco |
|
262 | 285 | """ |
|
263 | 286 | if index == 0: |
|
264 | 287 | var_size=25.0 |
|
265 | 288 | elif index == 1: |
|
266 | 289 | var_size=8.5 |
|
267 | 290 | elif index == 2: |
|
268 | 291 | var_size=4.7 |
|
269 | 292 | elif index == 3: |
|
270 | 293 | var_size=0.7 |
|
271 | 294 | |
|
272 | 295 | if index != 4: |
|
273 | 296 | self.txtDcapacity.setValue(var_size*10**9/1024**2) |
|
274 | 297 | self.txtDcapacity.setReadOnly(True) |
|
275 | 298 | else: |
|
276 | 299 | self.txtDcapacity.setValue(100.0) |
|
277 | 300 | self.txtDcapacity.setReadOnly(False) |
|
278 | 301 | |
|
279 | 302 | self.var_lstDcapacity = self.lstDcapacity.currentIndex() |
|
280 | 303 | self.var_Dcapacity = self.txtDcapacity.value() |
|
281 | 304 | |
|
282 | 305 | |
|
283 | 306 | #============================================================================== |
|
284 | 307 | # Botones para la generacion de los archivos de configuracion y el proceso de grabacion |
|
285 | 308 | #============================================================================== |
|
286 | 309 | |
|
287 | 310 | #----------------------------------------------------- Generacion de la configuracion usando los parametros --------------------------------------------------------------- |
|
288 | 311 | |
|
289 | 312 | @pyqtSignature("") |
|
290 | 313 | def on_btnGbkp_clicked(self): |
|
291 | 314 | """ |
|
292 | 315 | Generacion de archivos de configuracion usando los parametros |
|
293 | 316 | """ |
|
294 | 317 | |
|
295 | 318 | if functions.validate_parameters(self) == False: |
|
296 | 319 | return |
|
297 | 320 | |
|
298 | 321 | #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente |
|
299 | 322 | list_dirs=['gpath','iso','ppath', 'tmpdata'] |
|
300 | 323 | bool_make_dirs = functions.make_dirs(list_dirs, self) |
|
301 | 324 | if bool_make_dirs == False: |
|
302 | 325 | return |
|
303 | 326 | |
|
304 | 327 | var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar |
|
305 | 328 | |
|
306 | 329 | self.var_Discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat |
|
307 | 330 | |
|
308 | 331 | functions.make_files_print(self) # Se crean los archivos .print |
|
309 | 332 | |
|
310 | 333 | functions2.make_parameters_conf(self) # se crea el archivo parameters.conf |
|
311 | 334 | |
|
312 | 335 | self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys)) |
|
313 | 336 | |
|
314 | 337 | #Se bloquean los parametros de configuracion |
|
315 | 338 | functions2.enabled_items1(True, self) |
|
316 | 339 | |
|
317 | 340 | |
|
318 | 341 | |
|
319 | 342 | #----------------------------------------------------- Permite reiniciar la configuracion --------------------------------------------------------------- |
|
320 | 343 | |
|
321 | 344 | @pyqtSignature("") |
|
322 | 345 | def on_btnRestart_clicked(self): |
|
323 | 346 | """ |
|
324 | 347 | Permite que se puedan cambiar los parametros |
|
325 | 348 | """ |
|
349 | if os.path.isfile("parameters.conf"): | |
|
350 | os.remove("parameters.conf") | |
|
351 | if os.path.isfile("burning.conf"): | |
|
352 | os.remove("burning.conf") | |
|
353 | ||
|
326 | 354 | functions2.enabled_items1(False, self) |
|
327 | os.remove("parameters.conf") | |
|
355 | self.btnStartburn.setText("Start Burn") | |
|
356 | ||
|
328 | 357 | |
|
329 | 358 | |
|
330 | 359 | #----------------------------------------------------- Iniciar proceso de grabacion --------------------------------------------------------------- |
|
331 | 360 | |
|
332 | 361 | @pyqtSignature("") |
|
333 | 362 | def on_btnStartburn_clicked(self): |
|
334 | 363 | """ |
|
335 | 364 | Se inicia el proceso de grabacion |
|
336 | 365 | """ |
|
337 | ||
|
366 | self.txtInfo.append("BUTTON: on_btnStartburn_clicked") | |
|
367 | #Verifica que exista algun dispositivo de grabacion seleccionado | |
|
368 | if not(functions2.selected_devices(self)): | |
|
369 | self.txtInfo.append("There is no recording device selected") | |
|
370 | return | |
|
371 | ||
|
372 | # #Lista los dispositivos de grabacion a usar | |
|
373 | # for dev in self.var_devices: | |
|
374 | # self.txtInfo.append("recording device :"+dev) | |
|
375 | ||
|
376 | #Si se ingresaron los DVDs en blanco | |
|
338 | 377 | if self.blank_discs == True: |
|
339 | 378 | self.btnStartburn.setEnabled(False) |
|
340 | 379 | self.burning() |
|
341 | 380 | return |
|
342 | ||
|
343 | #Verifica que exista algun dispositivo de grabacion seleccionado | |
|
344 | if not(functions2.selected_devices(self)): | |
|
345 | self.txtInfo.append("There is no recording device selected") | |
|
381 | ||
|
382 | #Si se cargo los parametros de burning.conf | |
|
383 | if self.var_burned_discs != 0: | |
|
384 | self.txtInfo.append("BURNED DISC: "+str(self.var_burned_discs)) | |
|
385 | self.var_step = 0 | |
|
386 | self.bool_state_burning = True | |
|
387 | self.blank_discs = False | |
|
388 | functions2.enabled_items2(True, self) | |
|
389 | self.burning() | |
|
346 | 390 | return |
|
347 | ||
|
348 | #Lista los dispositivos de grabacion a usar | |
|
349 | for dev in self.var_devices: | |
|
350 | self.txtInfo.append("recording device :"+dev) | |
|
351 | 391 | |
|
352 | 392 | #Asigna las variables con los valores iniciales |
|
353 |
self.var_disc_n = |
|
|
354 |
self.var_copy_n = |
|
|
393 | self.var_disc_n = 1 # numero de disco actual para grabacion | |
|
394 | self.var_copy_n = 1 | |
|
395 | self.var_burned_discs = 0 #numero de discos grabados | |
|
355 | 396 | self.var_step = 0 |
|
356 | 397 | self.bool_state_burning = True |
|
357 | 398 | self.blank_discs = False |
|
358 | ||
|
359 | 399 | functions2.enabled_items2(True, self) |
|
360 | 400 | self.burning() |
|
361 | 401 | |
|
402 | ||
|
362 | 403 | def burning(self): |
|
363 | 404 | |
|
364 | 405 | var_Rpath_ppath=self.var_Rpath+"/ppath" |
|
365 | 406 | var_Rpath_iso=self.var_Rpath+"/iso" |
|
407 | ||
|
408 | #Si ya se grabaron todas las copias del disco | |
|
409 | if self.var_copy_n > self.var_Copys: | |
|
410 | #borra la imagen.iso del numero de disco anterior | |
|
411 | file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso" | |
|
412 | self.txtInfo.append("Deleting iso file") | |
|
413 | # os.remove(file_iso) | |
|
414 | self.var_copy_n = 1 | |
|
415 | self.var_disc_n += 1 # aumenta numero de disco actual para grabacion | |
|
416 | self.var_step = 0 | |
|
417 | ||
|
418 | #Si ya se grabaron todos los discos | |
|
419 | if self.var_disc_n > self.var_Discs: | |
|
420 | self.bool_state_burning = False | |
|
421 | self.txtInfo.append("Recording process is complete") | |
|
422 | functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion | |
|
423 | return | |
|
424 | ||
|
425 | self.txtInfo.append("\n"+str(self.var_disc_n)+" "+str(self.var_copy_n)+" "+str(self.var_step)) | |
|
366 | 426 | |
|
367 | 427 | #Creacion del archivo.iso para la grabacion |
|
368 | 428 | if self.var_step == 0: |
|
369 | #borra la imagen.iso del numero de disco anterior | |
|
370 | if self.var_disc_n > 0: | |
|
371 | file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso" | |
|
372 | # os.remove(file_iso) | |
|
373 | ||
|
374 | self.var_disc_n += 1 # aumenta numero de disco actual para grabacion | |
|
375 | self.var_copy_n = 0 # Resetea el numero actual de la copia | |
|
376 | ||
|
377 | #Si ya se grabaron todos los discos | |
|
378 | if self.var_disc_n > self.var_Discs: | |
|
379 | self.bool_state_burning = False | |
|
380 | self.txtInfo.append("Recording process is complete") | |
|
381 | # functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion | |
|
382 | ||
|
383 | return | |
|
384 | ||
|
385 | self.txtInfo.append("########## DISCO NUMERO: "+str(self.var_disc_n)+"##########") | |
|
386 | self.txtInfo.append("--------Creando el iso del disco numero: "+str(self.var_disc_n)) | |
|
387 | ||
|
388 | #comando para la creacion del archivo.iso | |
|
389 | file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(self.var_disc_n)+".dat" | |
|
390 | file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso" | |
|
391 | var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r ' | |
|
392 | var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel | |
|
393 | var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso | |
|
394 | self.var_step = 1 #Se ira al paso de la grabacion en la siguiente llamada | |
|
429 | self.txtInfo.append("########## Disc number: "+str(self.var_disc_n)+"##########") | |
|
430 | self.txtInfo.append("---------Creating iso file number: "+str(self.var_disc_n)) | |
|
431 | var_cmd = functions.cmd_iso(self) | |
|
395 | 432 | |
|
396 | 433 | #Grabacion de los DVDs |
|
397 | 434 | elif self.var_step == 1: |
|
398 | self.var_copy_n += 1 # numero de copia actual | |
|
399 | var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) ) % len(self.var_devices) | |
|
435 | ||
|
436 | functions2.make_burning_conf(self) | |
|
437 | ||
|
438 | var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices) | |
|
400 | 439 | |
|
401 | 440 | if var_index == 0 and self.blank_discs == False: |
|
402 | self.txtInfo.append("EXPULSANDO BANDEJAS") | |
|
403 | self.var_copy_n -= 1 #El numero de copia se regresa al estado anterior | |
|
404 | # functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion | |
|
441 | functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion | |
|
405 | 442 | self.blank_discs = True |
|
406 | 443 | self.btnStartburn.setText("Continue") |
|
407 | 444 | self.btnStartburn.setEnabled(True) |
|
408 | 445 | return |
|
409 | 446 | |
|
410 | 447 | self.blank_discs = False |
|
411 | 448 | |
|
412 | 449 | self.txtInfo.append("Grabando la copia numero: "+str(self.var_copy_n)) |
|
413 | #Si esta es la ultima copia se pasara al siguiente disco en la siguiente llamada a la funcion | |
|
414 | if self.var_copy_n == self.var_Copys: | |
|
415 | self.var_step = 0 | |
|
416 | 450 | |
|
417 | 451 | var_dev_tmp = self.var_devices[var_index] |
|
418 | 452 | file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso" |
|
419 | 453 | var_cmd = "wodim -v dev="+var_dev_tmp+" speed=16 "+ file_iso |
|
420 | 454 | |
|
421 |
self.var_process.start(' |
|
|
422 | self.txtInfo.append("CMD: "+var_cmd) | |
|
455 | self.var_process.start('echo "comando"') | |
|
456 | # self.txtInfo.append("CMD: "+var_cmd) | |
|
423 | 457 | |
|
424 | 458 | # self.txtInfo.append("creando iso") |
|
425 | 459 | # self.var_process.start(var_cmd) |
|
426 | 460 | |
|
427 | 461 | |
|
428 | 462 | #----------------------------------------------------- Detener proceso de grabacion --------------------------------------------------------------- |
|
429 | 463 | |
|
430 | 464 | @pyqtSignature("") |
|
431 | 465 | def on_btnStopburn_clicked(self): |
|
432 | 466 | """ |
|
433 | 467 | Slot documentation goes here. |
|
434 | 468 | """ |
|
435 | 469 | self.bool_state_burning = False |
|
436 | 470 | self.var_process.terminate() #Termina el proceso, si puede |
|
437 | 471 | # self.var_process.kill() #Mata el proceso, no es la forma adecuada, solo usar si terminate() no funciona |
|
438 | 472 | self.txtInfo.append("Stopped recording") |
|
439 | 473 | functions2.enabled_items2(False, self) |
|
440 | self.btnStartburn.setText("Start Burn") | |
|
441 | 474 | |
|
442 | 475 | |
|
443 | 476 | #----------------------------------------------------- Testeo de las unidades de grabacion --------------------------------------------------------------- |
|
444 | 477 | |
|
445 | 478 | @pyqtSignature("") |
|
446 | 479 | def on_btnTdevA_clicked(self): |
|
447 | 480 | var_dev = str(self.txtDeviceA.text()) |
|
448 | 481 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
449 | 482 | commands.getstatusoutput(var_cmd) |
|
450 | 483 | |
|
451 | 484 | @pyqtSignature("") |
|
452 | 485 | def on_btnTdevB_clicked(self): |
|
453 | 486 | var_dev = str(self.txtDeviceB.text()) |
|
454 | 487 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
455 | 488 | commands.getstatusoutput(var_cmd) |
|
456 | 489 | |
|
457 | 490 | @pyqtSignature("") |
|
458 | 491 | def on_btnTdevC_clicked(self): |
|
459 | 492 | var_dev = str(self.txtDeviceC.text()) |
|
460 | 493 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
461 | 494 | commands.getstatusoutput(var_cmd) |
|
462 | 495 | |
|
463 | 496 | @pyqtSignature("") |
|
464 | 497 | def on_btnTdevD_clicked(self): |
|
465 | 498 | var_dev = str(self.txtDeviceD.text()) |
|
466 | 499 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
467 | 500 | commands.getstatusoutput(var_cmd) |
|
468 | 501 | |
|
469 | 502 | @pyqtSignature("") |
|
470 | 503 | def on_btnTDpath_clicked(self): |
|
471 | 504 | """ |
|
472 | 505 | Slot documentation goes here. |
|
473 | 506 | """ |
|
474 | 507 | self.var_TDpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)) |
|
475 | 508 | self.txtTDpath.setText(self.var_TDpath) |
|
476 | 509 | self.statusTDpath = functions.dir_exists(self.var_TDpath, self) |
|
477 | 510 | |
|
478 | 511 | |
|
479 | 512 | @pyqtSignature("") |
|
480 | 513 | def on_btnCHstart_clicked(self): |
|
481 | 514 | """ |
|
482 | 515 | Slot documentation goes here. |
|
483 | 516 | """ |
|
484 | pass | |
|
517 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now