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