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