515 if dlg.exec_() == QDialog.Accepted: |
513 if dlg.exec_() == QDialog.Accepted: |
516 args = [ |
514 args = [ |
517 "remove", |
515 "remove", |
518 "--json", |
516 "--json", |
519 "--yes", |
517 "--yes", |
520 "--prune", |
|
521 ] |
518 ] |
|
519 if condaVersion() >= (4, 4, 0): |
|
520 args.append("--prune",) |
522 if name: |
521 if name: |
523 args.extend(["--name", name]) |
522 args.extend(["--name", name]) |
524 elif prefix: |
523 elif prefix: |
525 args.extend(["--prefix", prefix]) |
524 args.extend(["--prefix", prefix]) |
526 args.extend(packages) |
525 args.extend(packages) |
658 infoDict = {} |
660 infoDict = {} |
659 |
661 |
660 proc = QProcess() |
662 proc = QProcess() |
661 proc.start(exe, ["info", "--json"]) |
663 proc.start(exe, ["info", "--json"]) |
662 if proc.waitForStarted(15000): |
664 if proc.waitForStarted(15000): |
663 if proc.waitForFinished(15000): |
665 if proc.waitForFinished(30000): |
664 output = str(proc.readAllStandardOutput(), |
666 output = str(proc.readAllStandardOutput(), |
665 Preferences.getSystem("IOEncoding"), |
667 Preferences.getSystem("IOEncoding"), |
666 'replace').strip() |
668 'replace').strip() |
667 try: |
669 try: |
668 infoDict = json.loads(output) |
670 infoDict = json.loads(output) |
669 except Exception: |
671 except Exception: |
670 infoDict = {} |
672 infoDict = {} |
671 |
673 |
672 return infoDict |
674 return infoDict |
|
675 |
|
676 def runProcess(self, args): |
|
677 """ |
|
678 Public method to execute the conda with the given arguments. |
|
679 |
|
680 The conda executable is called with the given arguments and |
|
681 waited for its end. |
|
682 |
|
683 @param args list of command line arguments |
|
684 @type list of str |
|
685 @return tuple containing a flag indicating success and the output |
|
686 of the process |
|
687 @rtype tuple of (bool, str) |
|
688 """ |
|
689 exe = Preferences.getConda("CondaExecutable") |
|
690 if not exe: |
|
691 exe = "conda" |
|
692 |
|
693 process = QProcess() |
|
694 process.start(exe, args) |
|
695 procStarted = process.waitForStarted(15000) |
|
696 if procStarted: |
|
697 finished = process.waitForFinished(30000) |
|
698 if finished: |
|
699 if process.exitCode() == 0: |
|
700 output = str(process.readAllStandardOutput(), |
|
701 Preferences.getSystem("IOEncoding"), |
|
702 'replace').strip() |
|
703 return True, output |
|
704 else: |
|
705 return (False, |
|
706 self.tr("conda exited with an error ({0}).") |
|
707 .format(process.exitCode())) |
|
708 else: |
|
709 process.terminate() |
|
710 process.waitForFinished(2000) |
|
711 process.kill() |
|
712 process.waitForFinished(3000) |
|
713 return False, self.tr("conda did not finish within" |
|
714 " 30 seconds.") |
|
715 |
|
716 return False, self.tr("conda could not be started.") |
|
717 |
|
718 def cleanConda(self, cleanAction): |
|
719 """ |
|
720 Public method to update conda itself. |
|
721 |
|
722 @param cleanAction cleaning action to be performed (must be one of |
|
723 the command line parameters without '--') |
|
724 @type str |
|
725 """ |
|
726 args = [ |
|
727 "clean", |
|
728 "--yes", |
|
729 "--{0}".format(cleanAction), |
|
730 ] |
|
731 |
|
732 dlg = CondaExecDialog("clean", self.__ui) |
|
733 dlg.start(args) |
|
734 dlg.exec_() |