##// END OF EJS Templates
***
ralonso -
r12:13
parent child
Show More
@@ -1,148 +1,153
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 27
28 28 @pyqtSignature("")
29 29 def on_btnDpath_clicked(self):
30 30 """
31 31 Slot documentation goes here.
32 32 """
33 33 var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
34 34 self.txtDpath.setText(var_Dpath)
35 35 self.on_txtDpath_editingFinished()
36 36
37 37 @pyqtSignature("")
38 38 def on_btnRpath_clicked(self):
39 39 """
40 40 Slot documentation goes here.
41 41 """
42 filename = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
43 self.txtRpath.setText(filename)
42 var_Rpath = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly)
43 self.txtRpath.setText(var_Rpath)
44 44
45 45
46 46
47 47 @pyqtSignature("")
48 48 def on_txtDpath_editingFinished(self):
49 49
50 50 #Usando el modulo "subprocess" eric4 pide seleccion del tipo de subproceso (padre o hijo)
51 51 #por ello se prefiere usar el modulo "commands"
52 52 #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE)
53 53 #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE)
54 54 #output_p2= p2.communicate()[0]
55 55 #self.txtInfo.setText(output_p2)
56 56
57 57 var_Dpath=self.txtDpath.text()
58 58
59 59 #Se verifica que la ruta exista y sea un directorio
60 60 var_cmd="test -d "+str(var_Dpath)
61 61 var_output=commands.getstatusoutput(var_cmd)[0]
62 62 if var_output != 0:
63 63 self.txtInfo.setText("Ruta no valida, output_error:" + str(var_output))
64 64 return
65 65
66 66 #Se buscan los archivos del tipo especificado
67 67 var_Dtype=self.txtDtype.text()
68 68 var_cmd="find " + str(var_Dpath) + " -name *."+ str(var_Dtype) +" | awk -F/ '{print substr($NF,2,7)}' | sort| uniq"
69 69 output_p2=commands.getstatusoutput(var_cmd)[1]
70 70
71 71 #INFO: Muestra los dias que se encontraron
72 72 self.txtInfo.setText(output_p2)
73 73
74 74 #Se cargan las listas para seleccionar StartDay y StopDay
75 75 self.var_list=[]
76 76 for i in range(0, (len(output_p2)+1)/8):
77 77 self.var_list.append(output_p2[8*i:8*(i+1)-1])
78 78
79 79 self.lstStartDay.clear()
80 80 self.lstStopDay.clear()
81 81
82 82 for i in self.var_list:
83 83 self.lstStartDay.addItem(i)
84 84 self.lstStopDay.addItem(i)
85 85
86 86 self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1)
87 87
88 88 #INFO: Muestra cuantos dias se encontraron
89 89 # self.txtInfo.setText(str(self.lstStartDay.count()))
90 90
91 91 @pyqtSignature("int")
92 92 def on_lstDtype_activated(self, index):
93 93 """
94 94 Permite elegir entre los tipos de archivos
95 95 """
96 96 if index == 0:
97 97 var_type='r'
98 98 elif index == 1:
99 99 var_type='pdata'
100 100 elif index == 2:
101 101 var_type='sswma'
102 102
103 103 if index != 3:
104 104 self.txtDtype.setText(var_type)
105 105 self.txtDtype.setReadOnly(True)
106 106 self.on_txtDpath_editingFinished()
107 107 else:
108 108 self.txtDtype.setText('')
109 109 self.txtDtype.setReadOnly(False)
110 110
111 111 @pyqtSignature("")
112 112 def on_txtDtype_editingFinished(self):
113 113 """
114 114 Se activa cuando el tipo de archivo es ingresado manualmente
115 115 """
116 116 self.on_txtDpath_editingFinished()
117 117
118 118 @pyqtSignature("int")
119 119 def on_lstStartDay_activated(self, index):
120 120 """
121 121 Slot documentation goes here.
122 122 """
123 123 self.txtInfo.setText(str(index))
124 var_StopDay_index=self.lstStopDay.currentIndex()
125 var_StopDay_index -= index
124 var_StopDay_index=self.lstStopDay.count() - self.lstStopDay.currentIndex()
126 125
127 126 self.lstStopDay.clear()
128 127
129 128 for i in self.var_list[index:]:
130 129 self.lstStopDay.addItem(i)
131 130
132 self.lstStopDay.setCurrentIndex(var_StopDay_index)
133
131 self.lstStopDay.setCurrentIndex(self.lstStopDay.count() - var_StopDay_index)
132 self.txtInfo.append(str(var_StopDay_index))
133 self.txtInfo.append(str(self.lstStopDay.count()))
134
135
134 136 @pyqtSignature("int")
135 137 def on_lstStopDay_activated(self, index):
136 138 """
137 139 Slot documentation goes here.
138 140 """
139 141 self.txtInfo.setText(str(index))
140 142 var_StartDay_index=self.lstStartDay.currentIndex()
141
143
144 var_end_index = self.lstStopDay.count() - index
145
142 146 self.lstStartDay.clear()
143 147
144 for i in self.var_list[:index+1]:
148 for i in self.var_list[:len(self.var_list) - var_end_index + 1]:
145 149 self.lstStartDay.addItem(i)
146 150
147 151 self.lstStartDay.setCurrentIndex(var_StartDay_index)
148 152 self.txtInfo.append(str(var_StartDay_index))
153 self.txtInfo.append(str(self.lstStartDay.count()))
General Comments 0
You need to be logged in to leave comments. Login now