PyInstallerInterface/PyInstallerExecDialog.py

Wed, 21 Sep 2022 16:45:00 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 21 Sep 2022 16:45:00 +0200
branch
eric7
changeset 46
ccd14067e6a2
parent 43
01ce3d6f7a07
child 47
3b9805bff70c
permissions
-rw-r--r--

Reformatted source code with 'Black'.

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
43
01ce3d6f7a07 Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 38
diff changeset
3 # Copyright (c) 2018 - 2022 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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
13 from PyQt6.QtCore import pyqtSlot, QProcess, QTimer
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
16 from EricWidgets import EricMessageBox
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 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
19
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
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
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class PyInstallerExecDialog(QDialog, Ui_PyInstallerExecDialog):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 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
26 pyinstaller/pyi-makespec process.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
27
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29 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
30 """
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
31
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 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
33 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
35
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @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
37 @type str
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @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
39 @type QWidget
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
35
d9b3cadaf707 Implemented some code simplifications.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
41 super().__init__(parent)
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setupUi(self)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
43
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
44 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
45 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
46
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__process = None
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
48 self.__cmdname = cmdname # used for several outputs
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
49
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 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
51 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 Public slot to start the packager command.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
53
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @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
55 @type list of str
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @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
57 @type dict
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @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
59 @type Project
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @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
61 packager
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @type str
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @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
64 @rtype bool
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__project = project
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
67
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 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
69 # 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
70 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
71 dname = os.path.dirname(script)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__script = os.path.basename(script)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
73
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.contents.clear()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
75
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 args.append(self.__script)
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 = QProcess()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__process.setWorkingDirectory(dname)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
80
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 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
82 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
83 self.__process.finished.connect(self.__finishedProcess)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
84
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
85 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
86 self.contents.insertPlainText(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
87 "{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
88 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.contents.ensureCursorVisible()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
90
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 program = args.pop(0)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__process.start(program, args)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 procStarted = self.__process.waitForStarted()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 if not procStarted:
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
95 EricMessageBox.critical(
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self,
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
97 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
98 self.tr(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
99 "The process {0} could not be started. "
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
100 "Ensure, that it is in the search path."
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
101 ).format(program),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
102 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 return procStarted
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
104
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @pyqtSlot(QAbstractButton)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 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
107 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 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
109
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @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
111 @type QAbstractButton
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
113 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
114 self.accept()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
115 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
116 self.__finish()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
117
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 def __finish(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 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
121
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 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
123 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
124 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 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
126 self.__process.disconnect(self.__finishedProcess)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.__process.terminate()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 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
129 self.__process.waitForFinished(3000)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__process = None
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
131
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.contents.insertPlainText(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
133 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
134 )
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
135
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.__enableButtons()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
137
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 def __finishedProcess(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 Private slot called when the process finished.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
141
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 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
143 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
144 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
145 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
146 # add the spec file to the project
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
147 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
148
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__process = None
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.contents.insertPlainText(
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
152 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
153 )
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
154
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 self.__enableButtons()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
156
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 def __enableButtons(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 Private slot called when all processes finished.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
160
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 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
162 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
163 """
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
164 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
165 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
166 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
167 self.contents.ensureCursorVisible()
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def __readStdout(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Private slot to handle the readyReadStandardOutput signal.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
172
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 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
174 the contents pane.
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
176 self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
177
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 while self.__process.canReadLine():
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
179 s = str(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
180 self.__process.readAllStandardOutput(),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
181 Preferences.getSystem("IOEncoding"),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
182 "replace",
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 self.contents.insertPlainText(s)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.contents.ensureCursorVisible()
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
186
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 def __readStderr(self):
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 """
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 Private slot to handle the readyReadStandardError signal.
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
190
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 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
192 error pane.
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
194 self.__process.setReadChannel(QProcess.ProcessChannel.StandardError)
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
195
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 while self.__process.canReadLine():
46
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
197 s = str(
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
198 self.__process.readAllStandardError(),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
199 Preferences.getSystem("IOEncoding"),
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
200 "replace",
ccd14067e6a2 Reformatted source code with 'Black'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 43
diff changeset
201 )
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.contents.insertPlainText(s)
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.contents.ensureCursorVisible()

eric ide

mercurial