Fri, 11 Jul 2014 19:01:33 +0200
Ported to PyQt5 and eric6.
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 | |
63
f249a66da0d5
Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
57
diff
changeset
|
3 | # Copyright (c) 2012 - 2014 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 | |
71
8a78fab32c18
Added the Python2 compatibility flag.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
63
diff
changeset
|
10 | from __future__ import unicode_literals |
56
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 |
71
8a78fab32c18
Added the Python2 compatibility flag.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
63
diff
changeset
|
13 | except NameError: |
56
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 | |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
18 | from PyQt5.QtCore import QProcess, QTimer, pyqtSlot, Qt, QCoreApplication |
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
19 | from PyQt5.QtWidgets import (QDialog, QDialogButtonBox, QLineEdit, |
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
20 | QTreeWidgetItem) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | from E5Gui import E5MessageBox |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | 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
|
25 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | import Preferences |
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 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | class PyramidRoutesDialog(QDialog, Ui_PyramidRoutesDialog): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | 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
|
32 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | 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
|
34 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Constructor |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
37 | @param project reference to the project object |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
38 | (ProjectPyramid.Project.Project) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @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
|
40 | """ |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
41 | 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
|
42 | self.setupUi(self) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | 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
|
45 | 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
|
46 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.__project = project |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | self.buffer = "" |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | def finish(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | """ |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
56 | 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
|
57 | button. |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | 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
|
60 | self.proc.state() != QProcess.NotRunning: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.proc.terminate() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | 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
|
63 | self.proc.waitForFinished(3000) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.inputGroup.setEnabled(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.inputGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | self.proc = None |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.__processBuffer() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | 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
|
73 | 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
|
74 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
75 | self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
76 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | 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
|
79 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | 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
|
81 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @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
|
83 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | 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
|
85 | self.close() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | 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
|
87 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | def __procFinished(self, exitCode, exitStatus): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | 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
|
92 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | @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
|
94 | @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
|
95 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | 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
|
97 | self.finish() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | def __processBuffer(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | 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
|
102 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | self.routes.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | if not self.buffer: |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
106 | QTreeWidgetItem(self.routes, [self.tr("No routes found.")]) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | lines = self.buffer.splitlines() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | row = 0 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | headers = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | if lines[row].strip().startswith("---"): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | headerLine = lines[row - 1] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | headers = headerLine.split() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | break |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | if headers: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.routes.setHeaderLabels(headers) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | self.routes.setHeaderHidden(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | splitCount = len(headers) - 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | while row < len(lines): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | line = lines[row].strip() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | parts = line.split(None, splitCount) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | QTreeWidgetItem(self.routes, parts) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | row += 1 |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | 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
|
129 | self.routes.resizeColumnToContents(column) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | def start(self, projectPath): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | 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
|
134 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | @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
|
136 | @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
|
137 | """ |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
138 | QTreeWidgetItem(self.routes, [self.tr("Getting routes...")]) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | self.routes.setHeaderHidden(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | self.errorGroup.hide() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | self.normal = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | 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
|
146 | 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
|
147 | self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
148 | self.buttonBox.button(QDialogButtonBox.Cancel).setFocus( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
149 | Qt.OtherFocusReason) |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | self.proc = QProcess() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | 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
|
154 | 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
|
155 | 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
|
156 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | cmd = self.__project.getPyramidCommand("proutes") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | args = [] |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | args.append("development.ini") |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | if projectPath: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | self.proc.setWorkingDirectory(projectPath) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | self.proc.start(cmd, args) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | procStarted = self.proc.waitForStarted() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | if not procStarted: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | self.buttonBox.setFocus() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | self.inputGroup.setEnabled(False) |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
168 | E5MessageBox.critical( |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
169 | self, |
74
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
170 | self.tr('Process Generation Error'), |
11587ae1122f
Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
71
diff
changeset
|
171 | self.tr( |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | '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
|
173 | '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
|
174 | ).format(cmd)) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | self.inputGroup.setEnabled(True) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | self.inputGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | return procStarted |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | def __readStdout(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | 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
|
183 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | 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
|
185 | delayed processing. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | 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
|
188 | out = str(self.proc.readAllStandardOutput(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
189 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
190 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | self.buffer += out |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | def __readStderr(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | 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
|
196 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | 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
|
198 | error pane. |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | 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
|
201 | err = str(self.proc.readAllStandardError(), |
54
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
202 | Preferences.getSystem("IOEncoding"), |
71c83a661c83
Fixed code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
203 | 'replace') |
13
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.errorGroup.show() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.errors.insertPlainText(err) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | QCoreApplication.processEvents() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | 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
|
211 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | 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
|
213 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | @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
|
215 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | if isOn: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | self.input.setEchoMode(QLineEdit.Password) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | else: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | self.input.setEchoMode(QLineEdit.Normal) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | @pyqtSlot() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | def on_sendButton_clicked(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | 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
|
225 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | input = self.input.text() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | input += os.linesep |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | if self.passwordCheckBox.isChecked(): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | self.errors.insertPlainText(os.linesep) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | self.errors.ensureCursorVisible() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | self.proc.write(input) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | self.passwordCheckBox.setChecked(False) |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | self.input.clear() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | def on_input_returnPressed(self): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | 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
|
241 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | self.intercept = True |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | self.on_sendButton_clicked() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | def keyPressEvent(self, evt): |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | 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
|
248 | |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | @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
|
250 | """ |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | if self.intercept: |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | self.intercept = False |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | evt.accept() |
227a115ab2a1
Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | return |
56
c7adc68350dd
Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
34
diff
changeset
|
255 | super(PyramidRoutesDialog, self).keyPressEvent(evt) |