##// END OF EJS Templates
falta verificacion
ralonso -
r73:74
parent child
Show More
@@ -1,192 +1,242
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 9
10 10 #----------------------------------------------------- Deteccion de los dispositivos de grabacion ---------------------------------------------------------------
11 11
12 12 def detect_devices(self):
13 13 """
14 14 Deteccion de los dispositvos de grabacion
15 15 """
16 16 #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ?
17 17 var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'"
18 18
19 19 var_output = commands.getstatusoutput(var_cmd)
20 20 if var_output[0] != 0:
21 21 self.txtInfo.append("No recording devices")
22 22 else:
23 23 # self.txtInfo.append("dispositivos encontrados")
24 24 var_devices = var_output[1].split('\n')
25 25
26 26 var_tmp=[]
27 27 for i in range(0, 4):
28 28 if i < len(var_devices):
29 29 var_len = len(var_devices[i])
30 30 var_tmp.append(var_devices[i][1:var_len - 1])
31 31 else:
32 32 var_tmp.append('')
33 33
34 34 #Se escriben los dispostivos correspodientes, si existen
35 35 self.txtDeviceA.setText(str(var_tmp[0]))
36 36 self.txtDeviceB.setText(str(var_tmp[1]))
37 37 self.txtDeviceC.setText(str(var_tmp[2]))
38 38 self.txtDeviceD.setText(str(var_tmp[3]))
39 39 #Se desactivan los que no existen
40 40 if len(var_tmp[0]) == 0 :
41 41 self.chkDevA.setChecked(False)
42 42 self.chkDevA.setEnabled(False)
43 43 if len(var_tmp[1]) == 0 :
44 44 self.chkDevB.setChecked(False)
45 45 self.chkDevB.setEnabled(False)
46 46 if len(var_tmp[2]) == 0 :
47 47 self.chkDevC.setChecked(False)
48 48 self.chkDevC.setEnabled(False)
49 49 if len(var_tmp[3]) == 0 :
50 50 self.chkDevD.setChecked(False)
51 51 self.chkDevD.setEnabled(False)
52 52
53 53 #----------------------------------- expulsa los dispositivos de grabacion --------------------------------------------
54 54
55 55 def eject_devices(self):
56 56 self.txtInfo.append("Ejecting recording devices")
57 57 return
58 58 for var_dev in self.var_devices:
59 59 var_cmd = 'eject ' + var_dev
60 60 commands.getstatusoutput(var_cmd)
61 61
62 62 #----------------------------------- listado de los dispositivos de grabacion seleccionados --------------------------------------------
63 63
64 64 def selected_devices(self):
65 65 self.var_devices=[]
66 66 if self.chkDevA.isChecked():
67 67 self.var_devices.append(str(self.txtDeviceA.text()))
68 68 if self.chkDevB.isChecked():
69 69 self.var_devices.append(str(self.txtDeviceB.text()))
70 70 if self.chkDevC.isChecked():
71 71 self.var_devices.append(str(self.txtDeviceC.text()))
72 72 if self.chkDevD.isChecked():
73 73 self.var_devices.append(str(self.txtDeviceD.text()))
74 74
75 75 if len(self.var_devices) == 0:
76 76 return False
77 77 else:
78 78 return True
79 79
80 80
81 81 #----------------------------------------------------- Inicializacion para pruebas---------------------------------------------------------------
82 82
83 83 def set_parameters_test(self):
84 84 """
85 85 Se usa para inicializar ciertos parametros para pruebas
86 86 """
87 87 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS')
88 88 self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager')
89 89 self.txtElabel.setText('EW_DRIFTS_pruebas')
90 90 self.lstDcapacity.setCurrentIndex(4)
91 91 self.txtDcapacity.setValue(100.0)
92 92 self.txtDcapacity.setReadOnly(False)
93 93 self.txtDeviceA.setText("/dev/scd0")
94 94 self.txtDeviceB.setText("/dev/scd1")
95 95 self.txtDeviceC.setText("/dev/scd2")
96 96 self.txtDeviceD.setText("/dev/scd3")
97 97
98 98
99 99
100 100 #----------------------------------------------------- crea parameters.conf ---------------------------------------------------------------
101 101
102 102 def make_parameters_conf(self):
103 103 var_file = open("parameters.conf","w")
104 104 var_file.write(self.var_Dpath+"\n") #0 Ruta de los datos
105 105 var_file.write(self.var_Rpath+"\n") #1 Ruta del proyecto
106 106 var_file.write(str(self.var_lstDtype)+"\n") #2 opcion Data Type
107 107 var_file.write(self.var_Dtype+"\n") #3 extension Data Type
108 108 var_file.write(self.var_Elabel+"\n") #4 etiqueta
109 109 var_file.write(str(self.var_Copys)+"\n") #5 Numero de copias
110 110 var_file.write(str(self.var_lstDcapacity)+"\n") #6 opcion Device Capacity
111 111 var_file.write(str(self.var_Dcapacity)+"\n") #7 tamaΓ±o Device Capacity
112 112 var_file.write(str(self.var_Discs)+"\n") #8 Numero de discos a grabar
113 113 # var_file.write(str(self.lstStartDay.currentIndex())+"\n") #9 Indice fecha inicial
114 114 # var_file.write(str(self.lstStopDay.currentIndex())+"\n") #10 Indice fecha final
115 115
116 116 var_file.close()
117 117
118 118 #----------------------------------------------------- carga parameters.conf ---------------------------------------------------------------
119 119
120 120 def get_parameters_conf(self):
121 121 var_file = open("parameters.conf","r")
122 122 lines = var_file.readlines()
123 123 self.txtDpath.setText(lines[0][:-1]) #0
124 124 self.txtRpath.setText(lines[1][:-1]) #1
125 125 self.lstDtype.setCurrentIndex(int(lines[2])) #2
126 126 self.txtDtype.setText(lines[3][:-1]) #3
127 127 self.txtElabel.setText(lines[4][:-1]) #4
128 128 self.txtCopys.setValue(int(lines[5][:-1])) #5
129 129 self.lstDcapacity.setCurrentIndex(int(lines[6])) #6
130 130 self.txtDcapacity.setValue(float(lines[7])) #7
131 131 self.var_Discs = int(lines[8]) #8
132 132 # var_StartDay = int(lines[6]) #9
133 133 # var_StopDay = int(lines[7]) #10
134 134 ################################
135 135 self.var_Copys = self.txtCopys.value() #5
136 136 ################################
137 137
138 138 var_file.close()
139 139
140 140
141 141
142 142 #-------------------------- actualiza el valor de las variables con los parametros seleccionados -----------------------------
143 143
144 144 def set_vars(self):
145 145 self.var_Dpath = str(self.txtDpath.text()) #0
146 146 self.var_Rpath = str(self.txtRpath.text()) #1
147 147 self.var_lstDtype = self.lstDtype.currentIndex() #2
148 148 self.var_Dtype = str(self.txtDtype.text()) #3
149 149 self.var_Elabel = str(self.txtElabel.text()) #4
150 150 self.var_Copys = self.txtCopys.value() #5
151 151 self.var_lstDcapacity = self.lstDcapacity.currentIndex() #6
152 152 self.var_Dcapacity = self.txtDcapacity.value() #7
153 153 self.var_Discs = self.var_Discs #8
154 154
155 155
156 156 #-------------------------- crea burning.conf -----------------------------
157 157
158 158 def make_burning_conf(self):
159 159 var_file = open("burning.conf","w")
160 160 var_n_burned_discs = ( ( (self.var_disc_n - 1) * self.var_Copys) + self.var_copy_n -1 )
161 161 var_file.write(str(var_n_burned_discs)+"\n") #0 Numero de discos ya grabados
162 162 var_file.write(str(self.var_disc_n)+"\n") #1 Disco actual para grabar
163 163 var_file.write(str(self.var_copy_n)+"\n") #2 Numero de copia actual para grabar
164 164 var_file.close()
165 165
166 166 #----------------------------------------------------- carga burning.conf ---------------------------------------------------------------
167 167
168 168 def get_burning_conf(self):
169 169 var_file = open("burning.conf","r")
170 170 lines = var_file.readlines()
171 171 self.var_burned_discs = int(lines[0]) #0
172 172 self.var_disc_n = int(lines[1])
173 173 self.var_copy_n = int(lines[2])
174 174 var_file.close()
175 175
176 176 #---------------------------------------------- Habilitacion y deshabilitacion de items -------------------------------------------------------
177 177
178 178 def enabled_items1(var_bool, self):
179 179 self.tabParameters.setEnabled(not(var_bool))
180 180 self.lstDcapacity.setEnabled(not(var_bool))
181 181 self.txtDcapacity.setEnabled(not(var_bool))
182 182 self.actionChange_Parameters.setEnabled(var_bool)
183 183 self.btnGbkp.setEnabled(not(var_bool))
184 184 self.btnRestart.setEnabled(var_bool)
185 185 self.btnStartburn.setEnabled(var_bool)
186 186
187 187
188 188 def enabled_items2(var_bool, self):
189 189 self.btnRestart.setEnabled(not(var_bool))
190 190 self.btnStartburn.setEnabled(not(var_bool))
191 191 self.btnStopburn.setEnabled(var_bool)
192 192 self.chkCheck.setEnabled(not(var_bool))
193 self.actionChange_Parameters.setEnabled(False)
194
195
196
197
198 #---------------------------------------------- Actualiza estado en los labels -------------------------------------------------------
199
200 def update_message(type, self):
201
202 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
203
204 if type == 1:
205 var_message = "BURNING"
206 if var_index == 0:
207 self.txtBstatusA.setText(var_message)
208 self.txtBdiscA.setText(str(self.var_disc_n))
209 self.txtBcopyA.setText(str(self.var_copy_n))
210
211 if var_index == 1:
212 self.txtBstatusB.setText(var_message)
213 self.txtBdiscB.setText(str(self.var_disc_n))
214 self.txtBcopyB.setText(str(self.var_copy_n))
215
216 if var_index == 2:
217 self.txtBstatusC.setText(var_message)
218 self.txtBdiscC.setText(str(self.var_disc_n))
219 self.txtBcopyC.setText(str(self.var_copy_n))
220
221 if var_index == 3:
222 self.txtBstatusD.setText(var_message)
223 self.txtBdiscD.setText(str(self.var_disc_n))
224 self.txtBcopyD.setText(str(self.var_copy_n))
225
226 if type == 2:
227 var_message = "COMPLETED"
228 if var_index == 0:
229 self.txtBstatusA.setText(var_message)
230
231 if var_index == 1:
232 self.txtBstatusB.setText(var_message)
233
234 if var_index == 2:
235 self.txtBstatusC.setText(var_message)
236
237 if var_index == 3:
238 self.txtBstatusD.setText(var_message)
239
240
241
242
@@ -1,517 +1,523
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 Ui_Parameters import Ui_Parameters
12 12 from Ui_About import Ui_About
13 13 from PyQt4 import QtGui
14 14 from subprocess import *
15 15 import sys
16 16 import os
17 17 #import subprocess
18 18 import commands
19 19 from functions import functions
20 20 from functions import functions2
21 21
22 22 class MainWindow(QMainWindow, Ui_MainWindow):
23 23 """
24 24 Class documentation goes here.
25 25 """
26 26
27 27 def __init__(self, parent = None):
28 28 QMainWindow.__init__(self, parent)
29 29 self.setupUi(self)
30 30
31 31 self.setupUi2()
32 32 #sys.stdout = self #redirige salida estandar
33 33
34 34 def setupUi2(self):
35 35
36 36 # functions2.detect_devices(self) #busca los dispositivos de grabacion
37 37
38 38 self.var_Discs = 0 #Numero de discos del proyecto
39 39 self.var_Copys = 0 #Numero de copias
40 40 self.var_disc_n = 0
41 41 self.var_copy_n = 0
42 42 self.var_burned_discs = 0
43 43
44 44 self.var_list=[]
45 45 self.var_sublist=[]
46 46
47 47 self.var_devices=[]
48 48
49 49 self.var_step = 0
50 50 self.bool_state_burning = False
51 51 self.blank_discs = False
52 52
53 53
54 54 #Revisa si existe el archivo de confirguracion
55 55 if os.path.isfile("parameters.conf"):
56 56 functions2.get_parameters_conf(self)
57 57 self.txtInfo.append("Parameters were loaded from configuration file")
58 58 self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys))
59 59
60 60 else:
61 61 # self.txtInfo.append("Elija los parametros de configuracion")
62 62 functions2.set_parameters_test(self) #Establece ciertos parametros, para pruebas
63 63
64 64 functions2.set_vars(self) #Carga las variables de la clase con los parametros seleccionados
65 65
66 66 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
67 67 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
68 68 functions.load_days(self)
69 69
70 70 if os.path.isfile("parameters.conf"):
71 71 functions2.enabled_items1(True, self) #Se bloquean los parametros de configuracion
72 72
73 73 if os.path.isfile("burning.conf"):
74 74 functions2.get_burning_conf(self)
75 75 self.txtInfo.append("Current disc: "+str(self.var_disc_n))
76 76 self.txtInfo.append("Current copy: "+str(self.var_copy_n))
77 77 self.btnStartburn.setText("Continue")
78 78
79 79 self.txtDeviceA.setText("/dev/scd0")
80 80 self.txtDeviceB.setText("/dev/scd1")
81 81 self.txtDeviceC.setText("/dev/scd2")
82 82 self.txtDeviceD.setText("/dev/scd3")
83 83
84 84 self.connect(self.actionChange_Parameters, QtCore.SIGNAL("triggered()"), self.changeParameters)
85 85 self.connect(self.actionAbout, QtCore.SIGNAL("triggered()"), self.about)
86 86
87 87 self.var_process = QtCore.QProcess()
88 88 self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput)
89 89 self.connect(self.var_process, QtCore.SIGNAL('readyReadStandardError()'), self.readError)
90 90 self.connect(self.var_process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished)
91 91
92 92 self.var_process_check = QtCore.QProcess()
93 93 self.connect(self.var_process_check, QtCore.SIGNAL('readyReadStandardOutput()'), self.readOuput_check)
94 94 self.connect(self.var_process_check, QtCore.SIGNAL('readyReadStandardError()'), self.readError_check)
95 95 self.connect(self.var_process_check, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.finished_check)
96 96
97 97 def write(self, txt):
98 98 self.txtInfo.append(str(txt))
99 99
100 100 def changeParameters(self):
101 101 dlg=QtGui.QDialog()
102 102 dlgui=Ui_Parameters()
103 103 dlgui.setupUi(dlg)
104 104 if (dlg.exec_() == QtGui.QDialog.Accepted):
105 105 if dlgui.txtDisc.value() > self.var_Discs or dlgui.txtCopy.value() > dlgui.txtNcopys.value():
106 106 self.txtInfo.append("Wrong parameters")
107 107 else:
108 108 self.var_Copys = dlgui.txtNcopys.value()
109 109 self.var_disc_n = dlgui.txtDisc.value()
110 110 self.var_copy_n = dlgui.txtCopy.value()
111 111 self.txtInfo.append("Changed parameters")
112 self.var_burned_discs = ( ( (self.var_disc_n - 1) * self.var_Copys) + self.var_copy_n -1 )
112 113
113 114
114 115 def about(self):
115 116 dlg_about=QtGui.QDialog()
116 117 dlgui_about=Ui_About()
117 118 dlgui_about.setupUi(dlg_about)
118 119 dlg_about.exec_()
119 120
120 121 #----------------------------------------------------- Funciones del proceso ---------------------------------------------------------------
121 122
122 123 def readOuput(self):
123 self.txtInfo.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput()))
124 # self.txtInfo.insertPlainText("stdout: " + QtCore.QString(self.var_process.readAllStandardOutput()))
125 pass
124 126
125 127 def readError(self):
126 128 self.txtInfo.insertPlainText("stderr: " + QtCore.QString(self.var_process.readAllStandardError()))
127 129
128 130 def finished(self):
129 self.txtInfo.insertPlainText("process completed"+QtCore.QString(self.var_process.exitCode())+"\n")
131 self.txtInfo.insertPlainText("\nprocess completed"+QtCore.QString(self.var_process.exitCode())+"\n")
130 132
131 133
132 134 if self.var_process.exitCode() != 0:
133 135 self.txtInfo.append("ERROR")
134 136
135 137 if self.bool_state_burning:
136 138 if self.var_step == 0:
137 139 self.var_step = 1 #Se ira al paso de la grabacion en la siguiente llamada
138 140
139 141 elif self.var_step == 1:
142 functions2.update_message(2, self)
140 143 self.var_copy_n += 1
141 144
142 145 self.burning()
143 146
144 147
145 148 #----------------------------------------------------- Funciones del proceso de verificacion ---------------------------------------------------------------
146 149
147 150 def readOuput_check(self):
148 151 self.txtInfo.insertPlainText("stdout check: " + QtCore.QString(self.var_process_check.readAllStandardOutput()))
149 152
150 153 def readError_check(self):
151 154 self.txtInfo.setText("stderr check: " + QtCore.QString(self.var_process_check.readAllStandardError()))
152 155
153 156 def finished_check(self):
154 157 self.txtInfo.append("check process completed "+QtCore.QString(self.var_process_check.exitCode())+"\n")
155 158
156 159
157 160 #----------------------------------------------------- Obtencion de la ruta de los datos ---------------------------------------------------------------
158 161
159 162 @pyqtSignature("")
160 163 def on_btnDpath_clicked(self):
161 164 """
162 165 Permite seleccionar graficamente el direcorio de los datos a grabar
163 166 """
164 167 self.var_Dpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
165 168 self.txtDpath.setText(self.var_Dpath)
166 169 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
167 170 functions.load_days(self)
168 171
169 172
170 173 @pyqtSignature("")
171 174 def on_txtDpath_editingFinished(self):
172 175 """
173 176 Carga la ruta editada y verifica que sea correcta y carga la lista de dias
174 177 """
175 178 self.var_Dpath=str(self.txtDpath.text()) #Se carga la variable con la ruta recien editada
176 179 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
177 180 functions.load_days(self)
178 181
179 182
180 183 #----------------------------------------------------- Obtencion de las ruta del proyecto ---------------------------------------------------------------
181 184
182 185 @pyqtSignature("")
183 186 def on_btnRpath_clicked(self):
184 187 """
185 188 Permite seleccionar graficamente el direcorio del proyecto
186 189 """
187 190 self.var_Rpath = str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
188 191 self.txtRpath.setText(self.var_Rpath)
189 192 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
190 193
191 194
192 195 @pyqtSignature("")
193 196 def on_txtRpath_editingFinished(self):
194 197 """
195 198 Valida la ruta del proyecto
196 199 """
197 200 self.var_Rpath = str(self.txtRpath.text()) #Se carga la variable con la ruta recien editada
198 201 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
199 202
200 203
201 204 #----------------------------------------------------- Tipo de datos ---------------------------------------------------------------
202 205
203 206 @pyqtSignature("int")
204 207 def on_lstDtype_activated(self, index):
205 208 """
206 209 Permite elegir entre los tipos de archivos
207 210 """
208 211 self.txtDtype.setReadOnly(True)
209 212 if index == 0:
210 213 self.var_Dtype ='r'
211 214 elif index == 1:
212 215 self.var_Dtype ='pdata'
213 216 elif index == 2:
214 217 self.var_Dtype ='sswma'
215 218 else :
216 219 self.var_Dtype =''
217 220 self.txtDtype.setReadOnly(False)
218 221
219 222 self.txtDtype.setText(self.var_Dtype)
220 223 functions.load_days(self) #llamada a funcion
221 224
222 225 @pyqtSignature("")
223 226 def on_txtDtype_editingFinished(self):
224 227 self.var_Dtype=str(self.txtDtype.text())
225 228 functions.load_days(self) #llamada a funcion
226 229
227 230
228 231 #----------------------------------------------------- Etiqueta ---------------------------------------------------------------
229 232
230 233 @pyqtSignature("")
231 234 def on_txtElabel_editingFinished(self):
232 235 self.var_Elabel = str(self.txtElabel.text())
233 236
234 237 #----------------------------------------------------- Numero de copias ---------------------------------------------------------------
235 238 @pyqtSignature("")
236 239 def on_txtCopys_editingFinished(self):
237 240 self.var_Copys = self.txtCopys.value()
238 241
239 242 #----------------------------------------------------- Seleccion del rango de fechas ---------------------------------------------------------------
240 243
241 244 @pyqtSignature("int") #CLOSED
242 245 def on_lstStartDay_activated(self, index):
243 246 """
244 247 Cambia la lista de opciones en lstStopDay
245 248 """
246 249 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
247 250 self.lstStopDay.clear()
248 251
249 252 for i in self.var_list[index:]:
250 253 self.lstStopDay.addItem(i)
251 254
252 255 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
253 256
254 257 functions.get_sub_list(self)
255 258
256 259
257 260 @pyqtSignature("int") #CLOSED
258 261 def on_lstStopDay_activated(self, index):
259 262 """
260 263 Cambia la lista de opciones en lstStartDay
261 264 """
262 265 var_StartDay_index=self.lstStartDay.currentIndex()
263 266 var_end_index = self.lstStopDay.count() - index
264 267 self.lstStartDay.clear()
265 268
266 269 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
267 270 self.lstStartDay.addItem(i)
268 271
269 272 self.lstStartDay.setCurrentIndex(var_StartDay_index)
270 273
271 274 functions.get_sub_list(self)
272 275
273 276
274 277 #----------------------------------------------------- Capacidad del dispositivo de grabacion ---------------------------------------------------------------
275 278
276 279 @pyqtSignature("")
277 280 def on_txtDcapacity_editingFinished(self):
278 281 self.var_Dcapacity = self.txtDcapacity.value()
279 282
280 283
281 284 @pyqtSignature("int") #CLOSED
282 285 def on_lstDcapacity_activated(self, index):
283 286 """
284 287 Permite elegir el tamaΓ±o del disco
285 288 """
286 289 if index == 0:
287 290 var_size=25.0
288 291 elif index == 1:
289 292 var_size=8.5
290 293 elif index == 2:
291 294 var_size=4.7
292 295 elif index == 3:
293 296 var_size=0.7
294 297
295 298 if index != 4:
296 299 self.txtDcapacity.setValue(var_size*10**9/1024**2)
297 300 self.txtDcapacity.setReadOnly(True)
298 301 else:
299 302 self.txtDcapacity.setValue(100.0)
300 303 self.txtDcapacity.setReadOnly(False)
301 304
302 305 self.var_lstDcapacity = self.lstDcapacity.currentIndex()
303 306 self.var_Dcapacity = self.txtDcapacity.value()
304 307
305 308
306 309 #==============================================================================
307 310 # Botones para la generacion de los archivos de configuracion y el proceso de grabacion
308 311 #==============================================================================
309 312
310 313 #----------------------------------------------------- Generacion de la configuracion usando los parametros ---------------------------------------------------------------
311 314
312 315 @pyqtSignature("")
313 316 def on_btnGbkp_clicked(self):
314 317 """
315 318 Generacion de archivos de configuracion usando los parametros
316 319 """
317 320
318 321 if functions.validate_parameters(self) == False:
319 322 return
320 323
321 324 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
322 325 list_dirs=['gpath','iso','ppath', 'tmpdata']
323 326 bool_make_dirs = functions.make_dirs(list_dirs, self)
324 327 if bool_make_dirs == False:
325 328 return
326 329
327 330 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
328 331
329 332 self.var_Discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
330 333
331 334 functions.make_files_print(self) # Se crean los archivos .print
332 335
333 336 functions2.make_parameters_conf(self) # se crea el archivo parameters.conf
334 337
335 338 self.txtInfo.append("Total number of discs for recording: "+str(self.var_Discs * self.var_Copys))
336 339
337 340 #Se bloquean los parametros de configuracion
338 341 functions2.enabled_items1(True, self)
339 342
340 343
341 344
342 345 #----------------------------------------------------- Permite reiniciar la configuracion ---------------------------------------------------------------
343 346
344 347 @pyqtSignature("")
345 348 def on_btnRestart_clicked(self):
346 349 """
347 350 Permite que se puedan cambiar los parametros
348 351 """
349 352 if os.path.isfile("parameters.conf"):
350 353 os.remove("parameters.conf")
351 354 if os.path.isfile("burning.conf"):
352 355 os.remove("burning.conf")
353 356
354 357 functions2.enabled_items1(False, self)
355 358 self.btnStartburn.setText("Start Burn")
356 359
357 360
358 361
359 362 #----------------------------------------------------- Iniciar proceso de grabacion ---------------------------------------------------------------
360 363
361 364 @pyqtSignature("")
362 365 def on_btnStartburn_clicked(self):
363 366 """
364 367 Se inicia el proceso de grabacion
365 368 """
366 self.txtInfo.append("BUTTON: on_btnStartburn_clicked")
369 ####### self.txtInfo.append("BUTTON: on_btnStartburn_clicked")
367 370 #Verifica que exista algun dispositivo de grabacion seleccionado
368 371 if not(functions2.selected_devices(self)):
369 372 self.txtInfo.append("There is no recording device selected")
370 373 return
371 374
372 375 # #Lista los dispositivos de grabacion a usar
373 376 # for dev in self.var_devices:
374 377 # self.txtInfo.append("recording device :"+dev)
375 378
376 379 #Si se ingresaron los DVDs en blanco
377 380 if self.blank_discs == True:
378 381 self.btnStartburn.setEnabled(False)
379 382 self.burning()
380 383 return
381 384
382 385 #Si se cargo los parametros de burning.conf
383 386 if self.var_burned_discs != 0:
384 387 self.txtInfo.append("BURNED DISC: "+str(self.var_burned_discs))
385 388 self.var_step = 0
386 389 self.bool_state_burning = True
387 390 self.blank_discs = False
388 391 functions2.enabled_items2(True, self)
389 392 self.burning()
390 393 return
391 394
392 395 #Asigna las variables con los valores iniciales
393 396 self.var_disc_n = 1 # numero de disco actual para grabacion
394 397 self.var_copy_n = 1
395 398 self.var_burned_discs = 0 #numero de discos grabados
396 399 self.var_step = 0
397 400 self.bool_state_burning = True
398 401 self.blank_discs = False
399 402 functions2.enabled_items2(True, self)
400 403 self.burning()
401 404
402 405
403 406 def burning(self):
404 407
405 408 var_Rpath_ppath=self.var_Rpath+"/ppath"
406 409 var_Rpath_iso=self.var_Rpath+"/iso"
407 410
408 411 #Si ya se grabaron todas las copias del disco
409 412 if self.var_copy_n > self.var_Copys:
410 413 #borra la imagen.iso del numero de disco anterior
411 414 file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso"
412 self.txtInfo.append("Deleting iso file")
415 # self.txtInfo.append("Deleting iso file")
413 416 # os.remove(file_iso)
414 417 self.var_copy_n = 1
415 418 self.var_disc_n += 1 # aumenta numero de disco actual para grabacion
416 419 self.var_step = 0
417 420
418 421 #Si ya se grabaron todos los discos
419 422 if self.var_disc_n > self.var_Discs:
420 423 self.bool_state_burning = False
421 424 self.txtInfo.append("Recording process is complete")
422 425 functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion
426 self.on_btnRestart_clicked()
427 self.btnStopburn.setEnabled(False)
423 428 return
424 429
425 self.txtInfo.append("\n"+str(self.var_disc_n)+" "+str(self.var_copy_n)+" "+str(self.var_step))
430 # self.txtInfo.append("\n"+str(self.var_disc_n)+" "+str(self.var_copy_n)+" "+str(self.var_step))
426 431
427 432 #Creacion del archivo.iso para la grabacion
428 433 if self.var_step == 0:
429 434 self.txtInfo.append("########## Disc number: "+str(self.var_disc_n)+"##########")
430 435 self.txtInfo.append("---------Creating iso file number: "+str(self.var_disc_n))
431 436 var_cmd = functions.cmd_iso(self)
432 437
433 438 #Grabacion de los DVDs
434 439 elif self.var_step == 1:
435 440
436 441 functions2.make_burning_conf(self)
437 442
438 443 var_index = ( ( (self.var_disc_n - 1) * self.var_Copys) + (self.var_copy_n - 1) - self.var_burned_discs ) % len(self.var_devices)
439
444 # self.txtInfo.append("INDEX: "+str(var_index))
440 445 if var_index == 0 and self.blank_discs == False:
441 446 functions2.eject_devices(self) # Expulsa las bandejas de los dispostivos de grabacion
442 447 self.blank_discs = True
443 448 self.btnStartburn.setText("Continue")
444 449 self.btnStartburn.setEnabled(True)
445 450 return
446 451
447 452 self.blank_discs = False
448 453
449 self.txtInfo.append("Grabando la copia numero: "+str(self.var_copy_n))
454 self.txtInfo.append("recording disc:"+str(self.var_copy_n)+", copy:"+str(self.var_copy_n))
455 functions2.update_message(1, self)
450 456
451 457 var_dev_tmp = self.var_devices[var_index]
452 458 file_iso=var_Rpath_iso+"/"+functions.i2s(self.var_disc_n)+".iso"
453 459 var_cmd = "wodim -v dev="+var_dev_tmp+" speed=16 "+ file_iso
454 460
455 461 self.var_process.start('echo "comando"')
456 462 # self.txtInfo.append("CMD: "+var_cmd)
457 463
458 464 # self.txtInfo.append("creando iso")
459 465 # self.var_process.start(var_cmd)
460 466
461 467
462 468 #----------------------------------------------------- Detener proceso de grabacion ---------------------------------------------------------------
463 469
464 470 @pyqtSignature("")
465 471 def on_btnStopburn_clicked(self):
466 472 """
467 473 Slot documentation goes here.
468 474 """
469 475 self.bool_state_burning = False
470 476 self.var_process.terminate() #Termina el proceso, si puede
471 477 # self.var_process.kill() #Mata el proceso, no es la forma adecuada, solo usar si terminate() no funciona
472 478 self.txtInfo.append("Stopped recording")
473 479 functions2.enabled_items2(False, self)
474 480
475 481
476 482 #----------------------------------------------------- Testeo de las unidades de grabacion ---------------------------------------------------------------
477 483
478 484 @pyqtSignature("")
479 485 def on_btnTdevA_clicked(self):
480 486 var_dev = str(self.txtDeviceA.text())
481 487 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
482 488 commands.getstatusoutput(var_cmd)
483 489
484 490 @pyqtSignature("")
485 491 def on_btnTdevB_clicked(self):
486 492 var_dev = str(self.txtDeviceB.text())
487 493 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
488 494 commands.getstatusoutput(var_cmd)
489 495
490 496 @pyqtSignature("")
491 497 def on_btnTdevC_clicked(self):
492 498 var_dev = str(self.txtDeviceC.text())
493 499 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
494 500 commands.getstatusoutput(var_cmd)
495 501
496 502 @pyqtSignature("")
497 503 def on_btnTdevD_clicked(self):
498 504 var_dev = str(self.txtDeviceD.text())
499 505 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
500 506 commands.getstatusoutput(var_cmd)
501 507
502 508 @pyqtSignature("")
503 509 def on_btnTDpath_clicked(self):
504 510 """
505 511 Slot documentation goes here.
506 512 """
507 513 self.var_TDpath= str(QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly))
508 514 self.txtTDpath.setText(self.var_TDpath)
509 515 self.statusTDpath = functions.dir_exists(self.var_TDpath, self)
510 516
511 517
512 518 @pyqtSignature("")
513 519 def on_btnCHstart_clicked(self):
514 520 """
515 521 Slot documentation goes here.
516 522 """
517 523 pass
General Comments 0
You need to be logged in to leave comments. Login now