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