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