##// END OF EJS Templates
funciones ok, botones ok...
ralonso -
r46:47
parent child
Show More
@@ -19,16 +19,15
19 19
20 20
21 21 #Crea directorios en la ruta indicada
22 def make_dirs(var_path, list_dirs, self):
23 var_cmd="mkdir -p "+str(var_path)
22 def make_dirs(list_dirs, self):
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 print var_cmd+'/'+var_dir
27 26 if var_output != 0:
28 27 self.txtInfo.append("Error al crear el directorio "+var_dir+", output_error:" + str(var_output))
29 return
30 else:
31 self.txtInfo.append('Carpetas creadas correctamente')
28 return False
29 self.txtInfo.append('Carpetas creadas correctamente')
30 return True
32 31
33 32
34 33 #Se verifica que la ruta exista y sea un directorio
@@ -72,6 +71,7
72 71 self.lstStopDay.addItem(i)
73 72 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
74 73
74 get_sub_list(self)
75 75 self.btnGbkp.setEnabled(True)
76 76
77 77
@@ -90,6 +90,7
90 90 return True
91 91
92 92
93 #Obtiene el rango de las fechas seleccionadas
93 94 def get_sub_list(self):
94 95 self.var_sublist=[]
95 96 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
@@ -98,3 +99,115
98 99 self.txtInfo.append("No existen archivos encontrados")
99 100
100 101
102 #Busca los archivos con los parametros de busqueda
103 def list_files(self):
104 var_files_list=[]
105 for var_doy in self.var_sublist:
106 var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort"
107 var_output=commands.getstatusoutput(var_cmd)[1]
108 for var_file in var_output.split():
109 var_files_list.append(var_file) #Almacena cada archivo en la lista
110 return var_files_list
111
112
113 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
114 def make_files_dat(var_files_list, self):
115 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
116 var_n=1 #Numero del DVD actual
117 var_tmp=0 #Se usa para acumular el tamaño de los archivos de la lista
118 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
119
120 for i in var_files_list: #Se asignan en i los archivos de la lista
121 self.txtInfo.append(i)
122 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
123 var_tmp += var_size_i #Se acumulan el tamaño de los archivos de la lista
124
125 #Si el tamaño acumulado es mayor que el de el DVD
126 if var_tmp > self.var_Dcapacity:
127 var_tmp -= var_size_i #se quita el tamaño sumado para mostrar el tamaño real
128 #se crea un archivo con numeral en el sufijo y extension .dat
129 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
130 #Se añade la lista de archivos a grabar en el DVD al archivo .dat
131 for line in var_files_list_2:
132 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
133 var_tmp_path2="/"
134 for l in range(0, len(var_tmp_path)-1):
135 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
136 var_file.write(var_tmp_path2+'=')
137 var_file.write(line+'\n')
138 var_file.close()
139
140 var_tmp = var_size_i #Se asigna a la variable el tamaño del archivo actual
141 var_files_list_2=[] #Se reinicia la lista
142 var_n += 1
143 var_files_list_2.append(i)
144
145 #se crea un archivo con numeral en el sufijo y extension .dat
146 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
147 #Se añade la lista de archivos a grabar en el DVD al archivo .dat
148 for line in var_files_list_2:
149 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
150 var_tmp_path2="/"
151 for l in range(0, len(var_tmp_path)-1):
152 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
153 var_file.write(var_tmp_path2+'=')
154 var_file.write(line+'\n')
155 var_file.close()
156
157 return var_n
158
159
160 #Genera los archivos .print con los cuales se creara los postscript
161 def make_files_print(self):
162
163 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
164
165 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print
166 for var_n in range(1, self.var_n_discs + 1):
167 #se abren los archivos .dat en modo lectura
168 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r")
169 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
170 # Se crea el archivo .print
171 var_file_print = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".print","w")
172 var_file_print.write(self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_n_discs)+"\n")
173 var_file_print.write("Year Doy Folder Set Time range\n")
174
175 var_first_folder = lines[0].split('=')[0]
176 var_first_file = (lines[0].split('=')[1])[:-1]
177 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
178
179 for j in range(1, len(lines)-1):
180 var_tmp_folder = lines[j].split('=')[0]
181 var_tmp_file = (lines[j].split('=')[1])[:-1]
182
183 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
184 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
185 var_last_file = (lines[j-1].split('=')[1])[:-1]
186 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
187 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
188 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
189 if var_first_folder == '/':
190 var_folder = self.var_Elabel
191 else:
192 var_folder = var_first_folder.split('/')[1]
193
194 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
195 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
196
197 var_first_folder = lines[j].split('=')[0]
198 var_first_file = (lines[j].split('=')[1])[:-1]
199 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
200
201 var_last_file = (lines[-1].split('=')[1])[:-1]
202 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
203
204 if var_first_folder == '/':
205 var_folder = self.txtElabel.text()
206 else:
207 var_folder = var_first_folder.split('/')[1]
208
209 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
210 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
211
212 var_file.close()
213 var_file_print.close()
@@ -19,7 +19,9
19 19 self.txtElabel.setText('EW_DRIFTS')
20 20 self.statusDpath = True
21 21 self.statusRpath = True
22 self.var_n_files=0
22 self.lstDcapacity.setCurrentIndex(4)
23 self.txtDcapacity.setValue(100.0)
24 self.txtDcapacity.setReadOnly(False)
23 25
24 26
25 27 def detect_devices(self):
@@ -1,7 +1,7
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE Project SYSTEM "Project-4.6.dtd">
3 3 <!-- eric4 project file for project jro_backup_manager -->
4 <!-- Saved: 2010-05-16, 23:51:59 -->
4 <!-- Saved: 2010-05-17, 12:04:38 -->
5 5 <!-- Copyright (C) 2010 , -->
6 6 <Project version="4.6">
7 7 <Language>en</Language>
@@ -32,7 +32,6
32 32 <Interfaces>
33 33 </Interfaces>
34 34 <Others>
35 <Other>functions/doc_tmp.txt</Other>
36 35 </Others>
37 36 <MainScript>main.py</MainScript>
38 37 <Vcs>
@@ -29,21 +29,22
29 29
30 30 def setupUi2(self):
31 31
32 self.statusDpath = False
33 self.statusRpath = False
34
35 functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
36
32 37 self.var_Dpath = self.txtDpath.text()
33 38 self.var_Rpath = self.txtRpath.text()
34 self.statusDpath = False
35 self.statusRpath = False
36
37 39 self.var_Dtype = self.txtDtype.text()
38 40 self.var_Elabel = self.txtElabel.text()
39 41 self.var_Copys = self.txtCopys.value()
40 42 self.var_Dcapacity = self.txtDcapacity.value() * 1024
41 43
42 self.var_n_files=0
44 self.var_n_discs=0
43 45 self.var_list=[]
44 46 self.var_sublist=[]
45
46 functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
47
47 48 functions2.detect_devices(self) #busca los dispositivos de grabacion
48 49
49 50
@@ -109,7 +110,9
109 110 if index != 3:
110 111 self.txtDtype.setText(var_type)
111 112 self.txtDtype.setReadOnly(True)
113 self.var_Dtype=self.txtDtype.text()
112 114 functions.load_days(self)
115
113 116 else:
114 117 self.txtDtype.setText('')
115 118 self.txtDtype.setReadOnly(False)
@@ -133,7 +136,7
133 136
134 137 @pyqtSignature("")
135 138 def on_txtDcapacity_editingFinished(self):
136 self.var_Dcapacity = self.txtDcapacity.value() * 1024
139 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaño en KB
137 140
138 141
139 142 @pyqtSignature("int") #CLOSED
@@ -189,7 +192,9
189 192 else:
190 193 self.txtDcapacity.setValue(100.0)
191 194 self.txtDcapacity.setReadOnly(False)
192
195
196 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaño en KB
197
193 198
194 199 @pyqtSignature("")
195 200 def on_btnGbkp_clicked(self):
@@ -201,124 +206,15
201 206 return
202 207
203 208 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
204 list_dirs=['gpath', 'iso', 'ppath']
205 functions.make_dirs(self.var_Rpath, list_dirs, self)
206
207 #Cargando variables con los parametros
208 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
209
210 #Busca los archivos con los parametros de busqueda
211 var_files_list=[]
212 for var_doy in var_sublist:
213 var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort"
214 var_output=commands.getstatusoutput(var_cmd)[1]
215 for var_file in var_output.split():
216 var_files_list.append(var_file) #Almacena cada archivo en la lista
217
218 #
219 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
220 #
221 var_n=0 #Numero del DVD actual
222 var_tmp=0 #Se usa para acumulanr el tamaño de los archivos de la lista
223 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
224
225 for i in var_files_list: #Se asignan en i los archivos de la lista
226 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
227 var_tmp += var_size_i #Se acumulan el tamaño de los archivos de la lista
228
229 #Si el tamaño acumulado es mayor que el de el DVD
230 if var_tmp > self.var_Dcapacity:
231 var_tmp -= var_size_i #se quita el tamaño sumado para mostrar el tamaño real
232 #se crea un archivo con numeral en el sufijo y extension .dat
233 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+functions.i2s(var_n)+".dat","w")
234 #Se añade la lista de archivos a grabar en el DVD al archivo .dat
235 for line in var_files_list_2:
236 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
237 var_tmp_path2="/"
238 for l in range(0, len(var_tmp_path)-1):
239 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
240 var_file.write(var_tmp_path2+'=')
241 var_file.write(line+'\n')
242 var_file.close()
243
244 var_tmp = var_size_i #Se asigna a la variable el tamaño del archivo actual
245 var_files_list_2=[] #Se reinicia la lista
246 var_n += 1
247 var_files_list_2.append(i)
248
249 #se crea un archivo con numeral en el sufijo y extension .dat
250 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+functions.i2s(var_n)+".dat","w")
251 #Se añade la lista de archivos a grabar en el DVD al archivo .dat
252 for line in var_files_list_2:
253 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
254 var_tmp_path2="/"
255 for l in range(0, len(var_tmp_path)-1):
256 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
257 var_file.write(var_tmp_path2+'=')
258 var_file.write(line+'\n')
259 var_file.close()
260
261 #
262 #Genera los archivos .print con los cuales se creara los postscript
263 #
264 self.var_n_files = var_n # Numero del ultimo archivo .dat creado
265 var_n = 0 # Se reinicia a cero y se usa para poder acceder a cada una de los archivos
266
267 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
268 for var_n in range(0, self.var_n_files+1):
269 print var_n
270
271 #se abren los archivos .dat en modo lectura
272 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+functions.i2s(var_n)+".dat","r")
273 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
274
275 # Se crea el archivo .print
276 var_file_print = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+functions.i2s(var_n)+".print","w")
277 var_file_print.write(self.txtElabel.text()+" "+functions.i2s(var_n)+"/"+str(self.var_n_files)+"\n")
278 var_file_print.write("Year Doy Folder Set Time range\n")
279
280 #Se crean los archivos .print con los cuales se crearan los archivos .ps
281 var_first_folder = lines[0].split('=')[0]
282 var_first_file = (lines[0].split('=')[1])[:-1]
283 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
284
285 for j in range(1, len(lines)-1):
286 var_tmp_folder = lines[j].split('=')[0]
287 var_tmp_file = (lines[j].split('=')[1])[:-1]
288
289 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
290 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
291
292 var_last_file = (lines[j-1].split('=')[1])[:-1]
293 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
294 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
295 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
296 if var_first_folder == '/':
297 var_folder = self.txtElabel.text()
298 else:
299 var_folder = var_first_folder.split('/')[1]
300
301 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
302 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
303
304 var_first_folder = lines[j].split('=')[0]
305 var_first_file = (lines[j].split('=')[1])[:-1]
306 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
307
308 var_last_file = (lines[-1].split('=')[1])[:-1]
309 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
310
311 if var_first_folder == '/':
312 var_folder = self.txtElabel.text()
313 else:
314 var_folder = var_first_folder.split('/')[1]
315
316 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
317 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
318
319 var_file.close()
320 var_file_print.close()
321
209 list_dirs=['gpath','iso','ppath']
210 bool_make_dirs = functions.make_dirs(list_dirs, self)
211 if bool_make_dirs == False:
212 return
213
214 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
215 self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
216
217 functions.make_files_print(self) # Se crean los archivos .print
322 218
323 219 #Se deshabilita el Tab Parameters y el boton btnGbkp
324 220 self.tabParameters.setEnabled(False)
@@ -326,18 +222,20
326 222 self.txtDcapacity.setEnabled(False)
327 223 self.btnGbkp.setEnabled(False)
328 224 self.btnRestart.setEnabled(True)
225 self.btnStartburn.setEnabled(True)
329 226
330 227
331 228 @pyqtSignature("")
332 229 def on_btnRestart_clicked(self):
333 230 """
334 Slot documentation goes here.
231 Permite que se puedan cambiar los parametros
335 232 """
336 233 self.tabParameters.setEnabled(True)
337 234 self.lstDcapacity.setEnabled(True)
338 235 self.txtDcapacity.setEnabled(True)
339 236 self.btnGbkp.setEnabled(True)
340 237 self.btnRestart.setEnabled(False)
238 self.btnStartburn.setEnabled(False)
341 239
342 240
343 241 @pyqtSignature("")
@@ -345,6 +243,12
345 243 """
346 244 Se inicia el proceso de grabacion
347 245 """
246 self.btnRestart.setEnabled(False)
247 self.btnStartburn.setEnabled(False)
248 self.btnStopburn.setEnabled(True)
249
250 return
251
348 252 sys.stdout = self
349 253 #sys.stderr = self
350 254 print "stdout_!!!"
@@ -356,7 +260,7
356 260 var_label=self.txtElabel.text()
357 261
358 262 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
359 for var_n in range(0, self.var_n_files+1):
263 for var_n in range(0, self.var_n_discs+1):
360 264 print var_n
361 265
362 266 file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
@@ -381,9 +285,9
381 285 """
382 286 Slot documentation goes here.
383 287 """
384 # TODO: not implemented yet
385 raise NotImplementedError
386
288 self.btnRestart.setEnabled(True)
289 self.btnStartburn.setEnabled(True)
290 self.btnStopburn.setEnabled(False)
387 291
388 292 @pyqtSignature("")
389 293 def on_btnTdevA_clicked(self):
@@ -6,7 +6,7
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 <width>754</width>
9 <width>806</width>
10 10 <height>737</height>
11 11 </rect>
12 12 </property>
@@ -780,8 +780,8
780 780 <rect>
781 781 <x>0</x>
782 782 <y>0</y>
783 <width>754</width>
784 <height>21</height>
783 <width>806</width>
784 <height>25</height>
785 785 </rect>
786 786 </property>
787 787 <widget class="QMenu" name="menuFile">
General Comments 0
You need to be logged in to leave comments. Login now