Tue, 10 Dec 2024 15:48:56 +0100
Updated copyright for 2025.
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
58
8bfeb70bcdc3
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
55
diff
changeset
|
3 | # Copyright (c) 2018 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show the output of the pyinstaller/pyi-makespec |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | process. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
51
37e614c54ea5
Adapted some import statements to eric 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
47
diff
changeset
|
13 | from PyQt6.QtCore import QProcess, QTimer, pyqtSlot |
37e614c54ea5
Adapted some import statements to eric 23.1 and newer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
47
diff
changeset
|
14 | from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
47
3b9805bff70c
Adapted the import statements to the new structure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
46
diff
changeset
|
16 | from eric7 import Preferences |
3b9805bff70c
Adapted the import statements to the new structure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
46
diff
changeset
|
17 | from eric7.EricWidgets import EricMessageBox |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from .Ui_PyInstallerExecDialog import Ui_PyInstallerExecDialog |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | class PyInstallerExecDialog(QDialog, Ui_PyInstallerExecDialog): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Class implementing a dialog to show the output of the |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | pyinstaller/pyi-makespec process. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
26 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | This class starts a QProcess and displays a dialog that |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | shows the output of the packager command process. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
30 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | def __init__(self, cmdname, parent=None): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | Constructor |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
34 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @param cmdname name of the packager |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @type str |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @param parent reference to the parent widget |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @type QWidget |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
35
d9b3cadaf707
Implemented some code simplifications.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
34
diff
changeset
|
40 | super().__init__(parent) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.setupUi(self) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
42 | |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
43 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
44 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
45 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.__process = None |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
47 | self.__cmdname = cmdname # used for several outputs |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
48 | |
55
3794f1ca53af
Corrected some code style issues and converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
54
diff
changeset
|
49 | def start(self, args, project, script): |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | Public slot to start the packager command. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
52 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @param args command line arguments for packager program |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @type list of str |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @param project reference to the project object |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @type Project |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | @param script script or spec file name to be processed by by the |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | packager |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | @type str |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | @return flag indicating the successful start of the process |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | @rtype bool |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | self.__project = project |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
64 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | if not os.path.isabs(script): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | # assume relative paths are relative to the project directory |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | script = os.path.join(self.__project.getProjectPath(), script) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | dname = os.path.dirname(script) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.__script = os.path.basename(script) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
70 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | self.contents.clear() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
72 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | args.append(self.__script) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
74 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | self.__process = QProcess() |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.__process.setWorkingDirectory(dname) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
77 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.__process.readyReadStandardOutput.connect(self.__readStdout) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__process.readyReadStandardError.connect(self.__readStderr) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | self.__process.finished.connect(self.__finishedProcess) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
81 | |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
82 | self.setWindowTitle(self.tr("{0} - {1}").format(self.__cmdname, script)) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
83 | self.contents.insertPlainText( |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
84 | "{0} {1}\n\n".format(" ".join(args), os.path.join(dname, self.__script)) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
85 | ) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | self.contents.ensureCursorVisible() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
87 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | program = args.pop(0) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | self.__process.start(program, args) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | procStarted = self.__process.waitForStarted() |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | if not procStarted: |
38
fc9ef9dcd51a
Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
92 | EricMessageBox.critical( |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | self, |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
94 | self.tr("Process Generation Error"), |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.tr( |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
96 | "The process {0} could not be started. " |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
97 | "Ensure, that it is in the search path." |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
98 | ).format(program), |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
99 | ) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | return procStarted |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
101 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | @pyqtSlot(QAbstractButton) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | def on_buttonBox_clicked(self, button): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | Private slot called by a button of the button box clicked. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
106 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | @param button button that was clicked |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | @type QAbstractButton |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | """ |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
110 | if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | self.accept() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
112 | elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | self.__finish() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
114 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | def __finish(self): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | Private slot called when the process was canceled by the user. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
118 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | It is called when the process finished or |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | the user pressed the cancel button. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | if self.__process is not None: |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | self.__process.disconnect(self.__finishedProcess) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | self.__process.terminate() |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | QTimer.singleShot(2000, self.__process.kill) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | self.__process.waitForFinished(3000) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | self.__process = None |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
128 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | self.contents.insertPlainText( |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
130 | self.tr("\n{0} aborted.\n").format(self.__cmdname) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
131 | ) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
132 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | self.__enableButtons() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
134 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | def __finishedProcess(self): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | Private slot called when the process finished. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
138 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | It is called when the process finished or |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | the user pressed the cancel button. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | """ |
38
fc9ef9dcd51a
Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
142 | if self.__process.exitStatus() == QProcess.ExitStatus.NormalExit: |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | # add the spec file to the project |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
144 | self.__project.addToOthers(os.path.splitext(self.__script)[0] + ".spec") |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
145 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | self.__process = None |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | self.contents.insertPlainText( |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
149 | self.tr("\n{0} finished.\n").format(self.__cmdname) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
150 | ) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
151 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | self.__enableButtons() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
153 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | def __enableButtons(self): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | Private slot called when all processes finished. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
157 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | It is called when the process finished or |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | the user pressed the cancel button. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | """ |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
161 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
162 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
163 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | self.contents.ensureCursorVisible() |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | def __readStdout(self): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | Private slot to handle the readyReadStandardOutput signal. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
169 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | It reads the output of the process, formats it and inserts it into |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | the contents pane. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | """ |
38
fc9ef9dcd51a
Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
173 | self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
174 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | while self.__process.canReadLine(): |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
176 | s = str( |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
177 | self.__process.readAllStandardOutput(), |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
178 | Preferences.getSystem("IOEncoding"), |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
179 | "replace", |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
180 | ) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | self.contents.insertPlainText(s) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | self.contents.ensureCursorVisible() |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
183 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | def __readStderr(self): |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | """ |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | Private slot to handle the readyReadStandardError signal. |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
187 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | It reads the error output of the process and inserts it into the |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | error pane. |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | """ |
38
fc9ef9dcd51a
Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
35
diff
changeset
|
191 | self.__process.setReadChannel(QProcess.ProcessChannel.StandardError) |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
192 | |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | while self.__process.canReadLine(): |
46
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
194 | s = str( |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
195 | self.__process.readAllStandardError(), |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
196 | Preferences.getSystem("IOEncoding"), |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
197 | "replace", |
ccd14067e6a2
Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
43
diff
changeset
|
198 | ) |
5
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | self.contents.insertPlainText(s) |
8c92d66d20e4
Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | self.contents.ensureCursorVisible() |