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