##// END OF EJS Templates
***
ralonso -
r17:18
parent child
Show More
@@ -1,238 +1,244
1 # -*- coding: utf-8 -*- No newline at end of file
1 # -*- coding: utf-8 -*-
2 No newline at end of file
2
3 """ No newline at end of file
3 """
4 Module implementing MainWindow. No newline at end of file
4 Module implementing MainWindow.
5 """ No newline at end of file
5 """
6 No newline at end of file
6
7 from PyQt4.QtGui import QMainWindow No newline at end of file
7 from PyQt4.QtGui import QMainWindow
8 from PyQt4.QtCore import pyqtSignature No newline at end of file
8 from PyQt4.QtCore import pyqtSignature
9 from Ui_MainWindow import Ui_MainWindow No newline at end of file
9 from Ui_MainWindow import Ui_MainWindow
10 from PyQt4 import QtGui No newline at end of file
10 from PyQt4 import QtGui
11 from subprocess import * No newline at end of file
11 from subprocess import *
12 import sys No newline at end of file
12 import sys
13 #import subprocess No newline at end of file
13 #import subprocess
14 import commands No newline at end of file
14 import commands
15 No newline at end of file
15
16 class MainWindow(QMainWindow, Ui_MainWindow): No newline at end of file
16 class MainWindow(QMainWindow, Ui_MainWindow):
17 """ No newline at end of file
17 """
18 Class documentation goes here. No newline at end of file
18 Class documentation goes here.
19 """ No newline at end of file
19 """
20 def __init__(self, parent = None): No newline at end of file
20 def __init__(self, parent = None):
21 QMainWindow.__init__(self, parent) No newline at end of file
21 QMainWindow.__init__(self, parent)
22 self.setupUi(self) No newline at end of file
22 self.setupUi(self)
23 self.setupUi2() No newline at end of file
23 self.setupUi2()
24 No newline at end of file
24
25 def setupUi2(self): No newline at end of file
25 def setupUi2(self):
26 print 'hi' No newline at end of file
26 print 'hi'
27 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS/') No newline at end of file
27 self.txtDpath.setText('/home/ricardoar/optional/STORAGE/EW_DRIFTS/')
28 self.txtRpath.setText('/home/ricardoar/optional/STORAGE/prueba1_jro_backup_manager/') No newline at end of file
28 self.txtRpath.setText('/home/ricardoar/optional/STORAGE/prueba1_jro_backup_manager/')
29 No newline at end of file
29
30 @pyqtSignature("") No newline at end of file
30 @pyqtSignature("")
31 def on_btnDpath_clicked(self): No newline at end of file
31 def on_btnDpath_clicked(self):
32 """ No newline at end of file
32 """
33 Slot documentation goes here. No newline at end of file
33 Slot documentation goes here.
34 """ No newline at end of file
34 """
35 var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) No newline at end of file
35 var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
36 self.txtDpath.setText(var_Dpath) No newline at end of file
36 self.txtDpath.setText(var_Dpath)
37 self.on_txtDpath_editingFinished() No newline at end of file
37 self.on_txtDpath_editingFinished()
38 No newline at end of file
38
39 @pyqtSignature("") No newline at end of file
39 @pyqtSignature("")
40 def on_btnRpath_clicked(self): No newline at end of file
40 def on_btnRpath_clicked(self):
41 """ No newline at end of file
41 """
42 Slot documentation goes here. No newline at end of file
42 Slot documentation goes here.
43 """ No newline at end of file
43 """
44 var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) No newline at end of file
44 var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
45 self.txtRpath.setText(var_Rpath) No newline at end of file
45 self.txtRpath.setText(var_Rpath)
46 self.on_txtRpath_editingFinished() No newline at end of file
46 self.on_txtRpath_editingFinished()
47 No newline at end of file
47
48 No newline at end of file
48
49 @pyqtSignature("") No newline at end of file
49 @pyqtSignature("")
50 def on_txtDpath_editingFinished(self): No newline at end of file
50 def on_txtDpath_editingFinished(self):
51 No newline at end of file
51
52 #Usando el modulo "subprocess" eric4 pide seleccion del tipo de subproceso (padre o hijo) No newline at end of file
52 #Usando el modulo "subprocess" eric4 pide seleccion del tipo de subproceso (padre o hijo)
53 #por ello se prefiere usar el modulo "commands" No newline at end of file
53 #por ello se prefiere usar el modulo "commands"
54 #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE) No newline at end of file
54 #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE)
55 #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE) No newline at end of file
55 #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE)
56 #output_p2= p2.communicate()[0] No newline at end of file
56 #output_p2= p2.communicate()[0]
57 #self.txtInfo.setText(output_p2) No newline at end of file
57 #self.txtInfo.setText(output_p2)
58 No newline at end of file
58
59 var_Dpath=self.txtDpath.text() No newline at end of file
59 var_Dpath=self.txtDpath.text()
60 No newline at end of file
60
61 #Se verifica que la ruta exista y sea un directorio No newline at end of file
61 #Se verifica que la ruta exista y sea un directorio
62 var_cmd="test -d "+str(var_Dpath) No newline at end of file
62 var_cmd="test -d "+str(var_Dpath)
63 var_output=commands.getstatusoutput(var_cmd)[0] No newline at end of file
63 var_output=commands.getstatusoutput(var_cmd)[0]
64 if var_output != 0: No newline at end of file
64 if var_output != 0:
65 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output)) No newline at end of file
65 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output))
66 return No newline at end of file
66 return
67 No newline at end of file
67
68 #Se buscan los archivos del tipo especificado No newline at end of file
68 #Se buscan los archivos del tipo especificado
69 var_Dtype=self.txtDtype.text() No newline at end of file
69 var_Dtype=self.txtDtype.text()
70 var_cmd="find " + str(var_Dpath) + " -name *."+ str(var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq" No newline at end of file
70 var_cmd="find " + str(var_Dpath) + " -name *."+ str(var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
71 output_p2=commands.getstatusoutput(var_cmd)[1] No newline at end of file
71 output_p2=commands.getstatusoutput(var_cmd)[1]
72 No newline at end of file
72
73 #INFO: Muestra los dias que se encontraron No newline at end of file
73 #INFO: Muestra los dias que se encontraron
74 self.txtInfo.setText(output_p2) No newline at end of file
74 self.txtInfo.setText(output_p2)
75 No newline at end of file
75
76 #Se cargan las listas para seleccionar StartDay y StopDay No newline at end of file
76 #Se cargan las listas para seleccionar StartDay y StopDay
77 self.var_list=[] No newline at end of file
77 self.var_list=[]
78 for i in range(0, (len(output_p2)+1)/8): No newline at end of file
78 for i in range(0, (len(output_p2)+1)/8):
79 self.var_list.append(output_p2[8*i:8*(i+1)-1]) No newline at end of file
79 self.var_list.append(output_p2[8*i:8*(i+1)-1])
80 No newline at end of file
80
81 self.lstStartDay.clear() No newline at end of file
81 self.lstStartDay.clear()
82 self.lstStopDay.clear() No newline at end of file
82 self.lstStopDay.clear()
83 No newline at end of file
83
84 for i in self.var_list: No newline at end of file
84 for i in self.var_list:
85 self.lstStartDay.addItem(i) No newline at end of file
85 self.lstStartDay.addItem(i)
86 self.lstStopDay.addItem(i) No newline at end of file
86 self.lstStopDay.addItem(i)
87 No newline at end of file
87
88 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1) No newline at end of file
88 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
89 No newline at end of file
89
90 #INFO: Muestra cuantos dias se encontraron No newline at end of file
90 #INFO: Muestra cuantos dias se encontraron
91 # self.txtInfo.setText(str(self.lstStartDay.count())) No newline at end of file
91 # self.txtInfo.setText(str(self.lstStartDay.count()))
92 No newline at end of file
92
93 No newline at end of file
93
94 @pyqtSignature("") No newline at end of file
94 @pyqtSignature("")
95 def on_txtRpath_editingFinished(self): No newline at end of file
95 def on_txtRpath_editingFinished(self):
96 """ No newline at end of file
96 """
97 Slot documentation goes here. No newline at end of file
97 Slot documentation goes here.
98 """ No newline at end of file
98 """
99 var_Rpath=self.txtRpath.text() No newline at end of file
99 var_Rpath=self.txtRpath.text()
100 #Se verifica que la ruta exista y sea un directorio No newline at end of file
100 #Se verifica que la ruta exista y sea un directorio
101 var_cmd="test -d "+str(var_Rpath) No newline at end of file
101 var_cmd="test -d "+str(var_Rpath)
102 var_output=commands.getstatusoutput(var_cmd)[0] No newline at end of file
102 var_output=commands.getstatusoutput(var_cmd)[0]
103 if var_output != 0: No newline at end of file
103 if var_output != 0:
104 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output)) No newline at end of file
104 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output))
105 return No newline at end of file
105 return
106 else: No newline at end of file
106 else:
107 self.txtInfo.setText("Ruta valida, sin error") No newline at end of file
107 self.txtInfo.setText("Ruta valida, sin error")
108 No newline at end of file
108
109 No newline at end of file
109
110 @pyqtSignature("int") No newline at end of file
110 @pyqtSignature("int")
111 def on_lstDtype_activated(self, index): No newline at end of file
111 def on_lstDtype_activated(self, index):
112 """ No newline at end of file
112 """
113 Permite elegir entre los tipos de archivos No newline at end of file
113 Permite elegir entre los tipos de archivos
114 """ No newline at end of file
114 """
115 if index == 0: No newline at end of file
115 if index == 0:
116 var_type='r' No newline at end of file
116 var_type='r'
117 elif index == 1: No newline at end of file
117 elif index == 1:
118 var_type='pdata' No newline at end of file
118 var_type='pdata'
119 elif index == 2: No newline at end of file
119 elif index == 2:
120 var_type='sswma' No newline at end of file
120 var_type='sswma'
121 No newline at end of file
121
122 if index != 3: No newline at end of file
122 if index != 3:
123 self.txtDtype.setText(var_type) No newline at end of file
123 self.txtDtype.setText(var_type)
124 self.txtDtype.setReadOnly(True) No newline at end of file
124 self.txtDtype.setReadOnly(True)
125 self.on_txtDpath_editingFinished() No newline at end of file
125 self.on_txtDpath_editingFinished()
126 else: No newline at end of file
126 else:
127 self.txtDtype.setText('') No newline at end of file
127 self.txtDtype.setText('')
128 self.txtDtype.setReadOnly(False) No newline at end of file
128 self.txtDtype.setReadOnly(False)
129 No newline at end of file
129
130 @pyqtSignature("") No newline at end of file
130 @pyqtSignature("")
131 def on_txtDtype_editingFinished(self): No newline at end of file
131 def on_txtDtype_editingFinished(self):
132 """ No newline at end of file
132 """
133 Se activa cuando el tipo de archivo es ingresado manualmente No newline at end of file
133 Se activa cuando el tipo de archivo es ingresado manualmente
134 """ No newline at end of file
134 """
135 self.on_txtDpath_editingFinished() No newline at end of file
135 self.on_txtDpath_editingFinished()
136 No newline at end of file
136
137 @pyqtSignature("int") No newline at end of file
137 @pyqtSignature("int")
138 def on_lstStartDay_activated(self, index): No newline at end of file
138 def on_lstStartDay_activated(self, index):
139 """ No newline at end of file
139 """
140 Slot documentation goes here. No newline at end of file
140 Slot documentation goes here.
141 """ No newline at end of file
141 """
142 #self.txtInfo.setText(str(index)) No newline at end of file
142 #self.txtInfo.setText(str(index))
143 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex() No newline at end of file
143 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
144 No newline at end of file
144
145 self.lstStopDay.clear() No newline at end of file
145 self.lstStopDay.clear()
146 No newline at end of file
146
147 for i in self.var_list[index:]: No newline at end of file
147 for i in self.var_list[index:]:
148 self.lstStopDay.addItem(i) No newline at end of file
148 self.lstStopDay.addItem(i)
149 No newline at end of file
149
150 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index) No newline at end of file
150 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
151 #self.txtInfo.append(str(var_StopDay_index)) No newline at end of file
151 #self.txtInfo.append(str(var_StopDay_index))
152 #self.txtInfo.append(str(self.lstStopDay.count())) No newline at end of file
152 #self.txtInfo.append(str(self.lstStopDay.count()))
153 No newline at end of file
153
154 No newline at end of file
154
155 @pyqtSignature("int") No newline at end of file
155 @pyqtSignature("int")
156 def on_lstStopDay_activated(self, index): No newline at end of file
156 def on_lstStopDay_activated(self, index):
157 """ No newline at end of file
157 """
158 Slot documentation goes here. No newline at end of file
158 Slot documentation goes here.
159 """ No newline at end of file
159 """
160 #self.txtInfo.setText(str(index)) No newline at end of file
160 #self.txtInfo.setText(str(index))
161 var_StartDay_index=self.lstStartDay.currentIndex() No newline at end of file
161 var_StartDay_index=self.lstStartDay.currentIndex()
162 No newline at end of file
162
163 var_end_index = self.lstStopDay.count() - index No newline at end of file
163 var_end_index = self.lstStopDay.count() - index
164 No newline at end of file
164
165 self.lstStartDay.clear() No newline at end of file
165 self.lstStartDay.clear()
166 No newline at end of file
166
167 for i in self.var_list[:len(self.var_list) - var_end_index + 1]: No newline at end of file
167 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
168 self.lstStartDay.addItem(i) No newline at end of file
168 self.lstStartDay.addItem(i)
169 No newline at end of file
169
170 self.lstStartDay.setCurrentIndex(var_StartDay_index) No newline at end of file
170 self.lstStartDay.setCurrentIndex(var_StartDay_index)
171 #self.txtInfo.append(str(var_StartDay_index)) No newline at end of file
171 #self.txtInfo.append(str(var_StartDay_index))
172 #self.txtInfo.append(str(self.lstStartDay.count())) No newline at end of file
172 #self.txtInfo.append(str(self.lstStartDay.count()))
173 No newline at end of file
173
174 @pyqtSignature("int") No newline at end of file
174 @pyqtSignature("int")
175 def on_lstDcapacity_activated(self, index): No newline at end of file
175 def on_lstDcapacity_activated(self, index):
176 """ No newline at end of file
176 """
177 Permite elegir el tamaΓ±o del disco No newline at end of file
177 Permite elegir el tamaΓ±o del disco
178 """ No newline at end of file
178 """
179 if index == 0: No newline at end of file
179 if index == 0:
180 var_size=25.0 No newline at end of file
180 var_size=25.0
181 elif index == 1: No newline at end of file
181 elif index == 1:
182 var_size=8.5 No newline at end of file
182 var_size=8.5
183 elif index == 2: No newline at end of file
183 elif index == 2:
184 var_size=4.7 No newline at end of file
184 var_size=4.7
185 elif index == 3: No newline at end of file
185 elif index == 3:
186 var_size=0.7 No newline at end of file
186 var_size=0.7
187 No newline at end of file
187
188 if index != 4: No newline at end of file
188 if index != 4:
189 self.txtDcapacity.setText(str(var_size*10**9/1024**2)) No newline at end of file
189 self.txtDcapacity.setText(str(var_size*10**9/1024**2))
190 self.txtDcapacity.setReadOnly(True) No newline at end of file
190 self.txtDcapacity.setReadOnly(True)
191 else: No newline at end of file
191 else:
192 self.txtDcapacity.setText('') No newline at end of file
192 self.txtDcapacity.setText('')
193 self.txtDcapacity.setReadOnly(False) No newline at end of file
193 self.txtDcapacity.setReadOnly(False)
194 No newline at end of file
194
195 @pyqtSignature("") No newline at end of file
195 @pyqtSignature("")
196 def on_btnGbkp_clicked(self): No newline at end of file
196 def on_btnGbkp_clicked(self):
197 """ No newline at end of file
197 """
198 Slot documentation goes here. No newline at end of file
198 Slot documentation goes here.
199 """ No newline at end of file
199 """
200 var_dirs='/{gpath,iso,ppath}' No newline at end of file
200 var_dirs='/{gpath,iso,ppath}'
201 var_Rpath=self.txtRpath.text() No newline at end of file
201 var_Rpath=self.txtRpath.text()
202 var_cmd="mkdir "+str(var_Rpath)+str(var_dirs) No newline at end of file
202 var_cmd="mkdir "+str(var_Rpath)+str(var_dirs)
203 self.txtInfo.append(var_cmd) No newline at end of file
203 self.txtInfo.append(var_cmd)
204 No newline at end of file
204
205 #CREA LAS CARPETAS "COMENTADO TEMPORALMENTE" No newline at end of file
205 #CREA LAS CARPETAS "COMENTADO TEMPORALMENTE"
206 #var_output=commands.getstatusoutput(var_cmd)[0] No newline at end of file
206 #var_output=commands.getstatusoutput(var_cmd)[0]
207 #if var_output != 0: No newline at end of file
207 #if var_output != 0:
208 # self.txtInfo.setText("No se pudieron crear los directorios, output_error:" + str(var_output)) No newline at end of file
208 # self.txtInfo.setText("No se pudieron crear los directorios, output_error:" + str(var_output))
209 # return No newline at end of file
209 # return
210 #else: No newline at end of file
210 #else:
211 # self.txtInfo.append('Carpetas creadas correctamente') No newline at end of file
211 # self.txtInfo.append('Carpetas creadas correctamente')
212
212
No newline at end of file
213
213 var_sublist = [] No newline at end of file
No newline at end of file
214 var_sublist=[]
No newline at end of file
215 No newline at end of file
214 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]: No newline at end of file
216 for i in self.var_list[self.lstStartDay.currentIndex():self.lstStartDay.currentIndex() + self.lstStopDay.currentIndex()+1]:
215 self.txtInfo.append(i) No newline at end of file
217 self.txtInfo.append(i)
216 var_sublist.append(i) No newline at end of file
218 var_sublist.append(i)
217 No newline at end of file
219
218 var_Dpath=self.txtDpath.text() No newline at end of file
220 var_Dpath=self.txtDpath.text()
219 var_Dtype=self.txtDtype.text() No newline at end of file
221 var_Dtype=self.txtDtype.text()
220 No newline at end of file
222
223 return
No newline at end of file
224 var_files_list=[] No newline at end of file
221 for var_doy in var_sublist No newline at end of file
225 for var_doy in var_sublist
222 var_cmd="find " + str(var_Dpath) + " -name ?"+var_doy+"???."+ str(var_Dtype) No newline at end of file
226 var_cmd="find " + str(var_Dpath) + " -name ?"+var_doy+"???."+ str(var_Dtype)
223 var_output=commands.getstatusoutput(var_cmd)[1] No newline at end of file
227 var_output=commands.getstatusoutput(var_cmd)[1]
224 No newline at end of file
228
229
No newline at end of file
230 return No newline at end of file
225 No newline at end of file
231
226 #Se cargan las listas para seleccionar StartDay y StopDay No newline at end of file
232 #Se cargan las listas para seleccionar StartDay y StopDay
227 self.var_list=[] No newline at end of file
233 self.var_list=[]
228 for i in range(0, (len(output_p2)+1)/8): No newline at end of file
234 for i in range(0, (len(output_p2)+1)/8):
229 self.var_list.append(output_p2[8*i:8*(i+1)-1]) No newline at end of file
235 self.var_list.append(output_p2[8*i:8*(i+1)-1])
230 No newline at end of file
236
231 self.lstStartDay.clear() No newline at end of file
237 self.lstStartDay.clear()
232 self.lstStopDay.clear() No newline at end of file
238 self.lstStopDay.clear()
233 No newline at end of file
239
234 for i in self.var_list: No newline at end of file
240 for i in self.var_list:
235 self.lstStartDay.addItem(i) No newline at end of file
241 self.lstStartDay.addItem(i)
236 self.lstStopDay.addItem(i) No newline at end of file
242 self.lstStopDay.addItem(i)
237 No newline at end of file
243
238 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1) No newline at end of file
244 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
General Comments 0
You need to be logged in to leave comments. Login now