@@ -1,214 +1,206 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | #class BKmanager: |
|
4 | 4 | # def __init__(self): |
|
5 | 5 | |
|
6 | 6 | from subprocess import * |
|
7 | 7 | import sys |
|
8 | 8 | import os |
|
9 | 9 | import subprocess |
|
10 | 10 | import commands |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | #Entero a cadena agregando ceros delante |
|
14 | 14 | def i2s(var_n, var_length=4): |
|
15 | 15 | var_n2=str(var_n) |
|
16 | 16 | while len(var_n2) < var_length: |
|
17 | 17 | var_n2 = "0"+var_n2 |
|
18 | 18 | return var_n2 |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | #Crea directorios en la ruta indicada |
|
22 | 22 | def make_dirs(list_dirs, self): |
|
23 | 23 | var_cmd="mkdir -p "+str(self.var_Rpath) |
|
24 | 24 | for var_dir in list_dirs: |
|
25 | 25 | var_output=commands.getstatusoutput(var_cmd+'/'+var_dir)[0] |
|
26 | 26 | if var_output != 0: |
|
27 | 27 | self.txtInfo.append("Error al crear el directorio "+var_dir+", output_error:" + str(var_output)) |
|
28 | 28 | return False |
|
29 | 29 | self.txtInfo.append('Carpetas creadas correctamente') |
|
30 | 30 | return True |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | #Se verifica que la ruta exista y sea un directorio |
|
34 | 34 | def dir_exists(var_dir, self): |
|
35 | 35 | if os.path.isdir(var_dir): |
|
36 | 36 | self.txtInfo.append("Ruta valida, sin error:" + str(var_dir)) |
|
37 | 37 | return True |
|
38 | 38 | else: |
|
39 | 39 | self.txtInfo.append("Ruta no valida, output_error:" + str(var_dir)) |
|
40 | 40 | return False |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | #Se buscan los archivos del tipo especificado |
|
44 | 44 | def load_days(self): |
|
45 | 45 | |
|
46 | 46 | self.var_list=[] |
|
47 | 47 | self.lstStartDay.clear() |
|
48 | 48 | self.lstStopDay.clear() |
|
49 | 49 | |
|
50 | 50 | if self.statusDpath == False: |
|
51 | 51 | self.btnGbkp.setEnabled(False) |
|
52 | 52 | return |
|
53 | 53 | |
|
54 | 54 | if self.var_Dtype == '': |
|
55 | 55 | return |
|
56 | 56 | |
|
57 | 57 | var_cmd="find " + str(self.var_Dpath) + " -name *."+ str(self.var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq" |
|
58 | 58 | output=commands.getstatusoutput(var_cmd)[1] |
|
59 | 59 | |
|
60 | 60 | #Si no se encuentra ningun archivo |
|
61 | 61 | if len(output) == 0: |
|
62 | 62 | self.txtInfo.append("No se encontraron archivos") |
|
63 | 63 | self.btnGbkp.setEnabled(False) |
|
64 | 64 | return |
|
65 | 65 | |
|
66 | 66 | #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox) |
|
67 | 67 | for i in range(0, (len(output)+1)/8): |
|
68 | 68 | self.var_list.append(output[8*i:8*(i+1)-1]) |
|
69 | 69 | |
|
70 | 70 | for i in self.var_list: |
|
71 | 71 | self.lstStartDay.addItem(i) |
|
72 | 72 | self.lstStopDay.addItem(i) |
|
73 | 73 | self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1) |
|
74 | 74 | |
|
75 | 75 | get_sub_list(self) |
|
76 | 76 | self.btnGbkp.setEnabled(True) |
|
77 | 77 | |
|
78 | 78 | |
|
79 | 79 | #Verifica que los parametros |
|
80 | 80 | def validate_parameters(self): |
|
81 | 81 | #Verifica que las rutas sean validas |
|
82 | 82 | if self.statusRpath == False: |
|
83 | 83 | self.txtInfo.append("Ruta de proyecto no valida") |
|
84 | 84 | return False |
|
85 | 85 | |
|
86 | 86 | #Verifica la etiqueta |
|
87 | 87 | if len(self.var_Elabel) == 0: |
|
88 | 88 | self.txtInfo.append("Debe ingresar el nombre de la etiqueta") |
|
89 | 89 | return False |
|
90 | 90 | |
|
91 | 91 | return True |
|
92 | 92 | |
|
93 | 93 | |
|
94 | 94 | #Obtiene el rango de las fechas seleccionadas |
|
95 | 95 | def get_sub_list(self): |
|
96 | 96 | self.var_sublist=[] |
|
97 | 97 | for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]: |
|
98 | 98 | self.var_sublist.append(i) |
|
99 | 99 | if len(self.var_sublist) == 0: |
|
100 | 100 | self.txtInfo.append("No existen archivos encontrados") |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | #Busca los archivos con los parametros de busqueda |
|
104 | 104 | def list_files(self): |
|
105 | 105 | var_files_list=[] |
|
106 | 106 | for var_doy in self.var_sublist: |
|
107 | 107 | var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort" |
|
108 | 108 | var_output=commands.getstatusoutput(var_cmd)[1] |
|
109 | 109 | for var_file in var_output.split(): |
|
110 | 110 | var_files_list.append(var_file) #Almacena cada archivo en la lista |
|
111 | 111 | return var_files_list |
|
112 | 112 | |
|
113 | 113 | |
|
114 | 114 | #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD |
|
115 | 115 | def make_files_dat(var_files_list, self): |
|
116 | 116 | var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar |
|
117 | 117 | var_n=1 #Numero del DVD actual |
|
118 | 118 | var_tmp=0 #Se usa para acumular el tamaΓ±o de los archivos de la lista |
|
119 | 119 | var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD |
|
120 | 120 | |
|
121 | 121 | for i in var_files_list: #Se asignan en i los archivos de la lista |
|
122 | 122 | self.txtInfo.append(i) |
|
123 | 123 | 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 |
|
124 | 124 | var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista |
|
125 | 125 | |
|
126 | 126 | #Si el tamaΓ±o acumulado es mayor que el de el DVD |
|
127 | 127 | if var_tmp > (self.var_Dcapacity * 1024): |
|
128 | 128 | var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real |
|
129 | 129 | #se crea un archivo con numeral en el sufijo y extension .dat |
|
130 | 130 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w") |
|
131 | 131 | #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat |
|
132 | 132 | for line in var_files_list_2: |
|
133 |
var_tmp_path= |
|
|
134 |
var_tmp_path |
|
|
135 | for l in range(0, len(var_tmp_path)-1): | |
|
136 | var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/" | |
|
137 | var_file.write(var_tmp_path2+'=') | |
|
138 | var_file.write(line+'\n') | |
|
133 | var_tmp_path=line.split(self.var_Dpath)[1][:-13] | |
|
134 | var_file.write(var_tmp_path+'='+line+'\n') | |
|
139 | 135 | var_file.close() |
|
140 | 136 | |
|
141 | 137 | var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual |
|
142 | 138 | var_files_list_2=[] #Se reinicia la lista |
|
143 | 139 | var_n += 1 |
|
144 | 140 | var_files_list_2.append(i) |
|
145 | 141 | |
|
146 | 142 | #se crea un archivo con numeral en el sufijo y extension .dat |
|
147 | 143 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w") |
|
148 | 144 | #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat |
|
149 | 145 | for line in var_files_list_2: |
|
150 |
var_tmp_path= |
|
|
151 | var_tmp_path2="/" | |
|
152 | for l in range(0, len(var_tmp_path)-1): | |
|
153 | var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/" | |
|
154 | var_file.write(var_tmp_path2+'=') | |
|
155 | var_file.write(line+'\n') | |
|
146 | var_tmp_path=line.split(self.var_Dpath)[1][:-13] | |
|
147 | var_file.write(var_tmp_path+'='+line+'\n') | |
|
156 | 148 | var_file.close() |
|
157 | ||
|
149 | ||
|
158 | 150 | return var_n |
|
159 | 151 | |
|
160 | 152 | |
|
161 | 153 | #Genera los archivos .print con los cuales se creara los postscript |
|
162 | 154 | def make_files_print(self): |
|
163 | 155 | |
|
164 | 156 | var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar |
|
165 | 157 | |
|
166 | 158 | # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print |
|
167 | 159 | for var_n in range(1, self.var_n_discs + 1): |
|
168 | 160 | #se abren los archivos .dat en modo lectura |
|
169 | 161 | var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r") |
|
170 | 162 | lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista |
|
171 | 163 | # Se crea el archivo .print |
|
172 | 164 | var_file_print = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".print","w") |
|
173 | 165 | var_file_print.write(self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_n_discs)+"\n") |
|
174 | 166 | var_file_print.write("Year Doy Folder Set Time range\n") |
|
175 | 167 | |
|
176 | 168 | var_first_folder = lines[0].split('=')[0] |
|
177 | 169 | var_first_file = (lines[0].split('=')[1])[:-1] |
|
178 | 170 | var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1] |
|
179 | 171 | |
|
180 | 172 | for j in range(1, len(lines)-1): |
|
181 | 173 | var_tmp_folder = lines[j].split('=')[0] |
|
182 | 174 | var_tmp_file = (lines[j].split('=')[1])[:-1] |
|
183 | 175 | |
|
184 | 176 | # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea |
|
185 | 177 | if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]): |
|
186 | 178 | var_last_file = (lines[j-1].split('=')[1])[:-1] |
|
187 | 179 | var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1] |
|
188 | 180 | # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/ |
|
189 | 181 | # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio |
|
190 | 182 | if var_first_folder == '/': |
|
191 | 183 | var_folder = self.var_Elabel |
|
192 | 184 | else: |
|
193 |
var_folder = var_first_folder.split('/')[ |
|
|
185 | var_folder = var_first_folder.split('/')[-2] | |
|
194 | 186 | |
|
195 | 187 | var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" " |
|
196 | 188 | +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n") |
|
197 | 189 | |
|
198 | 190 | var_first_folder = lines[j].split('=')[0] |
|
199 | 191 | var_first_file = (lines[j].split('=')[1])[:-1] |
|
200 | 192 | var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1] |
|
201 | 193 | |
|
202 | 194 | var_last_file = (lines[-1].split('=')[1])[:-1] |
|
203 | 195 | var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1] |
|
204 | 196 | |
|
205 | 197 | if var_first_folder == '/': |
|
206 | 198 | var_folder = self.txtElabel.text() |
|
207 | 199 | else: |
|
208 |
var_folder = var_first_folder.split('/')[ |
|
|
200 | var_folder = var_first_folder.split('/')[-2] | |
|
209 | 201 | |
|
210 | 202 | var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" " |
|
211 | 203 | +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n") |
|
212 | 204 | |
|
213 | 205 | var_file.close() |
|
214 | 206 | var_file_print.close() |
@@ -1,111 +1,115 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | |
|
4 | 4 | from subprocess import * |
|
5 | 5 | import sys |
|
6 | 6 | import os |
|
7 | 7 | import subprocess |
|
8 | 8 | import commands |
|
9 | ||
|
10 | ||
|
11 | def set_parameters(self): | |
|
12 | """ | |
|
13 | Se usa para inicializar ciertos parametros para pruebas | |
|
14 | """ | |
|
15 | self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS') | |
|
16 | self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager') | |
|
17 | self.txtElabel.setText('EW_DRIFTS_pruebas') | |
|
18 | self.lstDcapacity.setCurrentIndex(4) | |
|
19 | self.txtDcapacity.setValue(250.0) | |
|
20 | self.txtDcapacity.setReadOnly(False) | |
|
21 | ||
|
9 | ||
|
22 | 10 | |
|
23 | 11 | def detect_devices(self): |
|
24 | 12 | """ |
|
25 | 13 | Deteccion de los dispositvos de grabacion |
|
26 | 14 | """ |
|
27 | 15 | #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ? |
|
28 | 16 | var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'" |
|
29 | 17 | var_output = commands.getstatusoutput(var_cmd) |
|
30 | 18 | if var_output[0] != 0: |
|
31 | 19 | self.txtInfo.append("No se pudo encontrar los dispositivos de grabacion, output_error:" + str(var_output)) |
|
32 | 20 | else: |
|
33 | 21 | self.txtInfo.append("dispositivos encontrados") |
|
34 | 22 | var_devices = var_output[1].split('\n') |
|
35 | 23 | |
|
36 | 24 | var_tmp=[] |
|
37 | 25 | for i in range(0, 4): |
|
38 | 26 | if i < len(var_devices): |
|
39 | 27 | var_len = len(var_devices[i]) |
|
40 | 28 | var_tmp.append(var_devices[i][1:var_len - 1]) |
|
41 | 29 | else: |
|
42 | 30 | var_tmp.append('') |
|
43 | 31 | |
|
44 | 32 | #Se escriben los dispostivos correspodientes, si existen |
|
45 | 33 | self.txtDeviceA.setText(str(var_tmp[0])) |
|
46 | 34 | self.txtDeviceB.setText(str(var_tmp[1])) |
|
47 | 35 | self.txtDeviceC.setText(str(var_tmp[2])) |
|
48 | 36 | self.txtDeviceD.setText(str(var_tmp[3])) |
|
49 | 37 | #Se desactivan los que no existen |
|
50 | 38 | if len(var_tmp[0]) == 0 : |
|
51 | 39 | self.chkDevA.setChecked(False) |
|
52 | 40 | self.chkDevA.setEnabled(False) |
|
53 | 41 | if len(var_tmp[1]) == 0 : |
|
54 | 42 | self.chkDevB.setChecked(False) |
|
55 | 43 | self.chkDevB.setEnabled(False) |
|
56 | 44 | if len(var_tmp[2]) == 0 : |
|
57 | 45 | self.chkDevC.setChecked(False) |
|
58 | 46 | self.chkDevC.setEnabled(False) |
|
59 | 47 | if len(var_tmp[3]) == 0 : |
|
60 | 48 | self.chkDevD.setChecked(False) |
|
61 | 49 | self.chkDevD.setEnabled(False) |
|
62 | 50 | |
|
63 | def enabled_items1(var_bool, self): | |
|
64 | self.tabParameters.setEnabled(not(var_bool)) | |
|
65 | self.lstDcapacity.setEnabled(not(var_bool)) | |
|
66 | self.txtDcapacity.setEnabled(not(var_bool)) | |
|
67 | self.btnGbkp.setEnabled(not(var_bool)) | |
|
68 | self.btnRestart.setEnabled(var_bool) | |
|
69 | self.btnStartburn.setEnabled(var_bool) | |
|
51 | def set_parameters_test(self): | |
|
52 | """ | |
|
53 | Se usa para inicializar ciertos parametros para pruebas | |
|
54 | """ | |
|
55 | self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS') | |
|
56 | self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager') | |
|
57 | self.txtElabel.setText('EW_DRIFTS_pruebas') | |
|
58 | self.lstDcapacity.setCurrentIndex(4) | |
|
59 | self.txtDcapacity.setValue(250.0) | |
|
60 | self.txtDcapacity.setReadOnly(False) | |
|
70 | 61 | |
|
71 | 62 | |
|
72 | 63 | def make_parameters_conf(self): |
|
73 | 64 | var_file = open("parameters.conf","w") |
|
74 | ||
|
75 | 65 | var_file.write(self.var_Dpath+"\n") #0 |
|
76 | 66 | var_file.write(self.var_Rpath+"\n") #1 |
|
77 | 67 | var_file.write(str(self.var_lstDtype)+"\n") #2 |
|
78 | 68 | var_file.write(self.var_Dtype+"\n") #3 |
|
79 | 69 | var_file.write(self.var_Elabel+"\n") #4 |
|
80 | 70 | var_file.write(str(self.var_Copys)+"\n") #5 |
|
81 | 71 | var_file.write(str(self.var_lstDcapacity)+"\n") #6 |
|
82 | 72 | var_file.write(str(self.var_Dcapacity)+"\n") #7 |
|
83 | ||
|
73 | var_file.write(str(self.var_n_discs)) #8 | |
|
84 | 74 | var_file.close() |
|
85 | 75 | |
|
86 | 76 | |
|
87 | 77 | def get_parameters_conf(self): |
|
88 | 78 | var_file = open("parameters.conf","r") |
|
89 | 79 | lines = var_file.readlines() |
|
90 | ||
|
91 | 80 | self.txtDpath.setText(lines[0][:-1]) #0 |
|
92 | 81 | self.txtRpath.setText(lines[1][:-1]) #1 |
|
93 | 82 | self.lstDtype.setCurrentIndex(int(lines[2])) #2 |
|
94 | 83 | self.txtDtype.setText(lines[3][:-1]) #3 |
|
95 | 84 | self.txtElabel.setText(lines[4][:-1]) #4 |
|
96 | 85 | self.txtCopys.setValue(int(lines[5][:-1])) #5 |
|
97 | 86 | self.lstDcapacity.setCurrentIndex(int(lines[6])) #6 |
|
98 | self.txtDcapacity.setValue(float(lines[7])) | |
|
99 | ||
|
87 | self.txtDcapacity.setValue(float(lines[7])) #7 | |
|
88 | self.var_n_discs = int(lines[8]) # 8 | |
|
100 | 89 | var_file.close() |
|
101 | 90 | |
|
91 | ||
|
102 | 92 | def set_vars(self): |
|
103 | self.var_Dpath = self.txtDpath.text() | |
|
104 | self.var_Rpath = self.txtRpath.text() | |
|
105 | self.var_lstDtype = self.lstDtype.currentIndex() | |
|
106 | self.var_Dtype = self.txtDtype.text() | |
|
107 | self.var_Elabel = self.txtElabel.text() | |
|
108 | self.var_Copys = self.txtCopys.value() | |
|
109 | self.var_lstDcapacity = self.lstDcapacity.currentIndex() | |
|
110 |
self.var_Dcapacity = self.txtDcapacity.value() |
|
|
111 | ||
|
93 | self.var_Dpath = self.txtDpath.text() #0 | |
|
94 | self.var_Rpath = self.txtRpath.text() #1 | |
|
95 | self.var_lstDtype = self.lstDtype.currentIndex() #2 | |
|
96 | self.var_Dtype = self.txtDtype.text() #3 | |
|
97 | self.var_Elabel = self.txtElabel.text() #4 | |
|
98 | self.var_Copys = self.txtCopys.value() #5 | |
|
99 | self.var_lstDcapacity = self.lstDcapacity.currentIndex() #6 | |
|
100 | self.var_Dcapacity = self.txtDcapacity.value() #7 | |
|
101 | ||
|
102 | ||
|
103 | def enabled_items1(var_bool, self): | |
|
104 | self.tabParameters.setEnabled(not(var_bool)) | |
|
105 | self.lstDcapacity.setEnabled(not(var_bool)) | |
|
106 | self.txtDcapacity.setEnabled(not(var_bool)) | |
|
107 | self.btnGbkp.setEnabled(not(var_bool)) | |
|
108 | self.btnRestart.setEnabled(var_bool) | |
|
109 | self.btnStartburn.setEnabled(var_bool) | |
|
110 | ||
|
111 | ||
|
112 | def enabled_items2(var_bool, self): | |
|
113 | self.btnRestart.setEnabled(not(var_bool)) | |
|
114 | self.btnStartburn.setEnabled(not(var_bool)) | |
|
115 | self.btnStopburn.setEnabled(var_bool) |
@@ -1,354 +1,344 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | """ |
|
4 | 4 | Module implementing MainWindow. |
|
5 | 5 | """ |
|
6 | 6 | |
|
7 | 7 | from PyQt4.QtGui import QMainWindow |
|
8 | 8 | from PyQt4.QtCore import pyqtSignature |
|
9 | 9 | from PyQt4 import QtCore |
|
10 | 10 | from Ui_MainWindow import Ui_MainWindow |
|
11 | 11 | from PyQt4 import QtGui |
|
12 | 12 | from subprocess import * |
|
13 | 13 | import sys |
|
14 | 14 | import os |
|
15 | import subprocess | |
|
15 | #import subprocess | |
|
16 | 16 | import commands |
|
17 | 17 | from functions import functions |
|
18 | 18 | from functions import functions2 |
|
19 | 19 | |
|
20 | 20 | class MainWindow(QMainWindow, Ui_MainWindow): |
|
21 | 21 | """ |
|
22 | 22 | Class documentation goes here. |
|
23 | 23 | """ |
|
24 | 24 | |
|
25 | 25 | def __init__(self, parent = None): |
|
26 | 26 | QMainWindow.__init__(self, parent) |
|
27 | 27 | self.setupUi(self) |
|
28 | 28 | self.setupUi2() |
|
29 | 29 | #sys.stdout = self #redirige salida estandar |
|
30 | 30 | |
|
31 | 31 | def setupUi2(self): |
|
32 | 32 | |
|
33 | 33 | functions2.detect_devices(self) #busca los dispositivos de grabacion |
|
34 | 34 | |
|
35 | self.var_n_discs=0 | |
|
36 | self.var_list=[] | |
|
37 | self.var_sublist=[] | |
|
38 | ||
|
35 | 39 | #Revisa si existe el archivo de confirguracion |
|
36 | 40 | if os.path.isfile("parameters.conf"): |
|
37 | 41 | self.txtInfo.append("Archivo de configuracion encontrado") |
|
38 | 42 | functions2.get_parameters_conf(self) |
|
43 | self.txtInfo.append("El proyecto creara "+str(self.var_n_discs)+" DVDs") | |
|
39 | 44 | else: |
|
40 | 45 | self.txtInfo.append("Elija los parametros de configuracion") |
|
41 | functions2.set_parameters(self) #Establece ciertos parametros, para pruebas | |
|
46 | functions2.set_parameters_test(self) #Establece ciertos parametros, para pruebas | |
|
42 | 47 | |
|
43 | 48 | functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados |
|
44 | 49 | |
|
45 | 50 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
46 | 51 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
47 | ||
|
48 | self.var_n_discs=0 | |
|
49 | self.var_list=[] | |
|
50 | self.var_sublist=[] | |
|
51 | ||
|
52 | 52 | functions.load_days(self) |
|
53 | 53 | |
|
54 | 54 | self.var_process = QtCore.QProcess() |
|
55 | 55 | self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput) |
|
56 | 56 | self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardError()'), self.readError) |
|
57 | 57 | self.connect(self.var_process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished) |
|
58 | 58 | |
|
59 | ||
|
60 | def write(self, txt): | |
|
61 | self.txtInfo.append(str(txt)) | |
|
62 | ||
|
63 | ||
|
64 | #----------------------------------------------------- Funciones del proceso --------------------------------------------------------------- | |
|
65 | ||
|
59 | 66 | def readOuput(self): |
|
60 | 67 | self.txtSburn.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput())) |
|
61 | 68 | |
|
62 | ||
|
63 | 69 | def readError(self): |
|
64 | 70 | self.txtSburn.insertPlainText("stderr: " + QtCore.QString(self.var_process.readAllStandardError())) |
|
65 | 71 | |
|
66 | ||
|
67 | 72 | def finished(self): |
|
68 | self.txtInfo.append("proceso terminado finished()") | |
|
69 | print self.var_process.exitCode() | |
|
70 | ||
|
71 | ||
|
72 | def write(self, txt): | |
|
73 | self.txtInfo.append(str(txt)) | |
|
73 | self.txtInfo.append("proceso terminado finished() "+QtCore.QString(self.var_process.exitCode())) | |
|
74 | ||
|
74 | 75 | |
|
75 | 76 | #----------------------------------------------------- Obtencion de las ruta de los datos --------------------------------------------------------------- |
|
76 | 77 | |
|
77 | 78 | @pyqtSignature("") |
|
78 | 79 | def on_btnDpath_clicked(self): |
|
79 | 80 | """ |
|
80 | 81 | Permite seleccionar graficamente el direcorio de los datos a grabar |
|
81 | 82 | """ |
|
82 | 83 | self.var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) |
|
83 | 84 | self.txtDpath.setText(self.var_Dpath) |
|
84 | 85 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
85 | 86 | functions.load_days(self) |
|
86 | 87 | |
|
87 | 88 | |
|
88 | 89 | @pyqtSignature("") |
|
89 | 90 | def on_txtDpath_editingFinished(self): |
|
90 | 91 | """ |
|
91 | 92 | Carga la ruta editada y verifica que sea correcta y carga la lista de dias |
|
92 | 93 | """ |
|
93 | 94 | self.var_Dpath=self.txtDpath.text() #Se carga la variable con la ruta recien editada |
|
94 | 95 | self.statusDpath = functions.dir_exists(self.var_Dpath, self) |
|
95 | 96 | functions.load_days(self) |
|
96 | 97 | |
|
97 | 98 | |
|
98 | 99 | #----------------------------------------------------- Obtencion de las ruta del proyecto --------------------------------------------------------------- |
|
99 | 100 | |
|
100 | 101 | @pyqtSignature("") |
|
101 | 102 | def on_btnRpath_clicked(self): |
|
102 | 103 | """ |
|
103 | 104 | Permite seleccionar graficamente el direcorio del proyecto |
|
104 | 105 | """ |
|
105 | 106 | self.var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) |
|
106 | 107 | self.txtRpath.setText(self.var_Rpath) |
|
107 | 108 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
108 | 109 | |
|
109 | 110 | |
|
110 | 111 | @pyqtSignature("") |
|
111 | 112 | def on_txtRpath_editingFinished(self): |
|
112 | 113 | """ |
|
113 | 114 | Valida la ruta del proyecto |
|
114 | 115 | """ |
|
115 | 116 | self.var_Rpath=self.txtRpath.text() #Se carga la variable con la ruta recien editada |
|
116 | 117 | self.statusRpath = functions.dir_exists(self.var_Rpath, self) |
|
117 | 118 | |
|
118 | 119 | |
|
119 | 120 | #----------------------------------------------------- Tipo de datos --------------------------------------------------------------- |
|
120 | 121 | |
|
121 | 122 | @pyqtSignature("int") |
|
122 | 123 | def on_lstDtype_activated(self, index): |
|
123 | 124 | """ |
|
124 | 125 | Permite elegir entre los tipos de archivos |
|
125 | 126 | """ |
|
126 | 127 | self.txtDtype.setReadOnly(True) |
|
127 | 128 | if index == 0: |
|
128 | 129 | self.var_Dtype ='r' |
|
129 | 130 | elif index == 1: |
|
130 | 131 | self.var_Dtype ='pdata' |
|
131 | 132 | elif index == 2: |
|
132 | 133 | self.var_Dtype ='sswma' |
|
133 | 134 | else : |
|
134 | 135 | self.var_Dtype ='' |
|
135 | 136 | self.txtDtype.setReadOnly(False) |
|
136 | 137 | |
|
137 | 138 | self.txtDtype.setText(self.var_Dtype) |
|
138 | 139 | functions.load_days(self) #llamada a funcion |
|
139 | 140 | |
|
140 | 141 | @pyqtSignature("") |
|
141 | 142 | def on_txtDtype_editingFinished(self): |
|
142 | 143 | self.var_Dtype=self.txtDtype.text() |
|
143 | 144 | functions.load_days(self) #llamada a funcion |
|
144 | 145 | |
|
145 | 146 | |
|
146 | 147 | #----------------------------------------------------- Etiqueta --------------------------------------------------------------- |
|
147 | 148 | |
|
148 | 149 | @pyqtSignature("") |
|
149 | 150 | def on_txtElabel_editingFinished(self): |
|
150 | 151 | self.var_Elabel = self.txtElabel.text() |
|
151 | 152 | |
|
152 | 153 | #----------------------------------------------------- Numero de copias --------------------------------------------------------------- |
|
153 | 154 | @pyqtSignature("") |
|
154 | 155 | def on_txtCopys_editingFinished(self): |
|
155 | 156 | self.var_Copys = self.txtCopys.value() |
|
156 | 157 | |
|
157 | 158 | #----------------------------------------------------- Seleccion del rango de fechas --------------------------------------------------------------- |
|
158 | 159 | |
|
159 | 160 | @pyqtSignature("int") #CLOSED |
|
160 | 161 | def on_lstStartDay_activated(self, index): |
|
161 | 162 | """ |
|
162 | 163 | Cambia la lista de opciones en lstStopDay |
|
163 | 164 | """ |
|
164 | 165 | var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex() |
|
165 | 166 | self.lstStopDay.clear() |
|
166 | 167 | |
|
167 | 168 | for i in self.var_list[index:]: |
|
168 | 169 | self.lstStopDay.addItem(i) |
|
169 | 170 | |
|
170 | 171 | self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index) |
|
171 | 172 | |
|
172 | 173 | functions.get_sub_list(self) |
|
173 | 174 | |
|
174 | 175 | |
|
175 | 176 | @pyqtSignature("int") #CLOSED |
|
176 | 177 | def on_lstStopDay_activated(self, index): |
|
177 | 178 | """ |
|
178 | 179 | Cambia la lista de opciones en lstStartDay |
|
179 | 180 | """ |
|
180 | 181 | var_StartDay_index=self.lstStartDay.currentIndex() |
|
181 | 182 | var_end_index = self.lstStopDay.count() - index |
|
182 | 183 | self.lstStartDay.clear() |
|
183 | 184 | |
|
184 | 185 | for i in self.var_list[:len(self.var_list) - var_end_index + 1]: |
|
185 | 186 | self.lstStartDay.addItem(i) |
|
186 | 187 | |
|
187 | 188 | self.lstStartDay.setCurrentIndex(var_StartDay_index) |
|
188 | 189 | |
|
189 | 190 | functions.get_sub_list(self) |
|
190 | 191 | |
|
191 | 192 | |
|
192 | 193 | #----------------------------------------------------- Capacidad del dispositivo de grabacion --------------------------------------------------------------- |
|
193 | 194 | |
|
194 | 195 | @pyqtSignature("") |
|
195 | 196 | def on_txtDcapacity_editingFinished(self): |
|
196 | 197 | self.var_Dcapacity = self.txtDcapacity.value() |
|
197 | 198 | |
|
198 | 199 | |
|
199 | 200 | @pyqtSignature("int") #CLOSED |
|
200 | 201 | def on_lstDcapacity_activated(self, index): |
|
201 | 202 | """ |
|
202 | 203 | Permite elegir el tamaΓ±o del disco |
|
203 | 204 | """ |
|
204 | 205 | if index == 0: |
|
205 | 206 | var_size=25.0 |
|
206 | 207 | elif index == 1: |
|
207 | 208 | var_size=8.5 |
|
208 | 209 | elif index == 2: |
|
209 | 210 | var_size=4.7 |
|
210 | 211 | elif index == 3: |
|
211 | 212 | var_size=0.7 |
|
212 | 213 | |
|
213 | 214 | if index != 4: |
|
214 | 215 | self.txtDcapacity.setValue(var_size*10**9/1024**2) |
|
215 | 216 | self.txtDcapacity.setReadOnly(True) |
|
216 | 217 | else: |
|
217 | 218 | self.txtDcapacity.setValue(100.0) |
|
218 | 219 | self.txtDcapacity.setReadOnly(False) |
|
219 | 220 | |
|
220 | 221 | self.var_Dcapacity = self.txtDcapacity.value() |
|
221 | 222 | |
|
222 | 223 | |
|
223 | 224 | #============================================================================== |
|
224 | 225 | # Botones para la generacion de los archivos de configuracion y el proceso de grabacion |
|
225 | 226 | #============================================================================== |
|
226 | 227 | |
|
227 | 228 | #----------------------------------------------------- Generacion de la configuracion usando los parametros --------------------------------------------------------------- |
|
228 | 229 | |
|
229 | 230 | @pyqtSignature("") |
|
230 | 231 | def on_btnGbkp_clicked(self): |
|
231 | 232 | """ |
|
232 | 233 | Generacion de archivos de configuracion usando los parametros |
|
233 | 234 | """ |
|
234 | 235 | |
|
235 | 236 | if functions.validate_parameters(self) == False: |
|
236 | 237 | return |
|
237 | 238 | |
|
238 | 239 | #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente |
|
239 | 240 | list_dirs=['gpath','iso','ppath'] |
|
240 | 241 | bool_make_dirs = functions.make_dirs(list_dirs, self) |
|
241 | 242 | if bool_make_dirs == False: |
|
242 | 243 | return |
|
243 | 244 | |
|
244 | 245 | var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar |
|
245 | 246 | self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat |
|
246 | 247 | functions.make_files_print(self) # Se crean los archivos .print |
|
247 | 248 | functions2.make_parameters_conf(self) # se crea el archivo parameters.conf |
|
248 | 249 | |
|
249 | 250 | #Se bloquean los parametros de configuracion |
|
250 | 251 | functions2.enabled_items1(True, self) |
|
251 | 252 | |
|
252 | 253 | |
|
253 | 254 | #----------------------------------------------------- Permite reiniciar la configuracion --------------------------------------------------------------- |
|
254 | 255 | |
|
255 | 256 | @pyqtSignature("") |
|
256 | 257 | def on_btnRestart_clicked(self): |
|
257 | 258 | """ |
|
258 | 259 | Permite que se puedan cambiar los parametros |
|
259 | 260 | """ |
|
260 | 261 | functions2.enabled_items1(False, self) |
|
261 | 262 | os.remove("parameters.conf") |
|
262 | 263 | |
|
263 | 264 | |
|
264 | 265 | #----------------------------------------------------- Iniciar proceso de grabacion --------------------------------------------------------------- |
|
265 | 266 | |
|
266 | 267 | @pyqtSignature("") |
|
267 | 268 | def on_btnStartburn_clicked(self): |
|
268 | 269 | """ |
|
269 | 270 | Se inicia el proceso de grabacion |
|
270 | 271 | """ |
|
271 | self.btnRestart.setEnabled(False) | |
|
272 | self.btnStartburn.setEnabled(False) | |
|
273 | self.btnStopburn.setEnabled(True) | |
|
272 | functions2.enabled_items2(True, self) | |
|
274 | 273 | |
|
275 | 274 | sys.stdout = self |
|
276 | 275 | #sys.stderr = self |
|
277 | 276 | print "stdout_!!!" |
|
278 | 277 | |
|
278 | ||
|
279 | ||
|
279 | 280 | #Inicializando variables |
|
280 | 281 | var_Rpath_ppath=self.var_Rpath+"/ppath" |
|
281 | 282 | var_Rpath_iso=self.var_Rpath+"/iso" |
|
282 | 283 | |
|
283 | 284 | var_n=1 |
|
284 | 285 | file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso" |
|
285 | 286 | file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat" |
|
286 | 287 | |
|
287 | 288 | var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r ' |
|
288 | 289 | var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel |
|
289 | 290 | var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso |
|
290 | 291 | |
|
291 | # self.process.start(var_cmd) | |
|
292 | 292 | self.var_process.start(var_cmd) |
|
293 | # self.var_process.waitForFinished() | |
|
294 | 293 | self.txtInfo.append("ejecutandose") |
|
295 | 294 | |
|
296 | 295 | |
|
297 | 296 | # # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps |
|
298 | 297 | # for var_n in range(1, self.var_n_discs+1): |
|
299 | 298 | # self.txtInfo.append(str(var_n)) |
|
300 | 299 | # file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso" |
|
301 | 300 | # file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat" |
|
302 | 301 | # |
|
303 | 302 | # var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r ' |
|
304 | 303 | # var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel |
|
305 | 304 | # var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso |
|
306 | 305 | # self.txtInfo.append(var_cmd) |
|
307 | 306 | # |
|
308 | # var_output=commands.getstatusoutput(str(var_cmd))[0] | |
|
309 | # self.txtInfo.append(str(var_output)) | |
|
310 | ||
|
311 | #os.system(str(var_cmd)) | |
|
312 | #p = subprocess.Popen(str('ls /'), shell=True, stdout=self) | |
|
313 | #os.waitpid(p.pid, 0) | |
|
314 | ####self.txtInfo.append(str(p.pid)) | |
|
315 | 307 | |
|
316 | 308 | |
|
317 | 309 | #----------------------------------------------------- Detener proceso de grabacion --------------------------------------------------------------- |
|
318 | 310 | |
|
319 | 311 | @pyqtSignature("") |
|
320 | 312 | def on_btnStopburn_clicked(self): |
|
321 | 313 | """ |
|
322 | 314 | Slot documentation goes here. |
|
323 | 315 | """ |
|
324 | self.var_process.terminate() | |
|
325 | self.btnRestart.setEnabled(True) | |
|
326 | self.btnStartburn.setEnabled(True) | |
|
327 | self.btnStopburn.setEnabled(False) | |
|
316 | self.var_process.terminate() #Termina el proceso, si puede | |
|
317 | functions2.enabled_items2(False, self) | |
|
328 | 318 | |
|
329 | 319 | |
|
330 | 320 | #----------------------------------------------------- Testeo de las unidades de grabacion --------------------------------------------------------------- |
|
331 | 321 | |
|
332 | 322 | @pyqtSignature("") |
|
333 | 323 | def on_btnTdevA_clicked(self): |
|
334 | 324 | var_dev = str(self.txtDeviceA.text()) |
|
335 | 325 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
336 | 326 | commands.getstatusoutput(var_cmd) |
|
337 | 327 | |
|
338 | 328 | @pyqtSignature("") |
|
339 | 329 | def on_btnTdevB_clicked(self): |
|
340 | 330 | var_dev = str(self.txtDeviceB.text()) |
|
341 | 331 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
342 | 332 | commands.getstatusoutput(var_cmd) |
|
343 | 333 | |
|
344 | 334 | @pyqtSignature("") |
|
345 | 335 | def on_btnTdevC_clicked(self): |
|
346 | 336 | var_dev = str(self.txtDeviceC.text()) |
|
347 | 337 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
348 | 338 | commands.getstatusoutput(var_cmd) |
|
349 | 339 | |
|
350 | 340 | @pyqtSignature("") |
|
351 | 341 | def on_btnTdevD_clicked(self): |
|
352 | 342 | var_dev = str(self.txtDeviceD.text()) |
|
353 | 343 | var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev |
|
354 | 344 | commands.getstatusoutput(var_cmd) |
General Comments 0
You need to be logged in to leave comments.
Login now