##// END OF EJS Templates
***
ralonso -
r38:39
parent child
Show More
@@ -1,514 +1,512
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 Ui_MainWindow import Ui_MainWindow
9 from Ui_MainWindow import Ui_MainWindow
10 from PyQt4 import QtGui
10 from PyQt4 import QtGui
11 from subprocess import *
11 from subprocess import *
12 import sys
12 import sys
13 import os
13 import os
14 import subprocess
14 import subprocess
15 import commands
15 import commands
16
16
17 class MainWindow(QMainWindow, Ui_MainWindow):
17 class MainWindow(QMainWindow, Ui_MainWindow):
18 """
18 """
19 Class documentation goes here.
19 Class documentation goes here.
20 """
20 """
21
21
22 def __init__(self, parent = None):
22 def __init__(self, parent = None):
23 QMainWindow.__init__(self, parent)
23 QMainWindow.__init__(self, parent)
24 self.setupUi(self)
24 self.setupUi(self)
25 self.setupUi2()
25 self.setupUi2()
26
26
27 #redirige salida estandar
27 #redirige salida estandar
28 sys.stdout = self
28 sys.stdout = self
29
29
30
30
31 def setupUi2(self):
31 def setupUi2(self):
32 """
32 """
33 Se usa para inicializar ciertos parametros para pruebas
33 Se usa para inicializar ciertos parametros para pruebas
34 """
34 """
35 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/Data/RAW_EXP/JASMET/')
35 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/Data/RAW_EXP/JASMET/')
36 self.txtRpath.setText('/home/ricardoar/optional/STORAGE/prueba1_jro_backup_manager/')
36 self.txtRpath.setText('/home/ricardoar/optional/STORAGE/prueba1_jro_backup_manager/')
37 self.txtElabel.setText('JASMET')
37 self.txtElabel.setText('JASMET')
38 self.statusDpath = True
38 self.statusDpath = True
39 self.statusRpath = True
39 self.statusRpath = True
40 self.var_n_files=0
40 self.var_n_files=0
41 # self.statusDpath = False
41 # self.statusDpath = False
42 # self.statusRpath = False
42 # self.statusRpath = False
43
43
44
44
45 #
45 #
46 #Deteccion de los dispositvos de grabacion
46 #Deteccion de los dispositvos de grabacion
47 #
47 #
48 #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ?
48 #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ?
49 var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'"
49 var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'"
50 var_output = commands.getstatusoutput(var_cmd)
50 var_output = commands.getstatusoutput(var_cmd)
51 if var_output[0] != 0:
51 if var_output[0] != 0:
52 self.txtInfo.setText("No se pudo encontrar los dispositivos de grabacion, output_error:" + str(var_output))
52 self.txtInfo.setText("No se pudo encontrar los dispositivos de grabacion, output_error:" + str(var_output))
53 else:
53 else:
54 self.txtInfo.append("dispositivos encontrados")
54 self.txtInfo.append("dispositivos encontrados")
55 var_devices = var_output[1].split('\n')
55 var_devices = var_output[1].split('\n')
56
56
57 var_tmp=[]
57 var_tmp=[]
58 for i in range(0, 4):
58 for i in range(0, 4):
59 if i < len(var_devices):
59 if i < len(var_devices):
60 var_len = len(var_devices[i])
60 var_len = len(var_devices[i])
61 var_tmp.append(var_devices[i][1:var_len - 1])
61 var_tmp.append(var_devices[i][1:var_len - 1])
62 else:
62 else:
63 var_tmp.append('')
63 var_tmp.append('')
64
64
65 #Se escriben los dispostivos correspodientes, si existen
65 #Se escriben los dispostivos correspodientes, si existen
66 self.txtDeviceA.setText(str(var_tmp[0]))
66 self.txtDeviceA.setText(str(var_tmp[0]))
67 self.txtDeviceB.setText(str(var_tmp[1]))
67 self.txtDeviceB.setText(str(var_tmp[1]))
68 self.txtDeviceC.setText(str(var_tmp[2]))
68 self.txtDeviceC.setText(str(var_tmp[2]))
69 self.txtDeviceD.setText(str(var_tmp[3]))
69 self.txtDeviceD.setText(str(var_tmp[3]))
70 #Se desactivan los que no existen
70 #Se desactivan los que no existen
71 if len(var_tmp[0]) == 0 :
71 if len(var_tmp[0]) == 0 :
72 self.chkDevA.setChecked(False)
72 self.chkDevA.setChecked(False)
73 self.chkDevA.setEnabled(False)
73 self.chkDevA.setEnabled(False)
74 if len(var_tmp[1]) == 0 :
74 if len(var_tmp[1]) == 0 :
75 self.chkDevB.setChecked(False)
75 self.chkDevB.setChecked(False)
76 self.chkDevB.setEnabled(False)
76 self.chkDevB.setEnabled(False)
77 if len(var_tmp[2]) == 0 :
77 if len(var_tmp[2]) == 0 :
78 self.chkDevC.setChecked(False)
78 self.chkDevC.setChecked(False)
79 self.chkDevC.setEnabled(False)
79 self.chkDevC.setEnabled(False)
80 if len(var_tmp[3]) == 0 :
80 if len(var_tmp[3]) == 0 :
81 self.chkDevD.setChecked(False)
81 self.chkDevD.setChecked(False)
82 self.chkDevD.setEnabled(False)
82 self.chkDevD.setEnabled(False)
83
83
84
84
85 def write(self, txt):
85 def write(self, txt):
86 """
86 """
87 Escribe la salida estandar eb txtInfo
87 Escribe la salida estandar eb txtInfo
88 """
88 """
89 self.txtInfo.append(str(txt))
89 self.txtInfo.append(str(txt))
90
90
91
91
92 @pyqtSignature("")
92 @pyqtSignature("")
93 def on_btnDpath_clicked(self):
93 def on_btnDpath_clicked(self):
94 """
94 """
95 Permite seleccionar graficamente el direcorio de los datos a grabar
95 Permite seleccionar graficamente el direcorio de los datos a grabar
96 """
96 """
97 var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
97 var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
98 self.txtDpath.setText(var_Dpath)
98 self.txtDpath.setText(var_Dpath)
99
99
100 #llamada a funcion
100 #llamada a funcion
101 self.on_txtDpath_editingFinished()
101 self.on_txtDpath_editingFinished()
102
102
103
103
104 @pyqtSignature("")
104 @pyqtSignature("")
105 def on_btnRpath_clicked(self):
105 def on_btnRpath_clicked(self):
106 """
106 """
107 Permite seleccionar graficamente el direcorio del proyecto
107 Permite seleccionar graficamente el direcorio del proyecto
108 """
108 """
109 var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
109 var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
110 self.txtRpath.setText(var_Rpath)
110 self.txtRpath.setText(var_Rpath)
111
111
112 #llamada a funcion
112 #llamada a funcion
113 self.on_txtRpath_editingFinished()
113 self.on_txtRpath_editingFinished()
114
114
115
115
116 @pyqtSignature("")
116 @pyqtSignature("")
117 def on_txtDpath_editingFinished(self):
117 def on_txtDpath_editingFinished(self):
118 """
118 """
119 Permite buscar los archivos de extension seleccionada en la ruta de de datos
119 Permite buscar los archivos de extension seleccionada en la ruta de de datos
120 y cargar los valores para el rango de tiempo a ser grabado
120 y cargar los valores para el rango de tiempo a ser grabado
121 """
121 """
122
122
123 #Usando el modulo "subprocess", eric4 pide seleccion del tipo de subproceso (padre o hijo)
123 #Usando el modulo "subprocess", eric4 pide seleccion del tipo de subproceso (padre o hijo)
124 #por ello se prefiere usar el modulo "commands"
124 #por ello se prefiere usar el modulo "commands"
125 #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE)
125 #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE)
126 #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE)
126 #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE)
127 #output_p2= p2.communicate()[0]
127 #output_p2= p2.communicate()[0]
128 #self.txtInfo.setText(output_p2)
128 #self.txtInfo.setText(output_p2)
129
129
130 #Se carga la variable con la ruta de datos
130 #Se carga la variable con la ruta de datos
131 var_Dpath=self.txtDpath.text()
131 var_Dpath=self.txtDpath.text()
132
132
133 #Se verifica que la ruta exista y sea un directorio
133 #Se verifica que la ruta exista y sea un directorio
134 var_cmd="test -d "+str(var_Dpath)
134 var_cmd="test -d "+str(var_Dpath)
135 var_output=commands.getstatusoutput(var_cmd)[0]
135 var_output=commands.getstatusoutput(var_cmd)[0]
136 if var_output != 0:
136 if var_output != 0:
137 self.statusDpath = False
137 self.statusDpath = False
138 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output))
138 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output))
139 return
139 return
140 else:
140 else:
141 self.statusDpath = True
141 self.statusDpath = True
142 self.txtInfo.append("Ruta valida, sin error:" + str(var_Dpath))
142 self.txtInfo.append("Ruta valida, sin error:" + str(var_Dpath))
143
143
144 #Se buscan los archivos del tipo especificado
144 #Se buscan los archivos del tipo especificado
145 var_Dtype=self.txtDtype.text()
145 var_Dtype=self.txtDtype.text()
146 var_cmd="find " + str(var_Dpath) + " -name *."+ str(var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
146 var_cmd="find " + str(var_Dpath) + " -name *."+ str(var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
147 output_p2=commands.getstatusoutput(var_cmd)[1]
147 output_p2=commands.getstatusoutput(var_cmd)[1]
148
148
149 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
149 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
150 self.var_list=[]
150 self.var_list=[]
151 for i in range(0, (len(output_p2)+1)/8):
151 for i in range(0, (len(output_p2)+1)/8):
152 self.var_list.append(output_p2[8*i:8*(i+1)-1])
152 self.var_list.append(output_p2[8*i:8*(i+1)-1])
153
153
154 self.lstStartDay.clear()
154 self.lstStartDay.clear()
155 self.lstStopDay.clear()
155 self.lstStopDay.clear()
156
156
157 for i in self.var_list:
157 for i in self.var_list:
158 self.lstStartDay.addItem(i)
158 self.lstStartDay.addItem(i)
159 self.lstStopDay.addItem(i)
159 self.lstStopDay.addItem(i)
160
160
161 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
161 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
162
162
163
163
164 @pyqtSignature("")
164 @pyqtSignature("")
165 def on_txtRpath_editingFinished(self):
165 def on_txtRpath_editingFinished(self):
166 """
166 """
167 Valida la ruta del proyecto
167 Valida la ruta del proyecto
168 """
168 """
169 #Se carga la variable con la ruta del proyecto
169 #Se carga la variable con la ruta del proyecto
170 var_Rpath=self.txtRpath.text()
170 var_Rpath=self.txtRpath.text()
171
171
172 #Se verifica que la ruta exista y sea un directorio
172 #Se verifica que la ruta exista y sea un directorio
173 var_cmd="test -d "+str(var_Rpath)
173 var_cmd="test -d "+str(var_Rpath)
174 var_output=commands.getstatusoutput(var_cmd)[0]
174 var_output=commands.getstatusoutput(var_cmd)[0]
175 if var_output != 0:
175 if var_output != 0:
176 self.statusRpath = False
176 self.statusRpath = False
177 self.txtInfo.append("Ruta no valida, output_error:" + str(var_output))
177 self.txtInfo.append("Ruta no valida, output_error:" + str(var_output))
178 return
178 return
179 else:
179 else:
180 self.statusRpath = True
180 self.statusRpath = True
181 self.txtInfo.append("Ruta valida, sin error:" + str(var_Rpath))
181 self.txtInfo.append("Ruta valida, sin error:" + str(var_Rpath))
182
182
183
183
184 @pyqtSignature("int")
184 @pyqtSignature("int")
185 def on_lstDtype_activated(self, index):
185 def on_lstDtype_activated(self, index):
186 """
186 """
187 Permite elegir entre los tipos de archivos
187 Permite elegir entre los tipos de archivos
188 """
188 """
189 if index == 0:
189 if index == 0:
190 var_type='r'
190 var_type='r'
191 elif index == 1:
191 elif index == 1:
192 var_type='pdata'
192 var_type='pdata'
193 elif index == 2:
193 elif index == 2:
194 var_type='sswma'
194 var_type='sswma'
195
195
196 if index != 3:
196 if index != 3:
197 self.txtDtype.setText(var_type)
197 self.txtDtype.setText(var_type)
198 self.txtDtype.setReadOnly(True)
198 self.txtDtype.setReadOnly(True)
199 self.on_txtDpath_editingFinished()
199 self.on_txtDpath_editingFinished()
200 else:
200 else:
201 self.txtDtype.setText('')
201 self.txtDtype.setText('')
202 self.txtDtype.setReadOnly(False)
202 self.txtDtype.setReadOnly(False)
203
203
204
204
205 @pyqtSignature("")
205 @pyqtSignature("")
206 def on_txtDtype_editingFinished(self):
206 def on_txtDtype_editingFinished(self):
207 """
207 """
208 Se activa cuando el tipo de archivo es ingresado manualmente
208 Se activa cuando el tipo de archivo es ingresado manualmente
209 """
209 """
210 #llamada a funcion
210 #llamada a funcion
211 self.on_txtDpath_editingFinished()
211 self.on_txtDpath_editingFinished()
212
212
213
213
214 @pyqtSignature("int") #CLOSED
214 @pyqtSignature("int") #CLOSED
215 def on_lstStartDay_activated(self, index):
215 def on_lstStartDay_activated(self, index):
216 """
216 """
217 Cambia la lista de opciones en lstStopDay
217 Cambia la lista de opciones en lstStopDay
218 """
218 """
219 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
219 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
220 self.lstStopDay.clear()
220 self.lstStopDay.clear()
221
221
222 for i in self.var_list[index:]:
222 for i in self.var_list[index:]:
223 self.lstStopDay.addItem(i)
223 self.lstStopDay.addItem(i)
224
224
225 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
225 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
226
226
227
227
228 @pyqtSignature("int") #CLOSED
228 @pyqtSignature("int") #CLOSED
229 def on_lstStopDay_activated(self, index):
229 def on_lstStopDay_activated(self, index):
230 """
230 """
231 Cambia la lista de opciones en lstStartDay
231 Cambia la lista de opciones en lstStartDay
232 """
232 """
233 var_StartDay_index=self.lstStartDay.currentIndex()
233 var_StartDay_index=self.lstStartDay.currentIndex()
234 var_end_index = self.lstStopDay.count() - index
234 var_end_index = self.lstStopDay.count() - index
235 self.lstStartDay.clear()
235 self.lstStartDay.clear()
236
236
237 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
237 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
238 self.lstStartDay.addItem(i)
238 self.lstStartDay.addItem(i)
239
239
240 self.lstStartDay.setCurrentIndex(var_StartDay_index)
240 self.lstStartDay.setCurrentIndex(var_StartDay_index)
241
241
242
242
243 @pyqtSignature("int") #CLOSED
243 @pyqtSignature("int") #CLOSED
244 def on_lstDcapacity_activated(self, index):
244 def on_lstDcapacity_activated(self, index):
245 """
245 """
246 Permite elegir el tamaΓ±o del disco
246 Permite elegir el tamaΓ±o del disco
247 """
247 """
248 if index == 0:
248 if index == 0:
249 var_size=25.0
249 var_size=25.0
250 elif index == 1:
250 elif index == 1:
251 var_size=8.5
251 var_size=8.5
252 elif index == 2:
252 elif index == 2:
253 var_size=4.7
253 var_size=4.7
254 elif index == 3:
254 elif index == 3:
255 var_size=0.7
255 var_size=0.7
256
256
257 if index != 4:
257 if index != 4:
258 self.txtDcapacity.setText(str(var_size*10**9/1024**2))
258 self.txtDcapacity.setText(str(var_size*10**9/1024**2))
259 self.txtDcapacity.setReadOnly(True)
259 self.txtDcapacity.setReadOnly(True)
260 else:
260 else:
261 self.txtDcapacity.setText('')
261 self.txtDcapacity.setText('')
262 self.txtDcapacity.setReadOnly(False)
262 self.txtDcapacity.setReadOnly(False)
263
263
264
264
265 @pyqtSignature("")
265 @pyqtSignature("")
266 def on_btnGbkp_clicked(self):
266 def on_btnGbkp_clicked(self):
267 """
267 """
268 Cuando se presiona el boton btnGbkp
268 Cuando se presiona el boton btnGbkp
269 """
269 """
270
270
271 #Verifica que las rutas sean validas
271 #Verifica que las rutas sean validas
272 if self.statusDpath == False or self.statusRpath == False:
272 if self.statusDpath == False or self.statusRpath == False:
273 if self.statusDpath == False:
273 if self.statusDpath == False:
274 self.txtInfo.append("Ruta de datos no valida")
274 self.txtInfo.append("Ruta de datos no valida")
275 if self.statusRpath == False:
275 if self.statusRpath == False:
276 self.txtInfo.append("Ruta de proyecto no valida")
276 self.txtInfo.append("Ruta de proyecto no valida")
277 return
277 return
278
278
279 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
279 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
280 var_Rpath=self.txtRpath.text()
280 var_Rpath=self.txtRpath.text()
281 var_dirs='/{gpath,iso,ppath}'
281 var_dirs='/{gpath,iso,ppath}'
282 var_cmd="mkdir -p "+str(var_Rpath)+str(var_dirs)
282 var_cmd="mkdir -p "+str(var_Rpath)+str(var_dirs)
283 var_output=commands.getstatusoutput(var_cmd)[0]
283 var_output=commands.getstatusoutput(var_cmd)[0]
284 if var_output != 0:
284 if var_output != 0:
285 self.txtInfo.append("No se pudieron crear los directorios, output_error:" + str(var_output))
285 self.txtInfo.append("No se pudieron crear los directorios, output_error:" + str(var_output))
286 return
286 return
287 else:
287 else:
288 self.txtInfo.append('Carpetas creadas correctamente')
288 self.txtInfo.append('Carpetas creadas correctamente')
289
289
290 #Cargando variables con los parametros
290 #Cargando variables con los parametros
291 var_Dpath=self.txtDpath.text()
291 var_Dpath=self.txtDpath.text()
292 var_Rpath=self.txtRpath.text()
292 var_Rpath=self.txtRpath.text()
293 var_Rpath_ppath=var_Rpath+"/ppath" #Ruta de los archivos a grabar
293 var_Rpath_ppath=var_Rpath+"/ppath" #Ruta de los archivos a grabar
294 var_sublist=[]
294 var_sublist=[]
295 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
295 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
296 var_sublist.append(i)
296 var_sublist.append(i)
297 if len(var_sublist) == 0:
297 if len(var_sublist) == 0:
298 self.txtInfo.append("No existen archivos encontrados")
298 self.txtInfo.append("No existen archivos encontrados")
299 return
299 return
300 #self.txtInfo.append('elementos: '+str(len(var_sublist)))
300 #self.txtInfo.append('elementos: '+str(len(var_sublist)))
301
301
302
302
303 var_Dtype=self.txtDtype.text()
303 var_Dtype=self.txtDtype.text()
304 var_Dcapacity=float(self.txtDcapacity.text())*1024 #tamaΓ±o en KB
304 var_Dcapacity=float(self.txtDcapacity.text())*1024 #tamaΓ±o en KB
305
305
306 #Busca los archivos con los parametros de busqueda
306 #Busca los archivos con los parametros de busqueda
307 var_files_list=[]
307 var_files_list=[]
308 for var_doy in var_sublist:
308 for var_doy in var_sublist:
309 var_cmd="find " + str(var_Dpath) + " -name ?"+var_doy+"???."+ str(var_Dtype) + " |sort"
309 var_cmd="find " + str(var_Dpath) + " -name ?"+var_doy+"???."+ str(var_Dtype) + " |sort"
310 var_output=commands.getstatusoutput(var_cmd)[1]
310 var_output=commands.getstatusoutput(var_cmd)[1]
311 for var_file in var_output.split():
311 for var_file in var_output.split():
312 var_files_list.append(var_file) #Almacena cada archivo en la lista
312 var_files_list.append(var_file) #Almacena cada archivo en la lista
313
313
314 #
314 #
315 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
315 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
316 #
316 #
317 var_n=0 #Numero del DVD actual
317 var_n=0 #Numero del DVD actual
318 var_tmp=0 #Se usa para acumulanr el tamaΓ±o de los archivos de la lista
318 var_tmp=0 #Se usa para acumulanr el tamaΓ±o de los archivos de la lista
319 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
319 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
320
320
321 for i in var_files_list: #Se asignan en i los archivos de la lista
321 for i in var_files_list: #Se asignan en i los archivos de la lista
322 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
322 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
323 var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista
323 var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista
324
324
325 #Si el tamaΓ±o acumulado es mayor que el de el DVD
325 #Si el tamaΓ±o acumulado es mayor que el de el DVD
326 if var_tmp > var_Dcapacity:
326 if var_tmp > var_Dcapacity:
327 var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real
327 var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real
328 #se agregan los ceros necesarios
328 #se agregan los ceros necesarios
329 if len(str(var_n)) < 4:
329 if len(str(var_n)) < 4:
330 var_n2=""
330 var_n2=""
331 for k in range(0, 4-len(str(var_n))):
331 for k in range(0, 4-len(str(var_n))):
332 var_n2 = var_n2+"0"
332 var_n2 = var_n2+"0"
333 #se crea un archivo con numeral en el sufijo y extension .dat
333 #se crea un archivo con numeral en el sufijo y extension .dat
334 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","w")
334 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","w")
335 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
335 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
336 for line in var_files_list_2:
336 for line in var_files_list_2:
337 var_tmp_path=(line.split(var_Dpath)[1]).split('/')
337 var_tmp_path=(line.split(var_Dpath)[1]).split('/')
338 var_tmp_path2="/"
338 var_tmp_path2="/"
339 for l in range(0, len(var_tmp_path)-1):
339 for l in range(0, len(var_tmp_path)-1):
340 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
340 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
341 var_file.write(var_tmp_path2+'=')
341 var_file.write(var_tmp_path2+'=')
342 var_file.write(line+'\n')
342 var_file.write(line+'\n')
343 var_file.close()
343 var_file.close()
344
344
345 var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual
345 var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual
346 var_files_list_2=[] #Se reinicia la lista
346 var_files_list_2=[] #Se reinicia la lista
347 var_n += 1
347 var_n += 1
348 var_files_list_2.append(i)
348 var_files_list_2.append(i)
349
349
350 #se agregan los ceros necesarios
350 #se agregan los ceros necesarios
351 if len(str(var_n)) < 4:
351 if len(str(var_n)) < 4:
352 var_n2=""
352 var_n2=""
353 for k in range(0, 4-len(str(var_n))):
353 for k in range(0, 4-len(str(var_n))):
354 var_n2 = var_n2+"0"
354 var_n2 = var_n2+"0"
355 #se crea un archivo con numeral en el sufijo y extension .dat
355 #se crea un archivo con numeral en el sufijo y extension .dat
356 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","w")
356 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","w")
357 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
357 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
358 for line in var_files_list_2:
358 for line in var_files_list_2:
359 var_tmp_path=(line.split(var_Dpath)[1]).split('/')
359 var_tmp_path=(line.split(var_Dpath)[1]).split('/')
360 var_tmp_path2="/"
360 var_tmp_path2="/"
361 for l in range(0, len(var_tmp_path)-1):
361 for l in range(0, len(var_tmp_path)-1):
362 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
362 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
363 var_file.write(var_tmp_path2+'=')
363 var_file.write(var_tmp_path2+'=')
364 var_file.write(line+'\n')
364 var_file.write(line+'\n')
365 var_file.close()
365 var_file.close()
366
366
367 #
367 #
368 #Genera los archivos .print con los cuales se creara los postscript
368 #Genera los archivos .print con los cuales se creara los postscript
369 #
369 #
370 self.var_n_files = var_n # Numero del ultimo archivo .dat creado
370 self.var_n_files = var_n # Numero del ultimo archivo .dat creado
371 var_n = 0 # Se reinicia a cero y se usa para poder acceder a cada una de los archivos
371 var_n = 0 # Se reinicia a cero y se usa para poder acceder a cada una de los archivos
372
372
373 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
373 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
374 for var_n in range(0, self.var_n_files+1):
374 for var_n in range(0, self.var_n_files+1):
375 print var_n
375 print var_n
376
376
377 #se agregan los ceros necesarios
377 #se agregan los ceros necesarios
378 if len(str(var_n)) < 4:
378 if len(str(var_n)) < 4:
379 var_n2=""
379 var_n2=""
380 for k in range(0, 4-len(str(var_n))):
380 for k in range(0, 4-len(str(var_n))):
381 var_n2 = var_n2+"0"
381 var_n2 = var_n2+"0"
382 #se abren los archivos .dat en modo lectura
382 #se abren los archivos .dat en modo lectura
383 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","r")
383 var_file = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat","r")
384 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
384 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
385
385
386 # Se crea el archivo .print
386 # Se crea el archivo .print
387 var_file_print = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".print","w")
387 var_file_print = open(var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".print","w")
388 var_file_print.write(self.txtElabel.text()+" "+str(var_n2)+str(var_n)+"/"+str(self.var_n_files)+"\n")
388 var_file_print.write(self.txtElabel.text()+" "+str(var_n2)+str(var_n)+"/"+str(self.var_n_files)+"\n")
389 var_file_print.write("Year Doy Folder Set Time range\n")
389 var_file_print.write("Year Doy Folder Set Time range\n")
390
390
391 #Se crean los archivos .print con los cuales se crearan los archivos .ps
391 #Se crean los archivos .print con los cuales se crearan los archivos .ps
392 var_first_folder = lines[0].split('=')[0]
392 var_first_folder = lines[0].split('=')[0]
393 var_first_file = (lines[0].split('=')[1])[:-1]
393 var_first_file = (lines[0].split('=')[1])[:-1]
394 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
394 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
395
395
396 for j in range(1, len(lines)-1):
396 for j in range(1, len(lines)-1):
397 var_tmp_folder = lines[j].split('=')[0]
397 var_tmp_folder = lines[j].split('=')[0]
398 var_tmp_file = (lines[j].split('=')[1])[:-1]
398 var_tmp_file = (lines[j].split('=')[1])[:-1]
399
399
400 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
400 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
401 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
401 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
402
402
403 var_last_file = (lines[j-1].split('=')[1])[:-1]
403 var_last_file = (lines[j-1].split('=')[1])[:-1]
404 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
404 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
405 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
405 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
406 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
406 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
407 if var_first_folder == '/':
407 if var_first_folder == '/':
408 var_folder = self.txtElabel.text()
408 var_folder = self.txtElabel.text()
409 else:
409 else:
410 var_folder = var_first_folder.split('/')[1]
410 var_folder = var_first_folder.split('/')[1]
411
411
412 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
412 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
413 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
413 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
414
414
415 var_first_folder = lines[j].split('=')[0]
415 var_first_folder = lines[j].split('=')[0]
416 var_first_file = (lines[j].split('=')[1])[:-1]
416 var_first_file = (lines[j].split('=')[1])[:-1]
417 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
417 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
418
418
419 var_last_file = (lines[-1].split('=')[1])[:-1]
419 var_last_file = (lines[-1].split('=')[1])[:-1]
420 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
420 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
421
421
422 if var_first_folder == '/':
422 if var_first_folder == '/':
423 var_folder = self.txtElabel.text()
423 var_folder = self.txtElabel.text()
424 else:
424 else:
425 var_folder = var_first_folder.split('/')[1]
425 var_folder = var_first_folder.split('/')[1]
426
426
427 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
427 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
428 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
428 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
429
429
430 var_file.close()
430 var_file.close()
431 var_file_print.close()
431 var_file_print.close()
432
432
433
433
434 #Se deshabilita el Tab Parameters y el boton btnGbkp
434 #Se deshabilita el Tab Parameters y el boton btnGbkp
435 self.tabParameters.setEnabled(False)
435 self.tabParameters.setEnabled(False)
436 self.btnGbkp.setEnabled(False)
436 self.btnGbkp.setEnabled(False)
437
437
438
438
439 @pyqtSignature("")
439 @pyqtSignature("")
440 def on_btnStartburn_clicked(self):
440 def on_btnStartburn_clicked(self):
441 """
441 """
442 Slot documentation goes here.
442 Se inicia el proceso de grabacion
443 """
443 """
444 sys.stdout = self
444 sys.stdout = self
445 #sys.stderr = self
445 #sys.stderr = self
446 print "stdout_!!!"
446 print "stdout_!!!"
447
447
448 #Inicializando variables
448 #Inicializando variables
449 var_Rpath=self.txtRpath.text()
449 var_Rpath=self.txtRpath.text()
450 var_Rpath_ppath=var_Rpath+"/ppath"
450 var_Rpath_ppath=var_Rpath+"/ppath"
451 var_Rpath_iso=var_Rpath+"/iso"
451 var_Rpath_iso=var_Rpath+"/iso"
452 var_label=self.txtElabel.text()
452 var_label=self.txtElabel.text()
453
453
454
455
456 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
454 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
457 for var_n in range(0, self.var_n_files+1):
455 for var_n in range(0, self.var_n_files+1):
458 print var_n
456 print var_n
459
457
460 #se agregan los ceros necesarios
458 #se agregan los ceros necesarios
461 if len(str(var_n)) < 4:
459 if len(str(var_n)) < 4:
462 var_n2=""
460 var_n2=""
463 for k in range(0, 4-len(str(var_n))):
461 for k in range(0, 4-len(str(var_n))):
464 var_n2 = var_n2+"0"
462 var_n2 = var_n2+"0"
465
463
466 file_iso=var_Rpath_iso+"/"+var_n2+str(var_n)+".iso"
464 file_iso=var_Rpath_iso+"/"+var_n2+str(var_n)+".iso"
467 file_dat=var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat"
465 file_dat=var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+str(var_n2)+str(var_n)+".dat"
468
466
469 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
467 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
470 var_cmd += ' -A '+var_label+' -V '+var_label
468 var_cmd += ' -A '+var_label+' -V '+var_label
471 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
469 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
472 self.txtInfo.append(var_cmd)
470 self.txtInfo.append(var_cmd)
473
471
474 var_output=commands.getstatusoutput(str(var_cmd))[0]
472 var_output=commands.getstatusoutput(str(var_cmd))[0]
475 self.txtInfo.append(str(var_output))
473 self.txtInfo.append(str(var_output))
476
474
477 #os.system(str(var_cmd))
475 #os.system(str(var_cmd))
478 #p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
476 #p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
479 #os.waitpid(p.pid, 0)
477 #os.waitpid(p.pid, 0)
480 ####self.txtInfo.append(str(p.pid))
478 ####self.txtInfo.append(str(p.pid))
481
479
482
480
483
481
484 @pyqtSignature("")
482 @pyqtSignature("")
485 def on_btnRestart_clicked(self):
483 def on_btnRestart_clicked(self):
486 """
484 """
487 Slot documentation goes here.
485 Slot documentation goes here.
488 """
486 """
489 self.tabParameters.setEnabled(True)
487 self.tabParameters.setEnabled(True)
490 self.btnGbkp.setEnabled(True)
488 self.btnGbkp.setEnabled(True)
491
489
492 @pyqtSignature("")
490 @pyqtSignature("")
493 def on_btnTdevA_clicked(self):
491 def on_btnTdevA_clicked(self):
494 var_dev = str(self.txtDeviceA.text())
492 var_dev = str(self.txtDeviceA.text())
495 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
493 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
496 commands.getstatusoutput(var_cmd)
494 commands.getstatusoutput(var_cmd)
497
495
498 @pyqtSignature("")
496 @pyqtSignature("")
499 def on_btnTdevB_clicked(self):
497 def on_btnTdevB_clicked(self):
500 var_dev = str(self.txtDeviceB.text())
498 var_dev = str(self.txtDeviceB.text())
501 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
499 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
502 commands.getstatusoutput(var_cmd)
500 commands.getstatusoutput(var_cmd)
503
501
504 @pyqtSignature("")
502 @pyqtSignature("")
505 def on_btnTdevC_clicked(self):
503 def on_btnTdevC_clicked(self):
506 var_dev = str(self.txtDeviceC.text())
504 var_dev = str(self.txtDeviceC.text())
507 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
505 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
508 commands.getstatusoutput(var_cmd)
506 commands.getstatusoutput(var_cmd)
509
507
510 @pyqtSignature("")
508 @pyqtSignature("")
511 def on_btnTdevD_clicked(self):
509 def on_btnTdevD_clicked(self):
512 var_dev = str(self.txtDeviceD.text())
510 var_dev = str(self.txtDeviceD.text())
513 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
511 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
514 commands.getstatusoutput(var_cmd)
512 commands.getstatusoutput(var_cmd)
General Comments 0
You need to be logged in to leave comments. Login now