##// END OF EJS Templates
***
ralonso -
r47:48
parent child
Show More
@@ -1,213 +1,216
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 #class BKmanager:
3 #class BKmanager:
4 # def __init__(self):
4 # def __init__(self):
5
5
6 from subprocess import *
6 from subprocess import *
7 import sys
7 import sys
8 import os
8 import os
9 import subprocess
9 import subprocess
10 import commands
10 import commands
11
11
12
12
13 #Entero a cadena agregando ceros delante
13 #Entero a cadena agregando ceros delante
14 def i2s(var_n, var_length=4):
14 def i2s(var_n, var_length=4):
15 var_n2=str(var_n)
15 var_n2=str(var_n)
16 while len(var_n2) < var_length:
16 while len(var_n2) < var_length:
17 var_n2 = "0"+var_n2
17 var_n2 = "0"+var_n2
18 return var_n2
18 return var_n2
19
19
20
20
21 #Crea directorios en la ruta indicada
21 #Crea directorios en la ruta indicada
22 def make_dirs(list_dirs, self):
22 def make_dirs(list_dirs, self):
23 var_cmd="mkdir -p "+str(self.var_Rpath)
23 var_cmd="mkdir -p "+str(self.var_Rpath)
24 for var_dir in list_dirs:
24 for var_dir in list_dirs:
25 var_output=commands.getstatusoutput(var_cmd+'/'+var_dir)[0]
25 var_output=commands.getstatusoutput(var_cmd+'/'+var_dir)[0]
26 if var_output != 0:
26 if var_output != 0:
27 self.txtInfo.append("Error al crear el directorio "+var_dir+", output_error:" + str(var_output))
27 self.txtInfo.append("Error al crear el directorio "+var_dir+", output_error:" + str(var_output))
28 return False
28 return False
29 self.txtInfo.append('Carpetas creadas correctamente')
29 self.txtInfo.append('Carpetas creadas correctamente')
30 return True
30 return True
31
31
32
32
33 #Se verifica que la ruta exista y sea un directorio
33 #Se verifica que la ruta exista y sea un directorio
34 def dir_exists(var_dir, self):
34 def dir_exists(var_dir, self):
35 var_cmd="test -d "+str(var_dir)
35 var_cmd="test -d "+str(var_dir)
36 var_output=commands.getstatusoutput(var_cmd)[0]
36 var_output=commands.getstatusoutput(var_cmd)[0]
37 if var_output != 0:
37 if var_output != 0:
38 self.txtInfo.append("Ruta no valida, output_error:" + str(var_output))
38 self.txtInfo.append("Ruta no valida, output_error:" + str(var_output))
39 return False
39 return False
40 else:
40 else:
41 self.txtInfo.append("Ruta valida, sin error:" + str(var_dir))
41 self.txtInfo.append("Ruta valida, sin error:" + str(var_dir))
42 return True
42 return True
43
43
44
44
45 #Se buscan los archivos del tipo especificado
45 #Se buscan los archivos del tipo especificado
46 def load_days(self):
46 def load_days(self):
47
47
48 self.var_list=[]
48 self.var_list=[]
49 self.lstStartDay.clear()
49 self.lstStartDay.clear()
50 self.lstStopDay.clear()
50 self.lstStopDay.clear()
51
51
52 if self.statusDpath == False:
52 if self.statusDpath == False:
53 self.btnGbkp.setEnabled(False)
53 self.btnGbkp.setEnabled(False)
54 return
54 return
55
56 if self.var_Dtype == '':
57 return
55
58
56 var_cmd="find " + str(self.var_Dpath) + " -name *."+ str(self.var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
59 var_cmd="find " + str(self.var_Dpath) + " -name *."+ str(self.var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
57 output=commands.getstatusoutput(var_cmd)[1]
60 output=commands.getstatusoutput(var_cmd)[1]
58
61
59 #Si no se encuentra ningun archivo
62 #Si no se encuentra ningun archivo
60 if len(output) == 0:
63 if len(output) == 0:
61 self.txtInfo.append("No se encontraron archivos")
64 self.txtInfo.append("No se encontraron archivos")
62 self.btnGbkp.setEnabled(False)
65 self.btnGbkp.setEnabled(False)
63 return
66 return
64
67
65 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
68 #Se cargan las listas para seleccionar StartDay y StopDay (QComboBox)
66 for i in range(0, (len(output)+1)/8):
69 for i in range(0, (len(output)+1)/8):
67 self.var_list.append(output[8*i:8*(i+1)-1])
70 self.var_list.append(output[8*i:8*(i+1)-1])
68
71
69 for i in self.var_list:
72 for i in self.var_list:
70 self.lstStartDay.addItem(i)
73 self.lstStartDay.addItem(i)
71 self.lstStopDay.addItem(i)
74 self.lstStopDay.addItem(i)
72 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
75 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
73
76
74 get_sub_list(self)
77 get_sub_list(self)
75 self.btnGbkp.setEnabled(True)
78 self.btnGbkp.setEnabled(True)
76
79
77
80
78 #Verifica que los parametros
81 #Verifica que los parametros
79 def validate_parameters(self):
82 def validate_parameters(self):
80 #Verifica que las rutas sean validas
83 #Verifica que las rutas sean validas
81 if self.statusRpath == False:
84 if self.statusRpath == False:
82 self.txtInfo.append("Ruta de proyecto no valida")
85 self.txtInfo.append("Ruta de proyecto no valida")
83 return False
86 return False
84
87
85 #Verifica la etiqueta
88 #Verifica la etiqueta
86 if len(self.var_Elabel) == 0:
89 if len(self.var_Elabel) == 0:
87 self.txtInfo.append("Debe ingresar el nombre de la etiqueta")
90 self.txtInfo.append("Debe ingresar el nombre de la etiqueta")
88 return False
91 return False
89
92
90 return True
93 return True
91
94
92
95
93 #Obtiene el rango de las fechas seleccionadas
96 #Obtiene el rango de las fechas seleccionadas
94 def get_sub_list(self):
97 def get_sub_list(self):
95 self.var_sublist=[]
98 self.var_sublist=[]
96 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
99 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
97 self.var_sublist.append(i)
100 self.var_sublist.append(i)
98 if len(self.var_sublist) == 0:
101 if len(self.var_sublist) == 0:
99 self.txtInfo.append("No existen archivos encontrados")
102 self.txtInfo.append("No existen archivos encontrados")
100
103
101
104
102 #Busca los archivos con los parametros de busqueda
105 #Busca los archivos con los parametros de busqueda
103 def list_files(self):
106 def list_files(self):
104 var_files_list=[]
107 var_files_list=[]
105 for var_doy in self.var_sublist:
108 for var_doy in self.var_sublist:
106 var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort"
109 var_cmd="find " + str(self.var_Dpath) + " -name ?"+var_doy+"???."+ str(self.var_Dtype) + " |sort"
107 var_output=commands.getstatusoutput(var_cmd)[1]
110 var_output=commands.getstatusoutput(var_cmd)[1]
108 for var_file in var_output.split():
111 for var_file in var_output.split():
109 var_files_list.append(var_file) #Almacena cada archivo en la lista
112 var_files_list.append(var_file) #Almacena cada archivo en la lista
110 return var_files_list
113 return var_files_list
111
114
112
115
113 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
116 #Genera la lista de archivos .dat que contienen los archivos a grabar en cada DVD
114 def make_files_dat(var_files_list, self):
117 def make_files_dat(var_files_list, self):
115 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
118 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
116 var_n=1 #Numero del DVD actual
119 var_n=1 #Numero del DVD actual
117 var_tmp=0 #Se usa para acumular el tamaΓ±o de los archivos de la lista
120 var_tmp=0 #Se usa para acumular el tamaΓ±o de los archivos de la lista
118 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
121 var_files_list_2=[] #Se usa para almacenar la lista de archivos agrbar en cada DVD
119
122
120 for i in var_files_list: #Se asignan en i los archivos de la lista
123 for i in var_files_list: #Se asignan en i los archivos de la lista
121 self.txtInfo.append(i)
124 self.txtInfo.append(i)
122 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
125 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
123 var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista
126 var_tmp += var_size_i #Se acumulan el tamaΓ±o de los archivos de la lista
124
127
125 #Si el tamaΓ±o acumulado es mayor que el de el DVD
128 #Si el tamaΓ±o acumulado es mayor que el de el DVD
126 if var_tmp > self.var_Dcapacity:
129 if var_tmp > self.var_Dcapacity:
127 var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real
130 var_tmp -= var_size_i #se quita el tamaΓ±o sumado para mostrar el tamaΓ±o real
128 #se crea un archivo con numeral en el sufijo y extension .dat
131 #se crea un archivo con numeral en el sufijo y extension .dat
129 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
132 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
130 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
133 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
131 for line in var_files_list_2:
134 for line in var_files_list_2:
132 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
135 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
133 var_tmp_path2="/"
136 var_tmp_path2="/"
134 for l in range(0, len(var_tmp_path)-1):
137 for l in range(0, len(var_tmp_path)-1):
135 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
138 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
136 var_file.write(var_tmp_path2+'=')
139 var_file.write(var_tmp_path2+'=')
137 var_file.write(line+'\n')
140 var_file.write(line+'\n')
138 var_file.close()
141 var_file.close()
139
142
140 var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual
143 var_tmp = var_size_i #Se asigna a la variable el tamaΓ±o del archivo actual
141 var_files_list_2=[] #Se reinicia la lista
144 var_files_list_2=[] #Se reinicia la lista
142 var_n += 1
145 var_n += 1
143 var_files_list_2.append(i)
146 var_files_list_2.append(i)
144
147
145 #se crea un archivo con numeral en el sufijo y extension .dat
148 #se crea un archivo con numeral en el sufijo y extension .dat
146 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
149 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","w")
147 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
150 #Se aΓ±ade la lista de archivos a grabar en el DVD al archivo .dat
148 for line in var_files_list_2:
151 for line in var_files_list_2:
149 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
152 var_tmp_path=(line.split(self.var_Dpath)[1]).split('/')
150 var_tmp_path2="/"
153 var_tmp_path2="/"
151 for l in range(0, len(var_tmp_path)-1):
154 for l in range(0, len(var_tmp_path)-1):
152 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
155 var_tmp_path2=var_tmp_path2+str(var_tmp_path[l])+"/"
153 var_file.write(var_tmp_path2+'=')
156 var_file.write(var_tmp_path2+'=')
154 var_file.write(line+'\n')
157 var_file.write(line+'\n')
155 var_file.close()
158 var_file.close()
156
159
157 return var_n
160 return var_n
158
161
159
162
160 #Genera los archivos .print con los cuales se creara los postscript
163 #Genera los archivos .print con los cuales se creara los postscript
161 def make_files_print(self):
164 def make_files_print(self):
162
165
163 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
166 var_Rpath_ppath=self.var_Rpath+"/ppath" #Ruta de los archivos a grabar
164
167
165 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print
168 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .print
166 for var_n in range(1, self.var_n_discs + 1):
169 for var_n in range(1, self.var_n_discs + 1):
167 #se abren los archivos .dat en modo lectura
170 #se abren los archivos .dat en modo lectura
168 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r")
171 var_file = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".dat","r")
169 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
172 lines=var_file.readlines() # Se lee las lineas en el archivo y se almacenan en la lista
170 # Se crea el archivo .print
173 # Se crea el archivo .print
171 var_file_print = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".print","w")
174 var_file_print = open(var_Rpath_ppath+"/"+self.var_Elabel+"_"+i2s(var_n)+".print","w")
172 var_file_print.write(self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_n_discs)+"\n")
175 var_file_print.write(self.var_Elabel+" "+i2s(var_n)+"/"+i2s(self.var_n_discs)+"\n")
173 var_file_print.write("Year Doy Folder Set Time range\n")
176 var_file_print.write("Year Doy Folder Set Time range\n")
174
177
175 var_first_folder = lines[0].split('=')[0]
178 var_first_folder = lines[0].split('=')[0]
176 var_first_file = (lines[0].split('=')[1])[:-1]
179 var_first_file = (lines[0].split('=')[1])[:-1]
177 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
180 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
178
181
179 for j in range(1, len(lines)-1):
182 for j in range(1, len(lines)-1):
180 var_tmp_folder = lines[j].split('=')[0]
183 var_tmp_folder = lines[j].split('=')[0]
181 var_tmp_file = (lines[j].split('=')[1])[:-1]
184 var_tmp_file = (lines[j].split('=')[1])[:-1]
182
185
183 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
186 # Si el subfolder superior o la fecha del archivo cambia se genera una nueva linea
184 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
187 if (var_tmp_folder != var_first_folder) or (var_tmp_file[0:-5] != var_first_file[0:-5]):
185 var_last_file = (lines[j-1].split('=')[1])[:-1]
188 var_last_file = (lines[j-1].split('=')[1])[:-1]
186 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
189 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
187 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
190 # Si el archivo se grabara directamente en la / del DVD y no en un /directorio/
188 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
191 # se usa la etiqueta para indicar la parte de la etiqueta donde va el subdirectorio
189 if var_first_folder == '/':
192 if var_first_folder == '/':
190 var_folder = self.var_Elabel
193 var_folder = self.var_Elabel
191 else:
194 else:
192 var_folder = var_first_folder.split('/')[1]
195 var_folder = var_first_folder.split('/')[1]
193
196
194 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
197 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
195 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
198 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
196
199
197 var_first_folder = lines[j].split('=')[0]
200 var_first_folder = lines[j].split('=')[0]
198 var_first_file = (lines[j].split('=')[1])[:-1]
201 var_first_file = (lines[j].split('=')[1])[:-1]
199 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
202 var_date_first_file=commands.getstatusoutput("date -r "+var_first_file+" +'%T'")[1]
200
203
201 var_last_file = (lines[-1].split('=')[1])[:-1]
204 var_last_file = (lines[-1].split('=')[1])[:-1]
202 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
205 var_date_last_file=commands.getstatusoutput("date -r "+var_last_file+" +'%T'")[1]
203
206
204 if var_first_folder == '/':
207 if var_first_folder == '/':
205 var_folder = self.txtElabel.text()
208 var_folder = self.txtElabel.text()
206 else:
209 else:
207 var_folder = var_first_folder.split('/')[1]
210 var_folder = var_first_folder.split('/')[1]
208
211
209 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
212 var_file_print.write(var_first_file[-12:-8]+" "+var_first_file[-8:-5]+" "+var_folder +" "+var_first_file[-5:-2]+" "
210 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
213 +var_last_file[-5:-2]+" "+var_date_first_file+" "+var_date_last_file+"\n")
211
214
212 var_file.close()
215 var_file.close()
213 var_file_print.close()
216 var_file_print.close()
@@ -1,316 +1,308
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 from functions import functions
16 from functions import functions
17 from functions import functions2
17 from functions import functions2
18
18
19 class MainWindow(QMainWindow, Ui_MainWindow):
19 class MainWindow(QMainWindow, Ui_MainWindow):
20 """
20 """
21 Class documentation goes here.
21 Class documentation goes here.
22 """
22 """
23
23
24 def __init__(self, parent = None):
24 def __init__(self, parent = None):
25 QMainWindow.__init__(self, parent)
25 QMainWindow.__init__(self, parent)
26 self.setupUi(self)
26 self.setupUi(self)
27 self.setupUi2()
27 self.setupUi2()
28 sys.stdout = self #redirige salida estandar
28 sys.stdout = self #redirige salida estandar
29
29
30 def setupUi2(self):
30 def setupUi2(self):
31
31
32 self.statusDpath = False
32 self.statusDpath = False
33 self.statusRpath = False
33 self.statusRpath = False
34
34
35 functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
35 functions2.set_parameters(self) #Establece ciertos parametros, para pruebas
36
36
37 self.var_Dpath = self.txtDpath.text()
37 self.var_Dpath = self.txtDpath.text()
38 self.var_Rpath = self.txtRpath.text()
38 self.var_Rpath = self.txtRpath.text()
39 self.var_Dtype = self.txtDtype.text()
39 self.var_Dtype = self.txtDtype.text()
40 self.var_Elabel = self.txtElabel.text()
40 self.var_Elabel = self.txtElabel.text()
41 self.var_Copys = self.txtCopys.value()
41 self.var_Copys = self.txtCopys.value()
42 self.var_Dcapacity = self.txtDcapacity.value() * 1024
42 self.var_Dcapacity = self.txtDcapacity.value() * 1024
43
43
44 self.var_n_discs=0
44 self.var_n_discs=0
45 self.var_list=[]
45 self.var_list=[]
46 self.var_sublist=[]
46 self.var_sublist=[]
47
47
48 functions2.detect_devices(self) #busca los dispositivos de grabacion
48 functions2.detect_devices(self) #busca los dispositivos de grabacion
49 functions.load_days(self)
50
49
51
50
52
51 def write(self, txt):
53 def write(self, txt):
52 """
54 """
53 Escribe la salida estandar eb txtInfo
55 Escribe la salida estandar eb txtInfo
54 """
56 """
55 self.txtInfo.append(str(txt))
57 self.txtInfo.append(str(txt))
56
58
57
59
58 @pyqtSignature("")
60 @pyqtSignature("")
59 def on_btnDpath_clicked(self):
61 def on_btnDpath_clicked(self):
60 """
62 """
61 Permite seleccionar graficamente el direcorio de los datos a grabar
63 Permite seleccionar graficamente el direcorio de los datos a grabar
62 """
64 """
63 self.var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
65 self.var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
64 self.txtDpath.setText(self.var_Dpath)
66 self.txtDpath.setText(self.var_Dpath)
65 self.on_txtDpath_editingFinished() #llamada a funcion
67 self.on_txtDpath_editingFinished() #llamada a funcion
66
68
67
69
68 @pyqtSignature("")
70 @pyqtSignature("")
69 def on_btnRpath_clicked(self):
71 def on_btnRpath_clicked(self):
70 """
72 """
71 Permite seleccionar graficamente el direcorio del proyecto
73 Permite seleccionar graficamente el direcorio del proyecto
72 """
74 """
73 self.var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
75 self.var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
74 self.txtRpath.setText(self.var_Rpath)
76 self.txtRpath.setText(self.var_Rpath)
75 self.on_txtRpath_editingFinished() #llamada a funcion
77 self.on_txtRpath_editingFinished() #llamada a funcion
76
78
77
79
78 @pyqtSignature("")
80 @pyqtSignature("")
79 def on_txtDpath_editingFinished(self):
81 def on_txtDpath_editingFinished(self):
80 """
82 """
81 Permite buscar los archivos de extension seleccionada en la ruta de de datos
83 Permite buscar los archivos de extension seleccionada en la ruta de de datos
82 y cargar los valores para el rango de tiempo a ser grabado
84 y cargar los valores para el rango de tiempo a ser grabado
83 """
85 """
84 self.var_Dpath=self.txtDpath.text() #Se carga la variable con la ruta recien editada
86 self.var_Dpath=self.txtDpath.text() #Se carga la variable con la ruta recien editada
85 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
87 self.statusDpath = functions.dir_exists(self.var_Dpath, self)
86 functions.load_days(self)
88 functions.load_days(self)
87
89
88
90
89 @pyqtSignature("")
91 @pyqtSignature("")
90 def on_txtRpath_editingFinished(self):
92 def on_txtRpath_editingFinished(self):
91 """
93 """
92 Valida la ruta del proyecto
94 Valida la ruta del proyecto
93 """
95 """
94 self.var_Rpath=self.txtRpath.text() #Se carga la variable con la ruta recien editada
96 self.var_Rpath=self.txtRpath.text() #Se carga la variable con la ruta recien editada
95 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
97 self.statusRpath = functions.dir_exists(self.var_Rpath, self)
96
98
97
99
98 @pyqtSignature("int")
100 @pyqtSignature("int")
99 def on_lstDtype_activated(self, index):
101 def on_lstDtype_activated(self, index):
100 """
102 """
101 Permite elegir entre los tipos de archivos
103 Permite elegir entre los tipos de archivos
102 """
104 """
105 self.txtDtype.setReadOnly(True)
103 if index == 0:
106 if index == 0:
104 var_type='r'
107 var_type='r'
105 elif index == 1:
108 elif index == 1:
106 var_type='pdata'
109 var_type='pdata'
107 elif index == 2:
110 elif index == 2:
108 var_type='sswma'
111 var_type='sswma'
109
112 else :
110 if index != 3:
113 var_type=''
111 self.txtDtype.setText(var_type)
112 self.txtDtype.setReadOnly(True)
113 self.var_Dtype=self.txtDtype.text()
114 functions.load_days(self)
115
116 else:
117 self.txtDtype.setText('')
118 self.txtDtype.setReadOnly(False)
114 self.txtDtype.setReadOnly(False)
119
115
116 self.txtDtype.setText(var_type)
117 self.on_txtDtype_editingFinished()
118
120
119
121 @pyqtSignature("")
120 @pyqtSignature("")
122 def on_txtDtype_editingFinished(self):
121 def on_txtDtype_editingFinished(self):
123 self.var_Dtype=self.txtDtype.text()
122 self.var_Dtype=self.txtDtype.text()
124 functions.load_days(self) #llamada a funcion
123 functions.load_days(self) #llamada a funcion
125
124
126
125
127 @pyqtSignature("")
126 @pyqtSignature("")
128 def on_txtElabel_editingFinished(self):
127 def on_txtElabel_editingFinished(self):
129 self.var_Elabel = self.txtElabel.text()
128 self.var_Elabel = self.txtElabel.text()
130
129
131
130
132 @pyqtSignature("")
131 @pyqtSignature("")
133 def on_txtCopys_editingFinished(self):
132 def on_txtCopys_editingFinished(self):
134 self.var_Copys = self.txtCopys.value()
133 self.var_Copys = self.txtCopys.value()
135
134
136
135
137 @pyqtSignature("")
136 @pyqtSignature("")
138 def on_txtDcapacity_editingFinished(self):
137 def on_txtDcapacity_editingFinished(self):
139 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaΓ±o en KB
138 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaΓ±o en KB
140
139
141
140
142 @pyqtSignature("int") #CLOSED
141 @pyqtSignature("int") #CLOSED
143 def on_lstStartDay_activated(self, index):
142 def on_lstStartDay_activated(self, index):
144 """
143 """
145 Cambia la lista de opciones en lstStopDay
144 Cambia la lista de opciones en lstStopDay
146 """
145 """
147 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
146 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
148 self.lstStopDay.clear()
147 self.lstStopDay.clear()
149
148
150 for i in self.var_list[index:]:
149 for i in self.var_list[index:]:
151 self.lstStopDay.addItem(i)
150 self.lstStopDay.addItem(i)
152
151
153 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
152 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
154
153
155 functions.get_sub_list(self)
154 functions.get_sub_list(self)
156
155
157
156
158 @pyqtSignature("int") #CLOSED
157 @pyqtSignature("int") #CLOSED
159 def on_lstStopDay_activated(self, index):
158 def on_lstStopDay_activated(self, index):
160 """
159 """
161 Cambia la lista de opciones en lstStartDay
160 Cambia la lista de opciones en lstStartDay
162 """
161 """
163 var_StartDay_index=self.lstStartDay.currentIndex()
162 var_StartDay_index=self.lstStartDay.currentIndex()
164 var_end_index = self.lstStopDay.count() - index
163 var_end_index = self.lstStopDay.count() - index
165 self.lstStartDay.clear()
164 self.lstStartDay.clear()
166
165
167 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
166 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
168 self.lstStartDay.addItem(i)
167 self.lstStartDay.addItem(i)
169
168
170 self.lstStartDay.setCurrentIndex(var_StartDay_index)
169 self.lstStartDay.setCurrentIndex(var_StartDay_index)
171
170
172 functions.get_sub_list(self)
171 functions.get_sub_list(self)
173
172
174
173
175 @pyqtSignature("int") #CLOSED
174 @pyqtSignature("int") #CLOSED
176 def on_lstDcapacity_activated(self, index):
175 def on_lstDcapacity_activated(self, index):
177 """
176 """
178 Permite elegir el tamaΓ±o del disco
177 Permite elegir el tamaΓ±o del disco
179 """
178 """
180 if index == 0:
179 if index == 0:
181 var_size=25.0
180 var_size=25.0
182 elif index == 1:
181 elif index == 1:
183 var_size=8.5
182 var_size=8.5
184 elif index == 2:
183 elif index == 2:
185 var_size=4.7
184 var_size=4.7
186 elif index == 3:
185 elif index == 3:
187 var_size=0.7
186 var_size=0.7
188
187
189 if index != 4:
188 if index != 4:
190 self.txtDcapacity.setValue(var_size*10**9/1024**2)
189 self.txtDcapacity.setValue(var_size*10**9/1024**2)
191 self.txtDcapacity.setReadOnly(True)
190 self.txtDcapacity.setReadOnly(True)
192 else:
191 else:
193 self.txtDcapacity.setValue(100.0)
192 self.txtDcapacity.setValue(100.0)
194 self.txtDcapacity.setReadOnly(False)
193 self.txtDcapacity.setReadOnly(False)
195
194
196 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaΓ±o en KB
195 self.var_Dcapacity = self.txtDcapacity.value() * 1024 #tamaΓ±o en KB
197
196
198
197
199 @pyqtSignature("")
198 @pyqtSignature("")
200 def on_btnGbkp_clicked(self):
199 def on_btnGbkp_clicked(self):
201 """
200 """
202 Cuando se presiona el boton btnGbkp
201 Cuando se presiona el boton btnGbkp
203 """
202 """
204
203
205 if functions.validate_parameters(self) == False:
204 if functions.validate_parameters(self) == False:
206 return
205 return
207
206
208 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
207 #Crea las carpetas en la ruta del proyecto y verifica que se crearon correctamente
209 list_dirs=['gpath','iso','ppath']
208 list_dirs=['gpath','iso','ppath']
210 bool_make_dirs = functions.make_dirs(list_dirs, self)
209 bool_make_dirs = functions.make_dirs(list_dirs, self)
211 if bool_make_dirs == False:
210 if bool_make_dirs == False:
212 return
211 return
213
212
214 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
213 var_files_list = functions.list_files(self) #Se obtiene la lista de archivos a grabar
215 self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
214 self.var_n_discs = functions.make_files_dat(var_files_list, self) #Se crean los archivos .dat
216
215
217 functions.make_files_print(self) # Se crean los archivos .print
216 functions.make_files_print(self) # Se crean los archivos .print
218
217
219 #Se deshabilita el Tab Parameters y el boton btnGbkp
218 #Se deshabilita el Tab Parameters y el boton btnGbkp
220 self.tabParameters.setEnabled(False)
219 self.tabParameters.setEnabled(False)
221 self.lstDcapacity.setEnabled(False)
220 self.lstDcapacity.setEnabled(False)
222 self.txtDcapacity.setEnabled(False)
221 self.txtDcapacity.setEnabled(False)
223 self.btnGbkp.setEnabled(False)
222 self.btnGbkp.setEnabled(False)
224 self.btnRestart.setEnabled(True)
223 self.btnRestart.setEnabled(True)
225 self.btnStartburn.setEnabled(True)
224 self.btnStartburn.setEnabled(True)
226
225
227
226
228 @pyqtSignature("")
227 @pyqtSignature("")
229 def on_btnRestart_clicked(self):
228 def on_btnRestart_clicked(self):
230 """
229 """
231 Permite que se puedan cambiar los parametros
230 Permite que se puedan cambiar los parametros
232 """
231 """
233 self.tabParameters.setEnabled(True)
232 self.tabParameters.setEnabled(True)
234 self.lstDcapacity.setEnabled(True)
233 self.lstDcapacity.setEnabled(True)
235 self.txtDcapacity.setEnabled(True)
234 self.txtDcapacity.setEnabled(True)
236 self.btnGbkp.setEnabled(True)
235 self.btnGbkp.setEnabled(True)
237 self.btnRestart.setEnabled(False)
236 self.btnRestart.setEnabled(False)
238 self.btnStartburn.setEnabled(False)
237 self.btnStartburn.setEnabled(False)
239
238
240
239
241 @pyqtSignature("")
240 @pyqtSignature("")
242 def on_btnStartburn_clicked(self):
241 def on_btnStartburn_clicked(self):
243 """
242 """
244 Se inicia el proceso de grabacion
243 Se inicia el proceso de grabacion
245 """
244 """
246 self.btnRestart.setEnabled(False)
245 self.btnRestart.setEnabled(False)
247 self.btnStartburn.setEnabled(False)
246 self.btnStartburn.setEnabled(False)
248 self.btnStopburn.setEnabled(True)
247 self.btnStopburn.setEnabled(True)
249
248
250 return
251
252 sys.stdout = self
249 sys.stdout = self
253 #sys.stderr = self
250 #sys.stderr = self
254 print "stdout_!!!"
251 print "stdout_!!!"
255
252
256 #Inicializando variables
253 #Inicializando variables
257 var_Rpath=self.txtRpath.text()
254 var_Rpath_ppath=self.var_Rpath+"/ppath"
258 var_Rpath_ppath=var_Rpath+"/ppath"
255 var_Rpath_iso=self.var_Rpath+"/iso"
259 var_Rpath_iso=var_Rpath+"/iso"
256
260 var_label=self.txtElabel.text()
261
262 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
257 # Se leen todos los archivos .dat creados para crear las etiquetas en los archivos .ps
263 for var_n in range(0, self.var_n_discs+1):
258 for var_n in range(1, self.var_n_discs+1):
264 print var_n
259 self.txtInfo.append(str(var_n))
265
266 file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
260 file_iso=var_Rpath_iso+"/"+functions.i2s(var_n)+".iso"
267 file_dat=var_Rpath_ppath+"/"+self.txtElabel.text()+"_"+functions.i2s(var_n)+".dat"
261 file_dat=var_Rpath_ppath+"/"+self.var_Elabel+"_"+functions.i2s(var_n)+".dat"
268
262
269 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
263 var_cmd = 'genisoimage -hide-joliet-trans-tbl -joliet-long -r '
270 var_cmd += ' -A '+var_label+' -V '+var_label
264 var_cmd += ' -A '+self.var_Elabel+' -V '+self.var_Elabel
271 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
265 var_cmd += ' -graft-points -path-list '+ file_dat+' -o '+file_iso
272 self.txtInfo.append(var_cmd)
266 self.txtInfo.append(var_cmd)
273
267 #
274 var_output=commands.getstatusoutput(str(var_cmd))[0]
268 # var_output=commands.getstatusoutput(str(var_cmd))[0]
275 self.txtInfo.append(str(var_output))
269 # self.txtInfo.append(str(var_output))
276
270 #
277 #os.system(str(var_cmd))
271 #os.system(str(var_cmd))
278 #p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
272 #p = subprocess.Popen(str('ls /'), shell=True, stdout=self)
279 #os.waitpid(p.pid, 0)
273 #os.waitpid(p.pid, 0)
280 ####self.txtInfo.append(str(p.pid))
274 ####self.txtInfo.append(str(p.pid))
281
275
282
276
283 @pyqtSignature("")
277 @pyqtSignature("")
284 def on_btnStopburn_clicked(self):
278 def on_btnStopburn_clicked(self):
285 """
279 """
286 Slot documentation goes here.
280 Slot documentation goes here.
287 """
281 """
288 self.btnRestart.setEnabled(True)
282 self.btnRestart.setEnabled(True)
289 self.btnStartburn.setEnabled(True)
283 self.btnStartburn.setEnabled(True)
290 self.btnStopburn.setEnabled(False)
284 self.btnStopburn.setEnabled(False)
291
285
292 @pyqtSignature("")
286 @pyqtSignature("")
293 def on_btnTdevA_clicked(self):
287 def on_btnTdevA_clicked(self):
294 var_dev = str(self.txtDeviceA.text())
288 var_dev = str(self.txtDeviceA.text())
295 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
289 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
296 commands.getstatusoutput(var_cmd)
290 commands.getstatusoutput(var_cmd)
297
291
298 @pyqtSignature("")
292 @pyqtSignature("")
299 def on_btnTdevB_clicked(self):
293 def on_btnTdevB_clicked(self):
300 var_dev = str(self.txtDeviceB.text())
294 var_dev = str(self.txtDeviceB.text())
301 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
295 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
302 commands.getstatusoutput(var_cmd)
296 commands.getstatusoutput(var_cmd)
303
297
304 @pyqtSignature("")
298 @pyqtSignature("")
305 def on_btnTdevC_clicked(self):
299 def on_btnTdevC_clicked(self):
306 var_dev = str(self.txtDeviceC.text())
300 var_dev = str(self.txtDeviceC.text())
307 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
301 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
308 commands.getstatusoutput(var_cmd)
302 commands.getstatusoutput(var_cmd)
309
303
310 @pyqtSignature("")
304 @pyqtSignature("")
311 def on_btnTdevD_clicked(self):
305 def on_btnTdevD_clicked(self):
312 var_dev = str(self.txtDeviceD.text())
306 var_dev = str(self.txtDeviceD.text())
313 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
307 var_cmd = 'eject ' + var_dev + '; eject -t ' + var_dev
314 commands.getstatusoutput(var_cmd)
308 commands.getstatusoutput(var_cmd)
315
316
General Comments 0
You need to be logged in to leave comments. Login now