Mon, 22 Apr 2024 15:15:36 +0200
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10065
diff
changeset
|
3 | # Copyright (c) 2019 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show the output of a conda execution. |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import json |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
12 | from PyQt6.QtCore import QProcess, QTimer, pyqtSlot |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
13 | from PyQt6.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
15 | from eric7 import Globals, Preferences |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
16 | from eric7.EricWidgets import EricMessageBox |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | from .Ui_CondaExecDialog import Ui_CondaExecDialog |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | class CondaExecDialog(QDialog, Ui_CondaExecDialog): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
6678
5f1de9e59227
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6677
diff
changeset
|
23 | Class implementing a dialog to show the output of a conda execution. |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
26 | def __init__(self, command, parent=None): |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
29 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
30 | @param command conda command executed |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
31 | @type str |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | @param parent reference to the parent widget |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @type QWidget |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
35 | super().__init__(parent) |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
41 | self.__condaCommand = command |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.__process = None |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.__condaExe = Preferences.getConda("CondaExecutable") |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | if not self.__condaExe: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.__condaExe = "conda" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | @pyqtSlot(QAbstractButton) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | def on_buttonBox_clicked(self, button): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | Private slot called by a button of the button box clicked. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @param button button that was clicked |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @type QAbstractButton |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close): |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.accept() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
6679
c5f7b2e9a06d
CondaExecDialog: fixed abug calling the finish method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6678
diff
changeset
|
59 | self.__finish(1, 0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | def start(self, arguments): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Public slot to start the conda command. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | @param arguments commandline arguments for conda program |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | @type list of str |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | self.errorGroup.hide() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.progressLabel.hide() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.progressBar.hide() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
71 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.contents.clear() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.errors.clear() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | self.progressLabel.clear() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | self.progressBar.setValue(0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
76 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | self.__bufferedStdout = None |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.__json = "--json" in arguments |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | self.__firstProgress = True |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
80 | self.__lastFetchFile = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
82 | self.__statusOk = False |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
83 | self.__result = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
84 | |
6706
d792e054cde2
Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6697
diff
changeset
|
85 | self.__logOutput(self.__condaExe + " " + " ".join(arguments) + "\n\n") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
86 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | self.__process = QProcess() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.__process.readyReadStandardOutput.connect(self.__readStdout) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | self.__process.readyReadStandardError.connect(self.__readStderr) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | self.__process.finished.connect(self.__finish) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
91 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | self.__process.start(self.__condaExe, arguments) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | procStarted = self.__process.waitForStarted(5000) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | if not procStarted: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
95 | EricMessageBox.critical( |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | self, |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | self.tr("Conda Execution"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
99 | """The conda executable could not be started. Is it""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
100 | """ configured correctly?""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
101 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
102 | ) |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | self.__finish(1, 0) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | else: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | self.__logOutput(self.tr("Operation started.\n")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
106 | |
10065
de4ae767b0e3
Corrected and checked some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
107 | @pyqtSlot(int, QProcess.ExitStatus) |
10689
3ede487187f2
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
108 | def __finish(self, exitCode, _exitStatus): |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | Private slot called when the process finished. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | It is called when the process finished or |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | the user pressed the button. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
114 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
115 | @param exitCode exit code of the process |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
116 | @type int |
10689
3ede487187f2
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
117 | @param _exitStatus exit status of the process (unused) |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
118 | @type QProcess.ExitStatus |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
120 | if ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
121 | self.__process is not None |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
122 | and self.__process.state() != QProcess.ProcessState.NotRunning |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
123 | ): |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | self.__process.terminate() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | QTimer.singleShot(2000, self.__process.kill) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | self.__process.waitForFinished(3000) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
127 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
128 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
130 | self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
132 | self.progressLabel.hide() |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
133 | self.progressBar.hide() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
134 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
135 | self.__statusOk = exitCode == 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
136 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | self.__logOutput(self.tr("Operation finished.\n")) |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
138 | if not self.__json and self.__bufferedStdout: |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
139 | self.__logOutput(self.__bufferedStdout) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
141 | if self.__json and self.__bufferedStdout: |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
142 | index = self.__bufferedStdout.find("{") |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
143 | rindex = self.__bufferedStdout.rfind("}") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
144 | self.__bufferedStdout = self.__bufferedStdout[index : rindex + 1] |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
145 | try: |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
146 | self.__result = json.loads(self.__bufferedStdout) |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
147 | except Exception as error: |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
148 | self.__result = {} |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
149 | self.__logError(str(error)) |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
150 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
151 | |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
152 | if "error" in self.__result: |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
153 | self.__logError(self.__result["error"]) |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
154 | self.__statusOk = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | elif "success" in self.__result and not self.__result["success"]: |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
156 | self.__logError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
157 | self.tr("Conda command '{0}' did not return success.").format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
158 | self.__condaCommand |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
159 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | ) |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
161 | if "message" in self.__result: |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
162 | self.__logError("\n") |
6685
fbaee9890715
CondaExecDialog: did some cleanup and streamlining.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6683
diff
changeset
|
163 | self.__logError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
164 | self.tr("\nConda Message: {0}").format(self.__result["message"]) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
165 | ) |
6741
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
166 | self.__statusOk = False |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
167 | elif "message" in self.__result: |
33a82a20dd3a
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6717
diff
changeset
|
168 | self.__logOutput( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
169 | self.tr("\nConda Message: {0}").format(self.__result["message"]) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
170 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
171 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
172 | def getResult(self): |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | """ |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
174 | Public method to the result of the command execution. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
175 | |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
176 | @return tuple containing a flag indicating success and the result data. |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
177 | @rtype tuple of (bool, dict) |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
178 | """ |
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
179 | return self.__statusOk, self.__result |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
180 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
181 | def __setProgressValues(self, jsonDict, progressType): |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
182 | """ |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
183 | Private method to set the value of the progress bar. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
184 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
185 | @param jsonDict dictionary containing the progress info |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
186 | @type dict |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
187 | @param progressType action type to check for |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
188 | @type str |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
189 | @return flag indicating success |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
190 | @rtype bool |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
191 | """ |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
192 | if progressType in jsonDict and "progress" in jsonDict: |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
193 | if jsonDict["maxval"] == 1: |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
194 | self.progressBar.setMaximum(100) |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
195 | # percent values |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
196 | self.progressBar.setValue(int(jsonDict["progress"] * 100)) |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
197 | parts = jsonDict["fetch"].split("|") |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
198 | filename = parts[0].strip() |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
199 | filesize = parts[1].strip() |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
200 | else: |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
201 | self.progressBar.setMaximum(jsonDict["maxval"]) |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
202 | self.progressBar.setValue(jsonDict["progress"]) |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
203 | filename = jsonDict["fetch"].strip() |
6697
2f5c951bdf14
Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6685
diff
changeset
|
204 | filesize = Globals.dataString(int(jsonDict["maxval"])) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
205 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
206 | self.progressLabel.setText( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
207 | self.tr("{0} (Size: {1})").format(filename, filesize) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
208 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
209 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
210 | if progressType == "fetch": |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
211 | if filename != self.__lastFetchFile: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
212 | self.__logOutput(self.tr("Fetching {0} ...").format(filename)) |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
213 | self.__lastFetchFile = filename |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
214 | elif jsonDict["finished"]: |
6717
afc972591ed2
CondaExecDialog: small enhancement to the output.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6714
diff
changeset
|
215 | self.__logOutput(self.tr(" Done.\n")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
216 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
217 | if self.__firstProgress: |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
218 | self.progressLabel.show() |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
219 | self.progressBar.show() |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
220 | self.__firstProgress = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
221 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
222 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
223 | |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
224 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
225 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | def __readStdout(self): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | Private slot to handle the readyReadStandardOutput signal. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
229 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | It reads the output of the process, formats it and inserts it into |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | the contents pane. |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
233 | all_stdout = str( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
234 | self.__process.readAllStandardOutput(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
235 | Preferences.getSystem("IOEncoding"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
236 | "replace", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
237 | ) |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | all_stdout = all_stdout.replace("\x00", "") |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | if self.__json: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | for stdout in all_stdout.splitlines(): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | try: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | jsonDict = json.loads(stdout.replace("\x00", "").strip()) |
6683
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
243 | if self.__setProgressValues(jsonDict, "fetch"): |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
244 | # nothing to do anymore |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
245 | pass |
aca9d39fbfbd
CondaExecDialog: finished the progress bar function
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6679
diff
changeset
|
246 | elif "progress" not in jsonDict: |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | if self.__bufferedStdout is None: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | self.__bufferedStdout = stdout |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | else: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | self.__bufferedStdout += stdout |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | except (TypeError, ValueError): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | if self.__bufferedStdout is None: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | self.__bufferedStdout = stdout |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | else: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | self.__bufferedStdout += stdout |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | else: |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | self.__logOutput(all_stdout) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
258 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | def __readStderr(self): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | Private slot to handle the readyReadStandardError signal. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
262 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | It reads the error output of the process and inserts it into the |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | error pane. |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
266 | self.__process.setReadChannel(QProcess.ProcessChannel.StandardError) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
267 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | while self.__process.canReadLine(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
269 | stderr = str( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
270 | self.__process.readLine(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
271 | Preferences.getSystem("IOEncoding"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
272 | "replace", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
273 | ) |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | self.__logError(stderr) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
275 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | def __logOutput(self, stdout): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | Private method to log some output. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
279 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | @param stdout output string to log |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
281 | @type str |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | self.contents.insertPlainText(stdout) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | self.contents.ensureCursorVisible() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
285 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | def __logError(self, stderr): |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | Private method to log an error. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
289 | |
6677
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | @param stderr error string to log |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | @type str |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | """ |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | self.errorGroup.show() |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | self.errors.insertPlainText(stderr) |
6299d69a218a
Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | self.errors.ensureCursorVisible() |