398 @param venvName name of the virtual environment to be used |
398 @param venvName name of the virtual environment to be used |
399 @type str |
399 @type str |
400 """ |
400 """ |
401 from .PipFileSelectionDialog import PipFileSelectionDialog |
401 from .PipFileSelectionDialog import PipFileSelectionDialog |
402 dlg = PipFileSelectionDialog(self, "requirements") |
402 dlg = PipFileSelectionDialog(self, "requirements") |
403 if dlg.exec() == QDialog.Accepted: |
403 if dlg.exec() == QDialog.DialogCode.Accepted: |
404 requirements, user = dlg.getData() |
404 requirements, user = dlg.getData() |
405 if requirements and os.path.exists(requirements): |
405 if requirements and os.path.exists(requirements): |
406 interpreter = self.getVirtualenvInterpreter(venvName) |
406 interpreter = self.getVirtualenvInterpreter(venvName) |
407 if not interpreter: |
407 if not interpreter: |
408 return |
408 return |
440 self.parent(), |
440 self.parent(), |
441 self.tr("Uninstall Packages"), |
441 self.tr("Uninstall Packages"), |
442 self.tr( |
442 self.tr( |
443 "Do you really want to uninstall these packages?"), |
443 "Do you really want to uninstall these packages?"), |
444 packages) |
444 packages) |
445 if dlg.exec() == QDialog.Accepted: |
445 if dlg.exec() == QDialog.DialogCode.Accepted: |
446 interpreter = self.getVirtualenvInterpreter(venvName) |
446 interpreter = self.getVirtualenvInterpreter(venvName) |
447 if not interpreter: |
447 if not interpreter: |
448 return False |
448 return False |
449 args = ["-m", "pip", "uninstall", "--yes"] + packages |
449 args = ["-m", "pip", "uninstall", "--yes"] + packages |
450 dia = PipDialog(self.tr('Uninstall Packages')) |
450 dia = PipDialog(self.tr('Uninstall Packages')) |
462 """ |
462 """ |
463 if venvName: |
463 if venvName: |
464 from .PipFileSelectionDialog import PipFileSelectionDialog |
464 from .PipFileSelectionDialog import PipFileSelectionDialog |
465 dlg = PipFileSelectionDialog(self, "requirements", |
465 dlg = PipFileSelectionDialog(self, "requirements", |
466 install=False) |
466 install=False) |
467 if dlg.exec() == QDialog.Accepted: |
467 if dlg.exec() == QDialog.DialogCode.Accepted: |
468 requirements, _user = dlg.getData() |
468 requirements, _user = dlg.getData() |
469 if requirements and os.path.exists(requirements): |
469 if requirements and os.path.exists(requirements): |
470 try: |
470 try: |
471 with open(requirements, "r") as f: |
471 with open(requirements, "r") as f: |
472 reqs = f.read().splitlines() |
472 reqs = f.read().splitlines() |
480 self.parent(), |
480 self.parent(), |
481 self.tr("Uninstall Packages"), |
481 self.tr("Uninstall Packages"), |
482 self.tr( |
482 self.tr( |
483 "Do you really want to uninstall these packages?"), |
483 "Do you really want to uninstall these packages?"), |
484 reqs) |
484 reqs) |
485 if dlg.exec() == QDialog.Accepted: |
485 if dlg.exec() == QDialog.DialogCode.Accepted: |
486 interpreter = self.getVirtualenvInterpreter(venvName) |
486 interpreter = self.getVirtualenvInterpreter(venvName) |
487 if not interpreter: |
487 if not interpreter: |
488 return |
488 return |
489 |
489 |
490 args = ["-m", "pip", "uninstall", "--requirement", |
490 args = ["-m", "pip", "uninstall", "--requirement", |
680 reply = self.__networkManager.get(request) |
680 reply = self.__networkManager.get(request) |
681 while not reply.isFinished(): |
681 while not reply.isFinished(): |
682 QCoreApplication.processEvents() |
682 QCoreApplication.processEvents() |
683 |
683 |
684 reply.deleteLater() |
684 reply.deleteLater() |
685 if reply.error() == QNetworkReply.NoError: |
685 if reply.error() == QNetworkReply.NetworkError.NoError: |
686 data = str(reply.readAll(), |
686 data = str(reply.readAll(), |
687 Preferences.getSystem("IOEncoding"), |
687 Preferences.getSystem("IOEncoding"), |
688 'replace') |
688 'replace') |
689 try: |
689 try: |
690 result = json.loads(data) |
690 result = json.loads(data) |
726 if interpreter: |
726 if interpreter: |
727 pattern, ok = QInputDialog.getText( |
727 pattern, ok = QInputDialog.getText( |
728 None, |
728 None, |
729 self.tr("List Cached Files"), |
729 self.tr("List Cached Files"), |
730 self.tr("Enter a file pattern (empty for all):"), |
730 self.tr("Enter a file pattern (empty for all):"), |
731 QLineEdit.Normal) |
731 QLineEdit.EchoMode.Normal) |
732 |
732 |
733 if ok: |
733 if ok: |
734 args = ["-m", "pip", "cache", "list"] |
734 args = ["-m", "pip", "cache", "list"] |
735 if pattern.strip(): |
735 if pattern.strip(): |
736 args.append(pattern.strip()) |
736 args.append(pattern.strip()) |
752 if interpreter: |
752 if interpreter: |
753 pattern, ok = QInputDialog.getText( |
753 pattern, ok = QInputDialog.getText( |
754 None, |
754 None, |
755 self.tr("Remove Cached Files"), |
755 self.tr("Remove Cached Files"), |
756 self.tr("Enter a file pattern:"), |
756 self.tr("Enter a file pattern:"), |
757 QLineEdit.Normal) |
757 QLineEdit.EchoMode.Normal) |
758 |
758 |
759 if ok and pattern.strip(): |
759 if ok and pattern.strip(): |
760 args = ["-m", "pip", "cache", "remove", pattern.strip()] |
760 args = ["-m", "pip", "cache", "remove", pattern.strip()] |
761 dia = PipDialog(self.tr("Remove Cached Files")) |
761 dia = PipDialog(self.tr("Remove Cached Files")) |
762 res = dia.startProcess(interpreter, args, |
762 res = dia.startProcess(interpreter, args, |