##// END OF EJS Templates
conf_file
ralonso -
r49:50
parent child
Show More
@@ -1,103 +1,104
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
11 11 def set_parameters(self):
12 12 """
13 13 Se usa para inicializar ciertos parametros para pruebas
14 14 """
15 15 #self.txtDpath.setText('/home/ricardoar/optional/STORAGE/Data/RAW_EXP/JASMET/')
16 16 #self.txtRpath.setText('/home/ricardoar/optional/STORAGE/prueba1_jro_backup_manager/')
17 17 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS/')
18 18 self.txtRpath.setText('/home/ricardoar/optional/prueba1_jro_backup_manager/')
19 19 self.txtElabel.setText('EW_DRIFTS')
20 20 self.statusDpath = True
21 21 self.statusRpath = True
22 22 self.lstDcapacity.setCurrentIndex(4)
23 23 self.txtDcapacity.setValue(100.0)
24 24 self.txtDcapacity.setReadOnly(False)
25 25
26 26
27 27 def detect_devices(self):
28 28 """
29 29 Deteccion de los dispositvos de grabacion
30 30 """
31 31 #var_cmd="wodim --devices | grep /dev/ | awk -F\' '{print $2}'" #Funciona en consola pero no en python ΒΏ?
32 32 var_cmd="wodim --devices | grep /dev/ | awk '{print $2}' | awk -F= '{print $2}'"
33 33 var_output = commands.getstatusoutput(var_cmd)
34 34 if var_output[0] != 0:
35 35 self.txtInfo.append("No se pudo encontrar los dispositivos de grabacion, output_error:" + str(var_output))
36 36 else:
37 37 self.txtInfo.append("dispositivos encontrados")
38 38 var_devices = var_output[1].split('\n')
39 39
40 40 var_tmp=[]
41 41 for i in range(0, 4):
42 42 if i < len(var_devices):
43 43 var_len = len(var_devices[i])
44 44 var_tmp.append(var_devices[i][1:var_len - 1])
45 45 else:
46 46 var_tmp.append('')
47 47
48 48 #Se escriben los dispostivos correspodientes, si existen
49 49 self.txtDeviceA.setText(str(var_tmp[0]))
50 50 self.txtDeviceB.setText(str(var_tmp[1]))
51 51 self.txtDeviceC.setText(str(var_tmp[2]))
52 52 self.txtDeviceD.setText(str(var_tmp[3]))
53 53 #Se desactivan los que no existen
54 54 if len(var_tmp[0]) == 0 :
55 55 self.chkDevA.setChecked(False)
56 56 self.chkDevA.setEnabled(False)
57 57 if len(var_tmp[1]) == 0 :
58 58 self.chkDevB.setChecked(False)
59 59 self.chkDevB.setEnabled(False)
60 60 if len(var_tmp[2]) == 0 :
61 61 self.chkDevC.setChecked(False)
62 62 self.chkDevC.setEnabled(False)
63 63 if len(var_tmp[3]) == 0 :
64 64 self.chkDevD.setChecked(False)
65 65 self.chkDevD.setEnabled(False)
66 66
67 67 def enabled_items1(var_bool, self):
68 68 self.tabParameters.setEnabled(not(var_bool))
69 69 self.lstDcapacity.setEnabled(not(var_bool))
70 70 self.txtDcapacity.setEnabled(not(var_bool))
71 71 self.btnGbkp.setEnabled(not(var_bool))
72 72 self.btnRestart.setEnabled(var_bool)
73 73 self.btnStartburn.setEnabled(var_bool)
74 74
75 75 def make_parameters_conf(self):
76 76 var_file = open("parameters.conf","w")
77 77
78 var_file.write(self.var_Dpath+"\n")
79 var_file.write(self.var_Rpath+"\n")
80 var_file.write(str(self.var_lstDtype)+"\n")
81 var_file.write(self.var_Dtype+"\n")
82 var_file.write(self.var_Elabel+"\n")
83 var_file.write(str(self.var_Copys)+"\n")
84 var_file.write(str(self.var_lstDcapacity)+"\n")
85 var_file.write(str(self.var_Dcapacity)+"\n")
78 var_file.write(self.var_Dpath+"\n") #0
79 var_file.write(self.var_Rpath+"\n") #1
80 var_file.write(str(self.var_lstDtype)+"\n") #2
81 var_file.write(self.var_Dtype+"\n") #3
82 var_file.write(self.var_Elabel+"\n") #4
83 var_file.write(str(self.var_Copys)+"\n") #5
84 var_file.write(str(self.var_lstDcapacity)+"\n") #6
85 var_file.write(str(self.var_Dcapacity)+"\n") #7
86 86
87 87 var_file.close()
88 88
89 89
90 90 def get_parameters_conf(self):
91 var_file = open("parameters.conf","w")
91 var_file = open("parameters.conf","r")
92 lines = var_file.readlines()
92 93
93 var_file.write(self.var_Dpath+"\n")
94 var_file.write(self.var_Rpath+"\n")
95 var_file.write(str(self.var_lstDtype)+"\n")
96 var_file.write(self.var_Dtype+"\n")
97 var_file.write(self.var_Elabel+"\n")
98 var_file.write(str(self.var_Copys)+"\n")
99 var_file.write(str(self.var_lstDcapacity)+"\n")
100 var_file.write(str(self.var_Dcapacity)+"\n")
94 self.txtDpath.setText(lines[0][:-1]) #0
95 self.txtRpath.setText(lines[1][:-1]) #1
96 self.lstDtype.setCurrentIndex(int(lines[2])) #2
97 self.txtDtype.setText(lines[3][:-1]) #3
98 self.txtElabel.setText(lines[4][:-1]) #4
99 self.txtCopys.setValue(int(lines[5][:-1])) #5
100 self.lstDcapacity.setCurrentIndex(int(lines[6])) #6
101 self.txtDcapacity.setValue(float(lines[7]))
101 102
102 103 var_file.close()
103 104
@@ -1,312 +1,311
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 Ui_MainWindow import Ui_MainWindow
10 10 from PyQt4 import QtGui
11 11 from subprocess import *
12 12 import sys
13 13 import os
14 14 import subprocess
15 15 import commands
16 16 from functions import functions
17 17 from functions import functions2
18 18
19 19 class MainWindow(QMainWindow, Ui_MainWindow):
20 20 """
21 21 Class documentation goes here.
22 22 """
23 23
24 24 def __init__(self, parent = None):
25 25 QMainWindow.__init__(self, parent)
26 26 self.setupUi(self)
27 27 self.setupUi2()
28 28 sys.stdout = self #redirige salida estandar
29 29
30 30 def setupUi2(self):
31 31
32 32 sys.stdout = self
33 33
34 34 var_tmp = os.path.isfile("parameters.conf")
35 35
36 36 if var_tmp == True:
37 37 self.txtInfo.append("Archivo de configuracion encontrado")
38 38 functions2.get_parameters_conf(self)
39 39
40 40 else:
41 41 self.txtInfo.append("Elija los parametros de configuracion")
42
43 # os.remove("parameters.conf")
44 42
45 43 self.statusDpath = False
46 44 self.statusRpath = False
47 45
48 functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
46 # functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
49 47
50 48 self.var_Dpath = self.txtDpath.text()
51 49 self.var_Rpath = self.txtRpath.text()
52 50 self.var_lstDtype = self.lstDtype.currentIndex()
53 51 self.var_Dtype = self.txtDtype.text()
54 52 self.var_Elabel = self.txtElabel.text()
55 53 self.var_Copys = self.txtCopys.value()
56 54 self.var_lstDcapacity = self.lstDcapacity.currentIndex()
57 55 self.var_Dcapacity = self.txtDcapacity.value()
58 56
59 57 self.var_n_discs=0
60 58 self.var_list=[]
61 59 self.var_sublist=[]
62 60
63 61 functions2.detect_devices(self) #busca los dispositivos de grabacion
64 62 functions.load_days(self)
65 63
66 64
67 65
68 66 def write(self, txt):
69 67 """
70 68 Escribe la salida estandar eb txtInfo
71 69 """
72 70 self.txtInfo.append(str(txt))
73 71
74 72
75 73 @pyqtSignature("")
76 74 def on_btnDpath_clicked(self):
77 75 """
78 76 Permite seleccionar graficamente el direcorio de los datos a grabar
79 77 """
80 78 self.var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
81 79 self.txtDpath.setText(self.var_Dpath)
82 80 self.on_txtDpath_editingFinished() #llamada a funcion
83 81
84 82
85 83 @pyqtSignature("")
86 84 def on_btnRpath_clicked(self):
87 85 """
88 86 Permite seleccionar graficamente el direcorio del proyecto
89 87 """
90 88 self.var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
91 89 self.txtRpath.setText(self.var_Rpath)
92 90 self.on_txtRpath_editingFinished() #llamada a funcion
93 91
94 92
95 93 @pyqtSignature("")
96 94 def on_txtDpath_editingFinished(self):
97 95 """
98 96 Permite buscar los archivos de extension seleccionada en la ruta de de datos
99 97 y cargar los valores para el rango de tiempo a ser grabado
100 98 """
101 99 self.var_Dpath=self.txtDpath.text() #Se carga la variable con la ruta recien editada
102 100 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
103 101 functions.load_days(self)
104 102
105 103
106 104 @pyqtSignature("")
107 105 def on_txtRpath_editingFinished(self):
108 106 """
109 107 Valida la ruta del proyecto
110 108 """
111 109 self.var_Rpath=self.txtRpath.text() #Se carga la variable con la ruta recien editada
112 110 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
113 111
114 112
115 113 @pyqtSignature("int")
116 114 def on_lstDtype_activated(self, index):
117 115 """
118 116 Permite elegir entre los tipos de archivos
119 117 """
120 118 self.txtDtype.setReadOnly(True)
121 119 if index == 0:
122 120 var_type='r'
123 121 elif index == 1:
124 122 var_type='pdata'
125 123 elif index == 2:
126 124 var_type='sswma'
127 125 else :
128 126 var_type=''
129 127 self.txtDtype.setReadOnly(False)
130 128
131 129 self.txtDtype.setText(var_type)
132 130 self.on_txtDtype_editingFinished()
133 131
134 132
135 133 @pyqtSignature("")
136 134 def on_txtDtype_editingFinished(self):
137 135 self.var_Dtype=self.txtDtype.text()
138 136 functions.load_days(self) #llamada a funcion
139 137
140 138
141 139 @pyqtSignature("")
142 140 def on_txtElabel_editingFinished(self):
143 141 self.var_Elabel = self.txtElabel.text()
144 142
145 143
146 144 @pyqtSignature("")
147 145 def on_txtCopys_editingFinished(self):
148 146 self.var_Copys = self.txtCopys.value()
149 147
150 148
151 149 @pyqtSignature("")
152 150 def on_txtDcapacity_editingFinished(self):
153 151 self.var_Dcapacity = self.txtDcapacity.value()
154 152
155 153
156 154 @pyqtSignature("int") #CLOSED
157 155 def on_lstStartDay_activated(self, index):
158 156 """
159 157 Cambia la lista de opciones en lstStopDay
160 158 """
161 159 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
162 160 self.lstStopDay.clear()
163 161
164 162 for i in self.var_list[index:]:
165 163 self.lstStopDay.addItem(i)
166 164
167 165 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
168 166
169 167 functions.get_sub_list(self)
170 168
171 169
172 170 @pyqtSignature("int") #CLOSED
173 171 def on_lstStopDay_activated(self, index):
174 172 """
175 173 Cambia la lista de opciones en lstStartDay
176 174 """
177 175 var_StartDay_index=self.lstStartDay.currentIndex()
178 176 var_end_index = self.lstStopDay.count() - index
179 177 self.lstStartDay.clear()
180 178
181 179 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
182 180 self.lstStartDay.addItem(i)
183 181
184 182 self.lstStartDay.setCurrentIndex(var_StartDay_index)
185 183
186 184 functions.get_sub_list(self)
187 185
188 186
189 187 @pyqtSignature("int") #CLOSED
190 188 def on_lstDcapacity_activated(self, index):
191 189 """
192 190 Permite elegir el tamaΓ±o del disco
193 191 """
194 192 if index == 0:
195 193 var_size=25.0
196 194 elif index == 1:
197 195 var_size=8.5
198 196 elif index == 2:
199 197 var_size=4.7
200 198 elif index == 3:
201 199 var_size=0.7
202 200
203 201 if index != 4:
204 202 self.txtDcapacity.setValue(var_size*10**9/1024**2)
205 203 self.txtDcapacity.setReadOnly(True)
206 204 else:
207 205 self.txtDcapacity.setValue(100.0)
208 206 self.txtDcapacity.setReadOnly(False)
209 207
210 208 self.var_Dcapacity = self.txtDcapacity.value()
211 209
212 210
213 211 @pyqtSignature("")
214 212 def on_btnGbkp_clicked(self):
215 213 """
216 214 Cuando se presiona el boton btnGbkp
217 215 """
218 216
219 217 if functions.validate_parameters(self) == False:
220 218 return
221 219
222 220 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
223 221 list_dirs=['gpath','iso','ppath']
224 222 bool_make_dirs = functions.make_dirs(list_dirs, self)
225 223 if bool_make_dirs == False:
226 224 return
227 225
228 226 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
229 227 self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
230 228 functions.make_files_print(self) # Se crean los archivos .print
231 229 functions2.make_parameters_conf(self) # se crea el archivo parameters.conf
232 230
233 231 #Se deshabilitan los parametros de configuracion
234 232 functions2.enabled_items1(True, self)
235 233
236 234 @pyqtSignature("")
237 235 def on_btnRestart_clicked(self):
238 236 """
239 237 Permite que se puedan cambiar los parametros
240 238 """
241 239 functions2.enabled_items1(False, self)
240 os.remove("parameters.conf")
242 241
243 242
244 243 @pyqtSignature("")
245 244 def on_btnStartburn_clicked(self):
246 245 """
247 246 Se inicia el proceso de grabacion
248 247 """
249 248 self.btnRestart.setEnabled(False)
250 249 self.btnStartburn.setEnabled(False)
251 250 self.btnStopburn.setEnabled(True)
252 251
253 252 sys.stdout = self
254 253 #sys.stderr = self
255 254 print "stdout_!!!"
256 255
257 256 #Inicializando variables
258 257 var_Rpath_ppath=self.var_Rpath+"/ppath"
259 258 var_Rpath_iso=self.var_Rpath+"/iso"
260 259
261 260 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
262 261 for var_n in range(1, self.var_n_discs+1):
263 262 self.txtInfo.append(str(var_n))
264 263 file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
265 264 file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat"
266 265
267 266 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
268 267 var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
269 268 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
270 269 self.txtInfo.append(var_cmd)
271 270
272 271 var_output=commands.getstatusoutput(str(var_cmd))[0]
273 272 self.txtInfo.append(str(var_output))
274 273
275 274 #os.system(str(var_cmd))
276 275 #p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
277 276 #os.waitpid(p.pid, 0)
278 277 ####self.txtInfo.append(str(p.pid))
279 278
280 279
281 280 @pyqtSignature("")
282 281 def on_btnStopburn_clicked(self):
283 282 """
284 283 Slot documentation goes here.
285 284 """
286 285 self.btnRestart.setEnabled(True)
287 286 self.btnStartburn.setEnabled(True)
288 287 self.btnStopburn.setEnabled(False)
289 288
290 289 @pyqtSignature("")
291 290 def on_btnTdevA_clicked(self):
292 291 var_dev = str(self.txtDeviceA.text())
293 292 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
294 293 commands.getstatusoutput(var_cmd)
295 294
296 295 @pyqtSignature("")
297 296 def on_btnTdevB_clicked(self):
298 297 var_dev = str(self.txtDeviceB.text())
299 298 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
300 299 commands.getstatusoutput(var_cmd)
301 300
302 301 @pyqtSignature("")
303 302 def on_btnTdevC_clicked(self):
304 303 var_dev = str(self.txtDeviceC.text())
305 304 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
306 305 commands.getstatusoutput(var_cmd)
307 306
308 307 @pyqtSignature("")
309 308 def on_btnTdevD_clicked(self):
310 309 var_dev = str(self.txtDeviceD.text())
311 310 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
312 311 commands.getstatusoutput(var_cmd)
General Comments 0
You need to be logged in to leave comments. Login now