12 import contextlib |
12 import contextlib |
13 |
13 |
14 from PyQt6.QtCore import pyqtSignal, QObject, QProcess, QCoreApplication |
14 from PyQt6.QtCore import pyqtSignal, QObject, QProcess, QCoreApplication |
15 from PyQt6.QtWidgets import QDialog |
15 from PyQt6.QtWidgets import QDialog |
16 |
16 |
17 from E5Gui import E5MessageBox |
17 from E5Gui import EricMessageBox |
18 |
18 |
19 import Globals |
19 import Globals |
20 import Preferences |
20 import Preferences |
21 |
21 |
22 from . import rootPrefix, condaVersion |
22 from . import rootPrefix, condaVersion |
143 exe = "conda" |
143 exe = "conda" |
144 |
144 |
145 proc = QProcess() |
145 proc = QProcess() |
146 proc.start(exe, args) |
146 proc.start(exe, args) |
147 if not proc.waitForStarted(15000): |
147 if not proc.waitForStarted(15000): |
148 E5MessageBox.critical( |
148 EricMessageBox.critical( |
149 self.__ui, |
149 self.__ui, |
150 self.tr("conda remove"), |
150 self.tr("conda remove"), |
151 self.tr("""The conda executable could not be started.""")) |
151 self.tr("""The conda executable could not be started.""")) |
152 return False |
152 return False |
153 else: |
153 else: |
156 Preferences.getSystem("IOEncoding"), |
156 Preferences.getSystem("IOEncoding"), |
157 'replace').strip() |
157 'replace').strip() |
158 try: |
158 try: |
159 jsonDict = json.loads(output) |
159 jsonDict = json.loads(output) |
160 except Exception: |
160 except Exception: |
161 E5MessageBox.critical( |
161 EricMessageBox.critical( |
162 self.__ui, |
162 self.__ui, |
163 self.tr("conda remove"), |
163 self.tr("conda remove"), |
164 self.tr("""The conda executable returned invalid data.""")) |
164 self.tr("""The conda executable returned invalid data.""")) |
165 return False |
165 return False |
166 |
166 |
167 if "error" in jsonDict: |
167 if "error" in jsonDict: |
168 E5MessageBox.critical( |
168 EricMessageBox.critical( |
169 self.__ui, |
169 self.__ui, |
170 self.tr("conda remove"), |
170 self.tr("conda remove"), |
171 self.tr("<p>The conda executable returned an error.</p>" |
171 self.tr("<p>The conda executable returned an error.</p>" |
172 "<p>{0}</p>").format(jsonDict["message"])) |
172 "<p>{0}</p>").format(jsonDict["message"])) |
173 return False |
173 return False |