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