Sun, 29 Dec 2024 14:56:04 +0100
Prepared a new release.
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
104
45c88e73e3dd
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
69
diff
changeset
|
3 | # Copyright (c) 2024 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
9
2ab7d3ac8283
Implemented the 'pipx install' and 'pipx install-all' functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
4 | # |
2ab7d3ac8283
Implemented the 'pipx install' and 'pipx install-all' functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
5 | |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter the application command line parameters and |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | to execute the app. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import shlex |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from PyQt6.QtCore import QCoreApplication, QProcess, Qt, QTimer, pyqtSlot |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
15 | from PyQt6.QtWidgets import QAbstractButton, QComboBox, QDialog, QDialogButtonBox |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from eric7 import Preferences |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from eric7.EricGui import EricPixmapCache |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from eric7.EricWidgets import EricMessageBox |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
20 | from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | from .Ui_PipxAppStartDialog import Ui_PipxAppStartDialog |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | class PipxAppStartDialog(QDialog, Ui_PipxAppStartDialog): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Class implementing a dialog to enter the application command line parameters and |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | to execute the app. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
31 | def __init__(self, app, plugin, parent=None): |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | Constructor |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @param app path of the application to be executed |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @type str |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
37 | @param plugin reference to the plug-in object |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
38 | @type PluginPipxInterface |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @param parent reference to the parent widget (defaults to None) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @type QWidget (optional) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | super().__init__(parent) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.setupUi(self) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.executeButton.setIcon(EricPixmapCache.getIcon("start")) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
47 | self.workdirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
48 | self.workdirPicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
49 | |
69 | 50 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
51 | ||
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
52 | self.__plugin = plugin |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
53 | |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.__process = None |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.appLabel.setText(app) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.errorGroup.hide() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
59 | self.__populateWorkDirs() |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
60 | |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.parametersEdit.returnPressed.connect(self.on_executeButton_clicked) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | def closeEvent(self, e): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | Protected slot implementing a close event handler. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | @param e close event |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | @type QCloseEvent |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.__cancel() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | e.accept() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | def __finish(self): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | Private slot called when the process finished or the user pressed |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | the button. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | if ( |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__process is not None |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | and self.__process.state() != QProcess.ProcessState.NotRunning |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | ): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | self.__process.terminate() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | QTimer.singleShot(2000, self.__process.kill) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | self.__process.waitForFinished(3000) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | self.__process = None |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | self.executeButton.setEnabled(True) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | self.parametersEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | self.parametersEdit.selectAll() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | def __cancel(self): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | Private slot to cancel the current action. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | self.__finish() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | @pyqtSlot(QAbstractButton) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | def on_buttonBox_clicked(self, button): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | Private slot called by a button of the button box clicked. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | @param button button that was clicked |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | @type QAbstractButton |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | self.close() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | self.__cancel() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | @pyqtSlot(int, QProcess.ExitStatus) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | def __procFinished(self, _exitCode, _exitStatus): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | Private slot connected to the finished signal. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | @param _exitCode exit code of the process (unused) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | @type int |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | @param _exitStatus exit status of the process (unused) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | @type QProcess.ExitStatus |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | self.__finish() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | @pyqtSlot() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | def on_executeButton_clicked(self): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | Private slot to execute the selected app with the entered parameters. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | self.executeButton.setEnabled(False) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
135 | # clear output of last run |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
136 | self.resultbox.clear() |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
137 | self.errors.clear() |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
138 | self.errorGroup.hide() |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
139 | |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
140 | workdir = self.workdirPicker.text() |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | command = self.parametersEdit.text() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | args = shlex.split(command) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | self.__process = QProcess() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.__process.finished.connect(self.__procFinished) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | self.__process.readyReadStandardOutput.connect(self.__readStdout) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | self.__process.readyReadStandardError.connect(self.__readStderr) |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
148 | if os.path.isdir(workdir) or workdir == "": |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
149 | self.__populateWorkDirs(workdir) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
150 | self.__process.setWorkingDirectory(workdir) |
4
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | self.__process.start(self.appLabel.text(), args) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | procStarted = self.__process.waitForStarted(5000) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | if not procStarted: |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | self.buttonBox.setFocus() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | EricMessageBox.critical( |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | self, |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | self.tr("Process Generation Error"), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | self.tr("The process {0} could not be started.").format( |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | os.path.basename(self.appLabel.text()) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | ), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | ) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | def __readStdout(self): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | Private slot to handle the readyReadStandardOutput signal. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | It reads the output of the process, formats it and inserts it into |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | the contents pane. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | if self.__process is not None: |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | txt = str( |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | self.__process.readAllStandardOutput(), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | Preferences.getSystem("IOEncoding"), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | "replace", |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | ) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | self.__addOutput(txt) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | def __addOutput(self, txt): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | Private method to add some text to the output pane. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | @param txt text to be added |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | @type str |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | self.resultbox.insertPlainText(txt) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | self.resultbox.ensureCursorVisible() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | QCoreApplication.processEvents() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | def __readStderr(self): |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | Private slot to handle the readyReadStandardError signal. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | It reads the error output of the process and inserts it into the |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | error pane. |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | """ |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | if self.__process is not None: |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | s = str( |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | self.__process.readAllStandardError(), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | Preferences.getSystem("IOEncoding"), |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | "replace", |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | ) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | self.errorGroup.show() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | self.errors.insertPlainText(s) |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.errors.ensureCursorVisible() |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | |
097a06104774
Implemented two foundational dialogs for executing pipx commands and running applications from the list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | QCoreApplication.processEvents() |
7
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
207 | |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
208 | def __populateWorkDirs(self, mostRecent=None): |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
209 | """ |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
210 | Private method to populate the working directory selector. |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
211 | |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
212 | @param mostRecent most recently used working directory |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
213 | @type str |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
214 | """ |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
215 | workDirList = self.__plugin.getPreferences("RecentAppWorkdirs") |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
216 | if mostRecent is not None: |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
217 | if mostRecent in workDirList: |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
218 | # push it to the beginning of the list |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
219 | workDirList.remove(mostRecent) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
220 | workDirList.insert(0, mostRecent) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
221 | workDirList = workDirList[ |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
222 | : self.__plugin.getPreferences("MaxRecentAppWorkdirs") |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
223 | ] |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
224 | self.__plugin.setPreferences("RecentAppWorkdirs", workDirList) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
225 | |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
226 | self.workdirPicker.clear() |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
227 | self.workdirPicker.addItems(workDirList) |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
228 | if len(workDirList) > 0: |
9a98f7260372
Modified the application execution dialog to allow the selection of a working directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4
diff
changeset
|
229 | self.workdirPicker.setCurrentIndex(0) |