Tue, 29 Oct 2013 22:30:48 +0100
Merged with code styles issues cleaned.
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
34
d20f7218d53c
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
3 | # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog showing the available routes. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
10 | from __future__ import unicode_literals # __IGNORE_WARNING__ |
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
11 | try: |
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
12 | str = unicode |
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
13 | except (NameError): |
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
14 | pass |
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
15 | |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | import os |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from PyQt4.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from PyQt4.QtGui import QDialog, QDialogButtonBox, QLineEdit, QTreeWidgetItem |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | from E5Gui import E5MessageBox |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | from .Ui_PyramidRoutesDialog import Ui_PyramidRoutesDialog |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | import Preferences |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | class PyramidRoutesDialog(QDialog, Ui_PyramidRoutesDialog): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | Class implementing a dialog showing the available routes. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | def __init__(self, project, parent=None): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | Constructor |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
36 | @param project reference to the project object |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
37 | (ProjectPyramid.Project.Project) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @param parent reference to the parent widget (QWidget) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
40 | super(PyramidRoutesDialog, self).__init__(parent) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.setupUi(self) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.__project = project |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.buffer = "" |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | self.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | def finish(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
55 | Public slot called when the process finished or the user pressed the |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
56 | button. |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | if self.proc is not None and \ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.proc.state() != QProcess.NotRunning: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.proc.terminate() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | QTimer.singleShot(2000, self.proc.kill) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | self.proc.waitForFinished(3000) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.inputGroup.setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.inputGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.__processBuffer() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
74 | self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
75 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | def on_buttonBox_clicked(self, button): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | Private slot called by a button of the button box clicked. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | @param button button that was clicked (QAbstractButton) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | if button == self.buttonBox.button(QDialogButtonBox.Close): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | self.close() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | def __procFinished(self, exitCode, exitStatus): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | Private slot connected to the finished signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | @param exitCode exit code of the process (integer) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | @param exitStatus exit status of the process (QProcess.ExitStatus) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.normal = (exitStatus == QProcess.NormalExit) and (exitCode == 0) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | def __processBuffer(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | Private slot to process the output buffer of the proutes command. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | self.routes.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | if not self.buffer: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | QTreeWidgetItem(self.routes, [self.trUtf8("No routes found.")]) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | lines = self.buffer.splitlines() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | row = 0 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | headers = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if lines[row].strip().startswith("---"): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | headerLine = lines[row - 1] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | headers = headerLine.split() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | break |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | if headers: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | self.routes.setHeaderLabels(headers) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.routes.setHeaderHidden(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | splitCount = len(headers) - 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | line = lines[row].strip() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | parts = line.split(None, splitCount) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | QTreeWidgetItem(self.routes, parts) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | for column in range(len(headers)): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | self.routes.resizeColumnToContents(column) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | def start(self, projectPath): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | Public slot used to start the process. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | @param projectPath path to the Pyramid project (string) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | @return flag indicating a successful start of the process |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | QTreeWidgetItem(self.routes, [self.trUtf8("Getting routes...")]) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | self.errorGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | self.normal = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
147 | self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
148 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | self.proc = QProcess() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.proc.finished.connect(self.__procFinished) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | self.proc.readyReadStandardOutput.connect(self.__readStdout) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | self.proc.readyReadStandardError.connect(self.__readStderr) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | cmd = self.__project.getPyramidCommand("proutes") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | args = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | args.append("development.ini") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | if projectPath: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | self.proc.setWorkingDirectory(projectPath) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | self.proc.start(cmd, args) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | procStarted = self.proc.waitForStarted() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | if not procStarted: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.buttonBox.setFocus() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.inputGroup.setEnabled(False) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
167 | E5MessageBox.critical( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
168 | self, |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | self.trUtf8('Process Generation Error'), |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | self.trUtf8( |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | 'The process {0} could not be started. ' |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | 'Ensure, that it is in the search path.' |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | ).format(cmd)) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | self.inputGroup.setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | self.inputGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | return procStarted |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | def __readStdout(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | Private slot to handle the readyReadStandardOutput signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | It reads the output of the process and appends it to a buffer for |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | delayed processing. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | if self.proc is not None: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | out = str(self.proc.readAllStandardOutput(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
188 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
189 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | self.buffer += out |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | def __readStderr(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | Private slot to handle the readyReadStandardError signal. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | It reads the error output of the process and inserts it into the |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | error pane. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | if self.proc is not None: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | err = str(self.proc.readAllStandardError(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
201 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
202 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | self.errorGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.errors.insertPlainText(err) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | def on_passwordCheckBox_toggled(self, isOn): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | Private slot to handle the password checkbox toggled. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | @param isOn flag indicating the status of the check box (boolean) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | if isOn: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | self.input.setEchoMode(QLineEdit.Password) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | self.input.setEchoMode(QLineEdit.Normal) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | @pyqtSlot() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | def on_sendButton_clicked(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | Private slot to send the input to the subversion process. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | input = self.input.text() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | input += os.linesep |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | if self.passwordCheckBox.isChecked(): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | self.errors.insertPlainText(os.linesep) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.proc.write(input) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | self.passwordCheckBox.setChecked(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | self.input.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | def on_input_returnPressed(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | Private slot to handle the press of the return key in the input field. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | self.intercept = True |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | self.on_sendButton_clicked() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | def keyPressEvent(self, evt): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | Protected slot to handle a key press event. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | @param evt the key press event (QKeyEvent) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | if self.intercept: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | evt.accept() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | return |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
254 | super(PyramidRoutesDialog, self).keyPressEvent(evt) |