PyInstallerInterface/PyInstallerExecDialog.py

Sat, 31 Dec 2022 16:27:47 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Dec 2022 16:27:47 +0100
branch
eric7
changeset 53
415055c7aa74
parent 51
37e614c54ea5
child 54
359e2d772474
permissions
-rw-r--r--

Updated copyright for 2023.

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
53
415055c7aa74 Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 51
diff changeset
3 # Copyright (c) 2018 - 2023 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
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def start(self, args, parms, project, script):
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 parms parameters got from the config dialog
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @type dict
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @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
58 @type Project
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @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
60 packager
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @type str
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @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
63 @rtype bool
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__project = project
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
66
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 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
68 # 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
69 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
70 dname = os.path.dirname(script)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__script = os.path.basename(script)
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 self.contents.clear()
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 args.append(self.__script)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
76
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__process = QProcess()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__process.setWorkingDirectory(dname)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
79
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 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
81 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
82 self.__process.finished.connect(self.__finishedProcess)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
83
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
84 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
85 self.contents.insertPlainText(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
86 "{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
87 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.contents.ensureCursorVisible()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
89
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 program = args.pop(0)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__process.start(program, args)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 procStarted = self.__process.waitForStarted()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 if not procStarted:
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
94 EricMessageBox.critical(
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self,
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
96 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
97 self.tr(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
98 "The process {0} could not be started. "
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
99 "Ensure, that it is in the search path."
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
100 ).format(program),
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 return procStarted
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
103
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @pyqtSlot(QAbstractButton)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 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
106 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 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
108
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @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
110 @type QAbstractButton
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 """
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
112 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
113 self.accept()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
114 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
115 self.__finish()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
116
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 def __finish(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 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
120
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 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
122 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
123 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 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
125 self.__process.disconnect(self.__finishedProcess)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.__process.terminate()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 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
128 self.__process.waitForFinished(3000)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__process = None
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
130
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.contents.insertPlainText(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
132 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
133 )
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 self.__enableButtons()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
136
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def __finishedProcess(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Private slot called when the process finished.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
140
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 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
142 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
143 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
144 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
145 # add the spec file to the project
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
146 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
147
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__process = None
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.contents.insertPlainText(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
151 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
152 )
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 self.__enableButtons()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
155
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def __enableButtons(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Private slot called when all processes finished.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
159
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 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
161 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
162 """
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
163 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
164 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
165 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
166 self.contents.ensureCursorVisible()
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 def __readStdout(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot to handle the readyReadStandardOutput signal.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
171
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 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
173 the contents pane.
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
175 self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
176
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 while self.__process.canReadLine():
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
178 s = str(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
179 self.__process.readAllStandardOutput(),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
180 Preferences.getSystem("IOEncoding"),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
181 "replace",
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
182 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.contents.insertPlainText(s)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.contents.ensureCursorVisible()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
185
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 def __readStderr(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 Private slot to handle the readyReadStandardError signal.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
189
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 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
191 error pane.
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
193 self.__process.setReadChannel(QProcess.ProcessChannel.StandardError)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
194
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 while self.__process.canReadLine():
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
196 s = str(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
197 self.__process.readAllStandardError(),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
198 Preferences.getSystem("IOEncoding"),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
199 "replace",
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
200 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.contents.insertPlainText(s)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.contents.ensureCursorVisible()

eric ide

mercurial