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