98 self.__condaMenu = QMenu(self) |
98 self.__condaMenu = QMenu(self) |
99 self.__envActs = [] |
99 self.__envActs = [] |
100 |
100 |
101 self.__cleanMenu = QMenu(self.tr("Clean"), self) |
101 self.__cleanMenu = QMenu(self.tr("Clean"), self) |
102 self.__cleanMenu.addAction( |
102 self.__cleanMenu.addAction( |
103 self.tr("All"), lambda: self.__cleanMenuAction("all")) |
103 self.tr("All"), lambda: self.__conda.cleanConda("all")) |
104 self.__cleanMenu.addAction( |
104 self.__cleanMenu.addAction( |
105 self.tr("Cache"), lambda: self.__cleanMenuAction("index-cache")) |
105 self.tr("Cache"), lambda: self.__conda.cleanConda("index-cache")) |
106 self.__cleanMenu.addAction( |
106 self.__cleanMenu.addAction( |
107 self.tr("Lock Files"), |
107 self.tr("Lock Files"), |
108 lambda: self.__cleanMenuAction("lock")) |
108 lambda: self.__conda.cleanConda("lock")) |
109 self.__cleanMenu.addAction( |
109 self.__cleanMenu.addAction( |
110 self.tr("Packages"), lambda: self.__cleanMenuAction("packages")) |
110 self.tr("Packages"), lambda: self.__conda.cleanConda("packages")) |
111 self.__cleanMenu.addAction( |
111 self.__cleanMenu.addAction( |
112 self.tr("Tarballs"), lambda: self.__cleanMenuAction("tarballs")) |
112 self.tr("Tarballs"), lambda: self.__conda.cleanConda("tarballs")) |
113 self.__cleanMenu.addAction( |
|
114 self.tr("Temporary Files"), |
|
115 lambda: self.__cleanMenuAction("temp_files")) |
|
116 |
113 |
117 self.__condaMenu.addAction( |
114 self.__condaMenu.addAction( |
118 self.tr("About Conda..."), self.__aboutConda) |
115 self.tr("About Conda..."), self.__aboutConda) |
119 self.__condaMenu.addSeparator() |
116 self.__condaMenu.addSeparator() |
120 self.__condaMenu.addAction( |
117 self.__condaMenu.addAction( |
121 self.tr("Update Conda"), self.__conda.updateConda) |
118 self.tr("Update Conda"), self.__conda.updateConda) |
122 self.__condaMenu.addSeparator() |
119 self.__condaMenu.addSeparator() |
123 self.__envActs.append(self.__condaMenu.addAction( |
120 self.__envActs.append(self.__condaMenu.addAction( |
124 self.tr("Install Packages"), self.__installPackages)) |
121 self.tr("Install Packages"), self.__installPackages)) |
125 self.__envActs.append(self.__condaMenu.addAction( |
122 self.__envActs.append(self.__condaMenu.addAction( |
126 self.tr("Install Local Packages"), self.__installLocalPackage)) |
|
127 self.__envActs.append(self.__condaMenu.addAction( |
|
128 self.tr("Install Requirements"), self.__installRequirements)) |
123 self.tr("Install Requirements"), self.__installRequirements)) |
129 self.__condaMenu.addSeparator() |
124 self.__condaMenu.addSeparator() |
130 self.__envActs.append(self.__condaMenu.addAction( |
125 self.__envActs.append(self.__condaMenu.addAction( |
131 self.tr("Generate Requirements"), self.__generateRequirements)) |
126 self.tr("Generate Requirements"), self.__generateRequirements)) |
132 self.__condaMenu.addSeparator() |
127 self.__condaMenu.addSeparator() |
|
128 self.__condaMenu.addAction( |
|
129 self.tr("Create Environment from Requirements"), |
|
130 self.__createEnvironment) |
133 self.__envActs.append(self.__condaMenu.addAction( |
131 self.__envActs.append(self.__condaMenu.addAction( |
134 self.tr("Clone Environment"), self.__cloneEnvironment)) |
132 self.tr("Clone Environment"), self.__cloneEnvironment)) |
|
133 self.__deleteEnvAct = self.__condaMenu.addAction( |
|
134 self.tr("Delete Environment"), self.__deleteEnvironment) |
135 self.__condaMenu.addSeparator() |
135 self.__condaMenu.addSeparator() |
136 self.__envActs.append(self.__condaMenu.addMenu(self.__cleanMenu)) |
136 self.__condaMenu.addMenu(self.__cleanMenu) |
137 self.__condaMenu.addSeparator() |
137 self.__condaMenu.addSeparator() |
138 self.__condaMenu.addAction( |
138 self.__condaMenu.addAction( |
139 self.tr("Edit User Configuration..."), |
139 self.tr("Edit User Configuration..."), |
140 self.__editUserConfiguration) |
140 self.__editUserConfiguration) |
141 self.__condaMenu.addSeparator() |
141 self.__condaMenu.addSeparator() |
507 """ |
507 """ |
508 selectedEnvironment = self.environmentsComboBox.currentText() |
508 selectedEnvironment = self.environmentsComboBox.currentText() |
509 enable = selectedEnvironment not in [""] |
509 enable = selectedEnvironment not in [""] |
510 for act in self.__envActs: |
510 for act in self.__envActs: |
511 act.setEnabled(enable) |
511 act.setEnabled(enable) |
|
512 |
|
513 self.__deleteEnvAct.setEnabled( |
|
514 selectedEnvironment not in ["", self.__conda.RootName]) |
512 |
515 |
513 @pyqtSlot() |
516 @pyqtSlot() |
514 def __aboutConda(self): |
517 def __aboutConda(self): |
515 """ |
518 """ |
516 Private slot to |
519 Private slot to show some information about the conda installation. |
517 """ |
520 """ |
518 # TODO: implement this menu function |
|
519 # conda info --all |
|
520 infoDict = self.__conda.getCondaInformation() |
521 infoDict = self.__conda.getCondaInformation() |
521 |
522 |
522 from .CondaInfoDialog import CondaInfoDialog |
523 from .CondaInfoDialog import CondaInfoDialog |
523 dlg = CondaInfoDialog(infoDict, self) |
524 dlg = CondaInfoDialog(infoDict, self) |
524 dlg.exec_() |
525 dlg.exec_() |
525 |
526 |
526 @pyqtSlot() |
527 @pyqtSlot() |
527 def __installPackages(self): |
528 def __installPackages(self): |
528 """ |
529 """ |
529 Private slot to |
530 Private slot to install packages. |
530 """ |
531 """ |
531 # TODO: implement this menu function |
532 prefix = self.environmentsComboBox.itemData( |
532 # conda install ... |
533 self.environmentsComboBox.currentIndex()) |
533 |
534 if prefix: |
534 @pyqtSlot() |
535 ok, packageSpecs = E5TextInputDialog.getText( |
535 def __installLocalPackage(self): |
536 self, |
536 """ |
537 self.tr("Install Packages"), |
537 Private slot to |
538 self.tr("Package Specifications (separated by whitespace):"), |
538 """ |
539 QLineEdit.Normal, |
539 # TODO: implement this menu function |
540 minimumWidth=600) |
540 # conda install --use-local |
541 if ok and packageSpecs.strip(): |
|
542 packages = [p.strip() for p in packageSpecs.split()] |
|
543 ok = self.__conda.installPackages(packages, prefix=prefix) |
|
544 if ok: |
|
545 self.on_refreshButton_clicked() |
541 |
546 |
542 @pyqtSlot() |
547 @pyqtSlot() |
543 def __installRequirements(self): |
548 def __installRequirements(self): |
544 """ |
549 """ |
545 Private slot to |
550 Private slot to install packages from requirements files. |
546 """ |
551 """ |
547 # TODO: implement this menu function |
552 prefix = self.environmentsComboBox.itemData( |
548 # conda install --file FILE1 --file FILE2 ... |
553 self.environmentsComboBox.currentIndex()) |
|
554 if prefix: |
|
555 requirements = E5FileDialog.getOpenFileNames( |
|
556 self, |
|
557 self.tr("Install Packages"), |
|
558 "", |
|
559 self.tr("Text Files (*.txt);;All Files (*)")) |
|
560 if requirements: |
|
561 args = [] |
|
562 for requirement in requirements: |
|
563 args.extend(["--file", requirement]) |
|
564 ok = self.__conda.installPackages(args, prefix=prefix) |
|
565 if ok: |
|
566 self.on_refreshButton_clicked() |
549 |
567 |
550 @pyqtSlot() |
568 @pyqtSlot() |
551 def __generateRequirements(self): |
569 def __generateRequirements(self): |
552 """ |
570 """ |
553 Private slot to |
571 Private slot to generate a requirements file. |
554 """ |
572 """ |
555 # TODO: implement this menu function |
573 prefix = self.environmentsComboBox.itemData( |
556 # conda list --export |
574 self.environmentsComboBox.currentIndex()) |
|
575 if prefix: |
|
576 env = self.environmentsComboBox.currentText() |
|
577 |
|
578 from .CondaExportDialog import CondaExportDialog |
|
579 |
|
580 self.__requirementsDialog = CondaExportDialog( |
|
581 self.__conda, env, prefix) |
|
582 self.__requirementsDialog.show() |
|
583 QApplication.processEvents() |
|
584 self.__requirementsDialog.start() |
557 |
585 |
558 @pyqtSlot() |
586 @pyqtSlot() |
559 def __cloneEnvironment(self): |
587 def __cloneEnvironment(self): |
560 """ |
588 """ |
561 Private slot to |
589 Private slot to clone a conda environment. |
562 """ |
590 """ |
563 # TODO: implement this menu function |
591 prefix = self.environmentsComboBox.itemData( |
564 # conda create --clone ENV |
592 self.environmentsComboBox.currentIndex()) |
565 |
593 if prefix: |
566 def __cleanMenuAction(self, cleanAction): |
594 ok, envName = E5TextInputDialog.getText( |
567 """ |
595 self, |
568 Private method to |
596 self.tr("Clone Environment"), |
569 """ |
597 self.tr("Enter name for the cloned environment:"), |
570 # TODO: implement this menu function |
598 QLineEdit.Normal) |
571 # conda clean |
599 if ok and envName.strip(): |
572 # --all (act = 'all') |
600 args = [ |
573 # --index-cache (act = 'index-cache') |
601 "--name", |
574 # --lock (act = 'lock') |
602 envName.strip(), |
575 # --packages (act = 'packages') |
603 "--clone", |
576 # --tarballs (act = 'tarballs') |
604 prefix, |
577 # -c prefix1 prefix2 ... (act = 'temp_files') |
605 ] |
|
606 self.__conda.createCondaEnvironment(args) |
|
607 # TODO: add code to register the cloned env with the virt env manager |
|
608 |
|
609 @pyqtSlot() |
|
610 def __createEnvironment(self): |
|
611 """ |
|
612 Private slot to create a conda environment from a requirements file. |
|
613 """ |
|
614 # TODO: implement this |
|
615 |
|
616 @pyqtSlot() |
|
617 def __deleteEnvironment(self): |
|
618 """ |
|
619 Private slot to delete a conda environment. |
|
620 """ |
|
621 envName = self.environmentsComboBox.currentText() |
|
622 ok = E5MessageBox.yesNo( |
|
623 self, |
|
624 self.tr("Delete Environment"), |
|
625 self.tr("""<p>Shal the environment <b>{0}</b> really be""" |
|
626 """ deleted?</p>""").format(envName) |
|
627 ) |
|
628 if ok: |
|
629 self.__conda.removeCondaEnvironment(name=envName) |
578 |
630 |
579 @pyqtSlot() |
631 @pyqtSlot() |
580 def __editUserConfiguration(self): |
632 def __editUserConfiguration(self): |
581 """ |
633 """ |
582 Private slot to edit the user configuration. |
634 Private slot to edit the user configuration. |