94 if os.path.exists(python): |
103 if os.path.exists(python): |
95 break |
104 break |
96 else: |
105 else: |
97 python = "" |
106 python = "" |
98 |
107 |
|
108 self.condaEnvironmentCreated.emit() |
99 return True, prefix, python |
109 return True, prefix, python |
100 else: |
110 else: |
101 return False, "", "" |
111 return False, "", "" |
102 |
112 |
103 def removeCondaEnvironment(self, name="", prefix=""): |
113 def removeCondaEnvironment(self, name="", prefix=""): |
163 self.tr("conda remove"), |
173 self.tr("conda remove"), |
164 self.tr("<p>The conda executable returned an error.</p>" |
174 self.tr("<p>The conda executable returned an error.</p>" |
165 "<p>{0}</p>").format(jsonDict["message"])) |
175 "<p>{0}</p>").format(jsonDict["message"])) |
166 return False |
176 return False |
167 |
177 |
|
178 if jsonDict["success"]: |
|
179 self.condaEnvironmentRemoved.emit() |
|
180 |
168 return jsonDict["success"] |
181 return jsonDict["success"] |
|
182 |
|
183 return False |
169 |
184 |
170 def getCondaEnvironmentsList(self): |
185 def getCondaEnvironmentsList(self): |
171 """ |
186 """ |
172 Public method to get a list of all Conda environments. |
187 Public method to get a list of all Conda environments. |
173 |
188 |
220 @param prefix prefix of the environment |
235 @param prefix prefix of the environment |
221 @type str |
236 @type str |
222 @return list of installed packages. Each entry is a tuple containing |
237 @return list of installed packages. Each entry is a tuple containing |
223 the package name, version and build. |
238 the package name, version and build. |
224 @rtype list of tuples of (str, str, str) |
239 @rtype list of tuples of (str, str, str) |
225 @rtype bool |
|
226 @exception RuntimeError raised to indicate an error in parameters |
240 @exception RuntimeError raised to indicate an error in parameters |
227 |
241 |
228 Note: only one of name or prefix must be given. |
242 Note: only one of name or prefix must be given. |
229 """ |
243 """ |
230 if name and prefix: |
244 if name and prefix: |
282 @param prefix prefix of the environment |
296 @param prefix prefix of the environment |
283 @type str |
297 @type str |
284 @return list of installed packages. Each entry is a tuple containing |
298 @return list of installed packages. Each entry is a tuple containing |
285 the package name, version and build. |
299 the package name, version and build. |
286 @rtype list of tuples of (str, str, str) |
300 @rtype list of tuples of (str, str, str) |
287 @rtype bool |
|
288 @exception RuntimeError raised to indicate an error in parameters |
301 @exception RuntimeError raised to indicate an error in parameters |
289 |
302 |
290 Note: only one of name or prefix must be given. |
303 Note: only one of name or prefix must be given. |
291 """ |
304 """ |
292 if name and prefix: |
305 if name and prefix: |
347 @type list of str |
360 @type list of str |
348 @param name name of the environment |
361 @param name name of the environment |
349 @type str |
362 @type str |
350 @param prefix prefix of the environment |
363 @param prefix prefix of the environment |
351 @type str |
364 @type str |
352 @return list of installed packages. Each entry is a tuple containing |
365 @return flag indicating success |
353 the package name, version and build. |
|
354 @rtype list of tuples of (str, str, str) |
|
355 @rtype bool |
366 @rtype bool |
356 @exception RuntimeError raised to indicate an error in parameters |
367 @exception RuntimeError raised to indicate an error in parameters |
357 |
368 |
358 Note: only one of name or prefix must be given. |
369 Note: only one of name or prefix must be given. |
359 """ |
370 """ |
361 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
372 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
362 |
373 |
363 if not name and not prefix: |
374 if not name and not prefix: |
364 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
375 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
365 |
376 |
366 # TODO: not implemented yet |
377 if packages: |
|
378 from .CondaExecDialog import CondaExecDialog |
|
379 |
|
380 args = [ |
|
381 "update", |
|
382 "--json", |
|
383 "--yes", |
|
384 ] |
|
385 if name: |
|
386 args.extend(["--name", name]) |
|
387 elif prefix: |
|
388 args.extend(["--prefix", prefix]) |
|
389 args.extend(packages) |
|
390 |
|
391 dlg = CondaExecDialog("update", self.__ui) |
|
392 dlg.start(args) |
|
393 dlg.exec_() |
|
394 ok, _ = dlg.getResult() |
|
395 else: |
|
396 ok = False |
|
397 |
|
398 return ok |
367 |
399 |
368 def updateAllPackages(self, name="", prefix=""): |
400 def updateAllPackages(self, name="", prefix=""): |
369 """ |
401 """ |
370 Public method to update all packages of a conda environment. |
402 Public method to update all packages of a conda environment. |
371 |
403 |
372 @param name name of the environment |
404 @param name name of the environment |
373 @type str |
405 @type str |
374 @param prefix prefix of the environment |
406 @param prefix prefix of the environment |
375 @type str |
407 @type str |
376 @return list of installed packages. Each entry is a tuple containing |
408 @return flag indicating success |
377 the package name, version and build. |
|
378 @rtype list of tuples of (str, str, str) |
|
379 @rtype bool |
409 @rtype bool |
380 @exception RuntimeError raised to indicate an error in parameters |
410 @exception RuntimeError raised to indicate an error in parameters |
381 |
411 |
382 Note: only one of name or prefix must be given. |
412 Note: only one of name or prefix must be given. |
383 """ |
413 """ |
385 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
415 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
386 |
416 |
387 if not name and not prefix: |
417 if not name and not prefix: |
388 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
418 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
389 |
419 |
390 # TODO: not implemented yet |
420 from .CondaExecDialog import CondaExecDialog |
|
421 |
|
422 args = [ |
|
423 "update", |
|
424 "--json", |
|
425 "--yes", |
|
426 "--all" |
|
427 ] |
|
428 if name: |
|
429 args.extend(["--name", name]) |
|
430 elif prefix: |
|
431 args.extend(["--prefix", prefix]) |
|
432 |
|
433 dlg = CondaExecDialog("update", self.__ui) |
|
434 dlg.start(args) |
|
435 dlg.exec_() |
|
436 ok, _ = dlg.getResult() |
|
437 |
|
438 return ok |
391 |
439 |
392 def installPackages(self, packages, name="", prefix=""): |
440 def installPackages(self, packages, name="", prefix=""): |
393 """ |
441 """ |
394 Public method to install packages into a conda environment. |
442 Public method to install packages into a conda environment. |
395 |
443 |
397 @type list of str |
445 @type list of str |
398 @param name name of the environment |
446 @param name name of the environment |
399 @type str |
447 @type str |
400 @param prefix prefix of the environment |
448 @param prefix prefix of the environment |
401 @type str |
449 @type str |
402 @return list of installed packages. Each entry is a tuple containing |
450 @return flag indicating success |
403 the package name, version and build. |
|
404 @rtype list of tuples of (str, str, str) |
|
405 @rtype bool |
451 @rtype bool |
406 @exception RuntimeError raised to indicate an error in parameters |
452 @exception RuntimeError raised to indicate an error in parameters |
407 |
453 |
408 Note: only one of name or prefix must be given. |
454 Note: only one of name or prefix must be given. |
409 """ |
455 """ |
423 @type list of str |
469 @type list of str |
424 @param name name of the environment |
470 @param name name of the environment |
425 @type str |
471 @type str |
426 @param prefix prefix of the environment |
472 @param prefix prefix of the environment |
427 @type str |
473 @type str |
428 @return list of installed packages. Each entry is a tuple containing |
474 @return flag indicating success |
429 the package name, version and build. |
|
430 @rtype list of tuples of (str, str, str) |
|
431 @rtype bool |
475 @rtype bool |
432 @exception RuntimeError raised to indicate an error in parameters |
476 @exception RuntimeError raised to indicate an error in parameters |
433 |
477 |
434 Note: only one of name or prefix must be given. |
478 Note: only one of name or prefix must be given. |
435 """ |
479 """ |
437 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
481 raise RuntimeError("Only one of 'name' or 'prefix' must be given.") |
438 |
482 |
439 if not name and not prefix: |
483 if not name and not prefix: |
440 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
484 raise RuntimeError("One of 'name' or 'prefix' must be given.") |
441 |
485 |
442 # TODO: not implemented yet |
486 if packages: |
|
487 from UI.DeleteFilesConfirmationDialog import \ |
|
488 DeleteFilesConfirmationDialog |
|
489 dlg = DeleteFilesConfirmationDialog( |
|
490 self.parent(), |
|
491 self.tr("Uninstall Packages"), |
|
492 self.tr( |
|
493 "Do you really want to uninstall these packages?"), |
|
494 packages) |
|
495 if dlg.exec_() == QDialog.Accepted: |
|
496 from .CondaExecDialog import CondaExecDialog |
|
497 |
|
498 args = [ |
|
499 "remove", |
|
500 "--json", |
|
501 "--yes", |
|
502 ] |
|
503 if name: |
|
504 args.extend(["--name", name]) |
|
505 elif prefix: |
|
506 args.extend(["--prefix", prefix]) |
|
507 args.extend(packages) |
|
508 |
|
509 dlg = CondaExecDialog("remove", self.__ui) |
|
510 dlg.start(args) |
|
511 dlg.exec_() |
|
512 ok, _ = dlg.getResult() |
|
513 else: |
|
514 ok = False |
|
515 else: |
|
516 ok = False |
|
517 |
|
518 return ok |