@@ -1,74 +1,74 | |||
|
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 | |
|
24 | 24 | @pyqtSignature("") |
|
25 | 25 | def on_btnDpath_clicked(self): |
|
26 | 26 | """ |
|
27 | 27 | Slot documentation goes here. |
|
28 | 28 | """ |
|
29 | 29 | var_Dpath= QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) |
|
30 | 30 | self.txtDpath.setText(var_Dpath) |
|
31 | 31 | self.on_txtDpath_editingFinished() |
|
32 | 32 | |
|
33 | 33 | @pyqtSignature("") |
|
34 | 34 | def on_btnRpath_clicked(self): |
|
35 | 35 | """ |
|
36 | 36 | Slot documentation goes here. |
|
37 | 37 | """ |
|
38 | 38 | filename = QtGui.QFileDialog.getExistingDirectory(self, 'Open Directory', './', QtGui.QFileDialog.ShowDirsOnly) |
|
39 | 39 | self.txtRpath.setText(filename) |
|
40 | 40 | |
|
41 | 41 | # TODO: not implemented yet |
|
42 | 42 | # raise NotImplementedError |
|
43 | 43 | |
|
44 | 44 | @pyqtSignature("") |
|
45 | 45 | def on_txtDpath_editingFinished(self): |
|
46 | 46 | |
|
47 | 47 | var_Dpath=self.txtDpath.text() |
|
48 | 48 | |
|
49 | 49 | #Usando el modulo "subprocess" eric4 pide seleccion del tipo de subproceso (padre o hijo) |
|
50 | 50 | #por ello se prefiere usar el modulo "commands" |
|
51 | 51 | #p1= Popen(['find', var_Dpath, '-name', '*.r'], stdout=PIPE) |
|
52 | 52 | #p2= Popen(['awk', '-F/', '{print substr($NF,2,7)}'], stdin=p1.stdout, stdout=PIPE) |
|
53 | 53 | #output_p2= p2.communicate()[0] |
|
54 | 54 | #self.txtInfo.setText(output_p2) |
|
55 | 55 | |
|
56 | 56 | var_cmd="find " + str(var_Dpath) + " -name *.r | awk -F/ '{print substr($NF,2,7)}' | sort| uniq" |
|
57 | output_p2=commands.getstatusoutput(var_cmd)[] | |
|
57 | output_p2=commands.getstatusoutput(var_cmd)[1] | |
|
58 | 58 | |
|
59 | 59 | self.txtInfo.setText(output_p2) |
|
60 | 60 | |
|
61 | 61 | var_list=[] |
|
62 | 62 | for i in range(0, (len(output_p2)+1)/8): |
|
63 | 63 | var_list.append(output_p2[8*i:8*(i+1)-1]) |
|
64 | 64 | |
|
65 | 65 | self.lstStartDay.clear() |
|
66 | 66 | self.lstStopDay.clear() |
|
67 | 67 | |
|
68 | 68 | for i in var_list: |
|
69 | 69 | self.lstStartDay.addItem(i) |
|
70 | 70 | self.lstStopDay.addItem(i) |
|
71 | 71 | |
|
72 | 72 | self.txtInfo.setText(str(self.lstStartDay.count())) |
|
73 | 73 | self.lstStopDay.setCurrentIndex(self.lstStartDay.count()-1) |
|
74 | 74 |
General Comments 0
You need to be logged in to leave comments.
Login now