eric6/CondaInterface/CondaPackagesWidget.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7780
41420f82c0ac
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some more code cleanup.

6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7250
diff changeset
3 # Copyright (c) 2019 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the conda packages management widget.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
10 import os
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
11
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSlot, Qt
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 from PyQt5.QtWidgets import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 QWidget, QToolButton, QMenu, QTreeWidgetItem, QApplication, QLineEdit,
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 QDialog
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
18 from E5Gui import E5FileDialog, E5MessageBox, E5TextInputDialog
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
19 from E5Gui.E5Application import e5App
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
20 from E5Gui.E5OverrideCursor import E5OverrideCursor
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
21
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import UI.PixmapCache
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
26 import CondaInterface
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
27
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 class CondaPackagesWidget(QWidget, Ui_CondaPackagesWidget):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Class implementing the conda packages management widget.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
33 # Role definition of packages list
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
34 PackageVersionRole = Qt.UserRole + 1
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
35 PackageBuildRole = Qt.UserRole + 2
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
36
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
37 # Role definitions of search results list
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
38 PackageDetailedDataRole = Qt.UserRole + 1
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
39
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
40 def __init__(self, conda, parent=None):
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
44 @param conda reference to the conda interface
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
45 @type Conda
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param parent reference to the parent widget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @type QWidget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 super(CondaPackagesWidget, self).__init__(parent)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setupUi(self)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
52 self.__conda = conda
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
53
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
54 if not CondaInterface.isCondaAvailable():
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
55 self.baseWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
56 self.searchWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
57
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
58 else:
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
59 self.notAvailableWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
60
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
61 self.__initCondaInterface()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
62
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
63 def __initCondaInterface(self):
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
64 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
65 Private method to initialize the conda interface elements.
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
66 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
67 self.statusLabel.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
68
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.condaMenuButton.setObjectName(
7107
fccf607a5326 CondaPackagesWidget, PipPackagesWidget: fixed a little issue related to naming some Qt objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
70 "conda_supermenu_button")
6796
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
71 self.condaMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu"))
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.condaMenuButton.setToolTip(self.tr("Conda Menu"))
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.condaMenuButton.setPopupMode(QToolButton.InstantPopup)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.condaMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.condaMenuButton.setFocusPolicy(Qt.NoFocus)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.condaMenuButton.setAutoRaise(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.condaMenuButton.setShowMenuInside(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
6796
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
79 self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
80 self.upgradeButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
81 self.upgradeAllButton.setIcon(UI.PixmapCache.getIcon("2uparrow"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
82 self.uninstallButton.setIcon(UI.PixmapCache.getIcon("minus"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
83 self.searchToggleButton.setIcon(UI.PixmapCache.getIcon("find"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
84 self.searchButton.setIcon(UI.PixmapCache.getIcon("findNext"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
85 self.installButton.setIcon(UI.PixmapCache.getIcon("plus"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
86 self.showDetailsButton.setIcon(UI.PixmapCache.getIcon("info"))
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
87
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
88 if CondaInterface.condaVersion() >= (4, 4, 0):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
89 self.searchOptionsWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
90 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
91 self.platformComboBox.addItems(sorted([
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
92 "", "win-32", "win-64", "osx-64", "linux-32", "linux-64",
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
93 ]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
94
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__initCondaMenu()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__populateEnvironments()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
97 self.__updateActionButtons()
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
98
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
99 self.searchWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
100
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
101 self.__conda.condaEnvironmentCreated.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
102 self.on_refreshButton_clicked)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
103 self.__conda.condaEnvironmentRemoved.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
104 self.on_refreshButton_clicked)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __populateEnvironments(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private method to get a list of environments and populate the selector.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
110 environments = [("", "")] + sorted(
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
111 self.__conda.getCondaEnvironmentsList())
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
112 for environment in environments:
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
113 self.environmentsComboBox.addItem(environment[0], environment[1])
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 def __initCondaMenu(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 Private method to create the super menu and attach it to the super
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 menu button.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__condaMenu = QMenu(self)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
121 self.__envActs = []
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
122
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
123 self.__cleanMenu = QMenu(self.tr("Clean"), self)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
124 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
125 self.tr("All"), lambda: self.__conda.cleanConda("all"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
126 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
127 self.tr("Cache"), lambda: self.__conda.cleanConda("index-cache"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
128 self.__cleanMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
129 self.tr("Lock Files"),
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
130 lambda: self.__conda.cleanConda("lock"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
131 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
132 self.tr("Packages"), lambda: self.__conda.cleanConda("packages"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
133 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
134 self.tr("Tarballs"), lambda: self.__conda.cleanConda("tarballs"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
135
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
136 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
137 self.tr("About Conda..."), self.__aboutConda)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
138 self.__condaMenu.addSeparator()
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
139 self.__condaMenu.addAction(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
140 self.tr("Update Conda"), self.__conda.updateConda)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
141 self.__condaMenu.addSeparator()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
142 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
143 self.tr("Install Packages"), self.__installPackages))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
144 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
145 self.tr("Install Requirements"), self.__installRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
146 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
147 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
148 self.tr("Generate Requirements"), self.__generateRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
149 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
150 self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
151 self.tr("Create Environment from Requirements"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
152 self.__createEnvironment)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
153 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
154 self.tr("Clone Environment"), self.__cloneEnvironment))
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
155 self.__deleteEnvAct = self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
156 self.tr("Delete Environment"), self.__deleteEnvironment)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
157 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
158 self.__condaMenu.addMenu(self.__cleanMenu)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
159 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
160 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
161 self.tr("Edit User Configuration..."),
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
162 self.__editUserConfiguration)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
163 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
164 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
165 self.tr("Configure..."), self.__condaConfigure)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.condaMenuButton.setMenu(self.__condaMenu)
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
168
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
169 self.__condaMenu.aboutToShow.connect(self.__aboutToShowCondaMenu)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
171 def __selectedUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
172 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
173 Private method to get a list of selected items that can be updated.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
174
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
175 @return list of selected items that can be updated
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
176 @rtype list of QTreeWidgetItem
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
177 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
178 return [
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
179 itm for itm in self.packagesList.selectedItems()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
180 if bool(itm.text(2))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
181 ]
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
182
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
183 def __allUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
184 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
185 Private method to get a list of all items that can be updated.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
186
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
187 @return list of all items that can be updated
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
188 @rtype list of QTreeWidgetItem
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
190 updateableItems = []
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
191 for index in range(self.packagesList.topLevelItemCount()):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
192 itm = self.packagesList.topLevelItem(index)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
193 if itm.text(2):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
194 updateableItems.append(itm)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
196 return updateableItems
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
197
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
198 def __updateActionButtons(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
199 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
200 Private method to set the state of the action buttons.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
201 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
202 self.upgradeButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
203 bool(self.__selectedUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
204 self.uninstallButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
205 bool(self.packagesList.selectedItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
206 self.upgradeAllButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
207 bool(self.__allUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
208
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
209 @pyqtSlot(int)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
210 def on_environmentsComboBox_currentIndexChanged(self, index):
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
211 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
212 Private slot handling the selection of a conda environment.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
213
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
214 @param index index of the selected conda environment
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
215 @type int
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
217 self.packagesList.clear()
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
218 prefix = self.environmentsComboBox.itemData(index)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
219 if prefix:
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
220 self.statusLabel.show()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
221 self.statusLabel.setText(self.tr("Getting installed packages..."))
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
222
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
223 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
224 # 1. populate with installed packages
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
225 self.packagesList.setUpdatesEnabled(False)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
226 installedPackages = self.__conda.getInstalledPackages(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
227 prefix=prefix)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
228 for package, version, build in installedPackages:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
229 itm = QTreeWidgetItem(self.packagesList,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
230 [package, version])
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
231 itm.setData(1, self.PackageVersionRole, version)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
232 itm.setData(1, self.PackageBuildRole, build)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
233 self.packagesList.setUpdatesEnabled(True)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
234 self.statusLabel.setText(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
235 self.tr("Getting outdated packages..."))
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
236 QApplication.processEvents()
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
237
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
238 # 2. update with update information
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
239 self.packagesList.setUpdatesEnabled(False)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
240 updateablePackages = self.__conda.getUpdateablePackages(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
241 prefix=prefix)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
242 for package, version, build in updateablePackages:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
243 items = self.packagesList.findItems(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
244 package, Qt.MatchExactly | Qt.MatchCaseSensitive)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
245 if items:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
246 itm = items[0]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
247 itm.setText(2, version)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
248 itm.setData(2, self.PackageVersionRole, version)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
249 itm.setData(2, self.PackageBuildRole, build)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
250 if itm.data(1, self.PackageVersionRole) == version:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
251 # build must be different, show in version display
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
252 itm.setText(1, self.tr("{0} (Build: {1})").format(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
253 itm.data(1, self.PackageVersionRole),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
254 itm.data(1, self.PackageBuildRole),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
255 ))
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
256 itm.setText(2, self.tr("{0} (Build: {1})").format(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
257 itm.data(2, self.PackageVersionRole),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
258 itm.data(2, self.PackageBuildRole),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
259 ))
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
260
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
261 self.packagesList.sortItems(0, Qt.AscendingOrder)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
262 for col in range(self.packagesList.columnCount()):
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
263 self.packagesList.resizeColumnToContents(col)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
264 self.packagesList.setUpdatesEnabled(True)
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
265 self.statusLabel.hide()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
266
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
267 self.__updateActionButtons()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
268 self.__updateSearchActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def on_packagesList_itemSelectionChanged(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
273 Private slot to handle the selection of some items..
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
275 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 def on_refreshButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
280 Private slot to refresh the display.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
282 currentEnvironment = self.environmentsComboBox.currentText()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
283 self.environmentsComboBox.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
284 self.packagesList.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
285
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
286 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
287 self.__populateEnvironments()
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
288
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
289 index = self.environmentsComboBox.findText(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
290 currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
291 if index != -1:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
292 self.environmentsComboBox.setCurrentIndex(index)
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
293
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
294 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def on_upgradeButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
299 Private slot to upgrade selected packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
301 packages = [itm.text(0) for itm in self.__selectedUpdateableItems()]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
302 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
303 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
304 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
305 ok = self.__conda.updatePackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
306 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
307 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 def on_upgradeAllButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
312 Private slot to upgrade all packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
314 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
315 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
316 ok = self.__conda.updateAllPackages(prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
317 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
318 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 def on_uninstallButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
323 Private slot to remove selected packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
325 packages = [itm.text(0) for itm in self.packagesList.selectedItems()]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
326 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
327 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
328 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
329 ok = self.__conda.uninstallPackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
330 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
331 self.on_refreshButton_clicked()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
332
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
333 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
334 ## Search widget related methods below
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
335 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
336
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
337 def __updateSearchActionButtons(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
338 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
339 Private method to update the action button states of the search widget.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
340 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
341 enable = len(self.searchResultList.selectedItems()) == 1
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
342 self.installButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
343 enable and self.environmentsComboBox.currentIndex() > 0)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
344 self.showDetailsButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
345 enable and bool(self.searchResultList.selectedItems()[0].parent()))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
346
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
347 def __doSearch(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
348 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
349 Private method to search for packages.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
350 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
351 self.searchResultList.clear()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
352 pattern = self.searchEdit.text()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
353 if pattern:
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
354 with E5OverrideCursor():
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
355 if CondaInterface.condaVersion() >= (4, 4, 0):
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
356 prefix = ""
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
357 else:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
358 prefix = self.environmentsComboBox.itemData(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
359 self.environmentsComboBox.currentIndex())
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
360 ok, result = self.__conda.searchPackages(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
361 pattern,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
362 fullNameOnly=self.fullNameButton.isChecked(),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
363 packageSpec=self.packageSpecButton.isChecked(),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
364 platform=self.platformComboBox.currentText(),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
365 prefix=prefix,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
366 )
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
367
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
368 if ok:
7771
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
369 if result:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
370 self.searchResultList.setUpdatesEnabled(False)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
371 for package in result:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
372 itm = QTreeWidgetItem(self.searchResultList,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
373 [package])
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
374 itm.setExpanded(False)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
375 for detail in result[package]:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
376 version = detail["version"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
377 build = detail["build"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
378 if "subdir" in detail:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
379 platform = detail["subdir"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
380 elif "platform" in detail:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
381 platform = detail["platform"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
382 else:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
383 platform = ""
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
384 citm = QTreeWidgetItem(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
385 itm, ["", version, build, platform])
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
386 citm.setData(0, self.PackageDetailedDataRole,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
387 detail)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
388
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
389 self.searchResultList.sortItems(0, Qt.AscendingOrder)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
390 self.searchResultList.resizeColumnToContents(0)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
391 self.searchResultList.setUpdatesEnabled(True)
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
392 if not ok:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
393 try:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
394 message = result["message"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
395 except KeyError:
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
396 message = result["error"]
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
397 E5MessageBox.warning(
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
398 self,
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
399 self.tr("Conda Search Package Error"),
787a6b3f8c9f Optimized the use of Waiting Cursors by using a specialized context manager class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
400 message)
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
401
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
402 def __showDetails(self, item):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
403 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
404 Private method to show a dialog with details about a package item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
405
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
406 @param item reference to the package item
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
407 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
408 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
409 details = item.data(0, self.PackageDetailedDataRole)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
410 if details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
411 from .CondaPackageDetailsWidget import CondaPackageDetailsDialog
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
412 dlg = CondaPackageDetailsDialog(details, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7722
diff changeset
413 dlg.exec()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
414
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
415 @pyqtSlot(str)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
416 def on_searchEdit_textChanged(self, txt):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
417 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
418 Private slot handling changes of the entered search specification.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
419
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
420 @param txt current search entry
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
421 @type str
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
422 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
423 self.searchButton.setEnabled(bool(txt))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
424
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
425 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
426 def on_searchEdit_returnPressed(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
427 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
428 Private slot handling the user pressing the Return button in the
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
429 search edit.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
430 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
431 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
432
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
433 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
434 def on_searchButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
435 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
436 Private slot handling the press of the search button.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
437 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
438 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
439
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
440 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
441 def on_installButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
442 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
443 Private slot to install a selected package.
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
444 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
445 if len(self.searchResultList.selectedItems()) == 1:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
446 item = self.searchResultList.selectedItems()[0]
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
447 if item.parent() is None:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
448 # it is just the package item
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
449 package = item.text(0)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
450 else:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
451 # item with version and build
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
452 package = "{0}={1}={2}".format(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
453 item.parent().text(0),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
454 item.text(1),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
455 item.text(2),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
456 )
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
457
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
458 prefix = self.environmentsComboBox.itemData(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
459 self.environmentsComboBox.currentIndex())
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
460 ok = self.__conda.installPackages([package], prefix=prefix)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
461 if ok:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
462 self.on_refreshButton_clicked()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
463
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
464 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
465 def on_showDetailsButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
466 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
467 Private slot handling the 'Show Details' button.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
468 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
469 item = self.searchResultList.selectedItems()[0]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
470 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
471
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
472 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
473 def on_searchResultList_itemSelectionChanged(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
474 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
475 Private slot handling a change of selected search results.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
476 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
477 self.__updateSearchActionButtons()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
478
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
479 @pyqtSlot(QTreeWidgetItem)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
480 def on_searchResultList_itemExpanded(self, item):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
481 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
482 Private slot handling the expansion of an item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
483
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
484 @param item reference to the expanded item
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
485 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
486 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
487 for col in range(1, self.searchResultList.columnCount()):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
488 self.searchResultList.resizeColumnToContents(col)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
489
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
490 @pyqtSlot(QTreeWidgetItem, int)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
491 def on_searchResultList_itemDoubleClicked(self, item, column):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
492 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
493 Private slot handling a double click of an item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
494
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
495 @param item reference to the item that was double clicked
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
496 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
497 @param column column of the double click
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
498 @type int
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
499 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
500 if item.parent() is not None:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
501 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
502
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
503 @pyqtSlot(bool)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
504 def on_searchToggleButton_toggled(self, checked):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
505 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
506 Private slot to togle the search widget.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
507
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
508 @param checked state of the search widget button
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
509 @type bool
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
510 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
511 self.searchWidget.setVisible(checked)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
512
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
513 if checked:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
514 self.searchEdit.setFocus(Qt.OtherFocusReason)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
515 self.searchEdit.selectAll()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
516
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
517 self.__updateSearchActionButtons()
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
518
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
519 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
520 ## Menu related methods below
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
521 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
522
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
523 @pyqtSlot()
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
524 def __aboutToShowCondaMenu(self):
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
525 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
526 Private slot to handle the conda menu about to be shown.
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
527 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
528 selectedEnvironment = self.environmentsComboBox.currentText()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
529 enable = selectedEnvironment not in [""]
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
530 for act in self.__envActs:
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
531 act.setEnabled(enable)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
532
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
533 self.__deleteEnvAct.setEnabled(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
534 selectedEnvironment not in ["", self.__conda.RootName])
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
535
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
536 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
537 def __aboutConda(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
538 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
539 Private slot to show some information about the conda installation.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
540 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
541 infoDict = self.__conda.getCondaInformation()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
542
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
543 from .CondaInfoDialog import CondaInfoDialog
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
544 dlg = CondaInfoDialog(infoDict, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7722
diff changeset
545 dlg.exec()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
546
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
547 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
548 def __installPackages(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
549 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
550 Private slot to install packages.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
551 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
552 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
553 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
554 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
555 ok, packageSpecs = E5TextInputDialog.getText(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
556 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
557 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
558 self.tr("Package Specifications (separated by whitespace):"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
559 QLineEdit.Normal,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
560 minimumWidth=600)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
561 if ok and packageSpecs.strip():
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
562 packages = [p.strip() for p in packageSpecs.split()]
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
563 ok = self.__conda.installPackages(packages, prefix=prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
564 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
565 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
566
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
567 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
568 def __installRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
569 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
570 Private slot to install packages from requirements files.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
571 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
572 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
573 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
574 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
575 requirements = E5FileDialog.getOpenFileNames(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
576 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
577 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
578 "",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
579 self.tr("Text Files (*.txt);;All Files (*)"))
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
580 if requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
581 args = []
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
582 for requirement in requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
583 args.extend(["--file", requirement])
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
584 ok = self.__conda.installPackages(args, prefix=prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
585 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
586 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
587
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
588 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
589 def __generateRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
590 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
591 Private slot to generate a requirements file.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
592 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
593 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
594 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
595 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
596 env = self.environmentsComboBox.currentText()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
597
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
598 from .CondaExportDialog import CondaExportDialog
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
599
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
600 self.__requirementsDialog = CondaExportDialog(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
601 self.__conda, env, prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
602 self.__requirementsDialog.show()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
603 QApplication.processEvents()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
604 self.__requirementsDialog.start()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
605
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
606 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
607 def __cloneEnvironment(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
608 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
609 Private slot to clone a conda environment.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
610 """
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
611 from .CondaNewEnvironmentDataDialog import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
612 CondaNewEnvironmentDataDialog)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
613
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
614 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
615 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
616 if prefix:
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
617 dlg = CondaNewEnvironmentDataDialog(self.tr("Clone Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
618 False, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7722
diff changeset
619 if dlg.exec() == QDialog.Accepted:
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
620 virtEnvName, envName, _ = dlg.getData()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
621 args = [
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
622 "--name",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
623 envName.strip(),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
624 "--clone",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
625 prefix,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
626 ]
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
627 ok, prefix, interpreter = self.__conda.createCondaEnvironment(
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
628 args)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
629 if ok:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
630 e5App().getObject("VirtualEnvManager").addVirtualEnv(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
631 virtEnvName, prefix, interpreter, isConda=True)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
632
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
633 @pyqtSlot()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
634 def __createEnvironment(self):
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
635 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
636 Private slot to create a conda environment from a requirements file.
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
637 """
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
638 from .CondaNewEnvironmentDataDialog import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
639 CondaNewEnvironmentDataDialog)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
640
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
641 dlg = CondaNewEnvironmentDataDialog(self.tr("Create Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
642 True, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7722
diff changeset
643 if dlg.exec() == QDialog.Accepted:
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
644 virtEnvName, envName, requirements = dlg.getData()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
645 args = [
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
646 "--name",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
647 envName.strip(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
648 "--file",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
649 requirements,
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
650 ]
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
651 ok, prefix, interpreter = self.__conda.createCondaEnvironment(args)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
652 if ok:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
653 e5App().getObject("VirtualEnvManager").addVirtualEnv(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
654 virtEnvName, prefix, interpreter, isConda=True)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
655
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
656 @pyqtSlot()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
657 def __deleteEnvironment(self):
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
658 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
659 Private slot to delete a conda environment.
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
660 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
661 envName = self.environmentsComboBox.currentText()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
662 ok = E5MessageBox.yesNo(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
663 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
664 self.tr("Delete Environment"),
6771
bcffbb627791 Updated the translations for the new conda interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6738
diff changeset
665 self.tr("""<p>Shall the environment <b>{0}</b> really be"""
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
666 """ deleted?</p>""").format(envName)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
667 )
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
668 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
669 self.__conda.removeCondaEnvironment(name=envName)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
670
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
671 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
672 def __editUserConfiguration(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
673 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
674 Private slot to edit the user configuration.
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
675 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
676 from QScintilla.MiniEditor import MiniEditor
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
677
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
678 cfgFile = CondaInterface.userConfiguration()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
679 if not cfgFile:
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
680 return
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
681
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
682 if not os.path.exists(cfgFile):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
683 self.__conda.writeDefaultConfiguration()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
684
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
685 # check, if the destination is writeable
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
686 if not os.access(cfgFile, os.W_OK):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
687 E5MessageBox.critical(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
688 None,
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
689 self.tr("Edit Configuration"),
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
690 self.tr("""The configuration file "{0}" does not exist"""
7722
db3a6d341913 CondaPackagesWidget: fixed an omission.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
691 """ or is not writable.""").format(cfgFile))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
692 return
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
693
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
694 self.__editor = MiniEditor(cfgFile, "YAML")
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
695 self.__editor.show()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
696
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
697 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
698 def __condaConfigure(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
699 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
700 Private slot to open the configuration page.
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
701 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
702 e5App().getObject("UserInterface").showPreferences("condaPage")
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
703
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
704 @pyqtSlot()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
705 def on_recheckButton_clicked(self):
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
706 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
707 Private slot to re-check the availability of conda and adjust the
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
708 interface if it became available.
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
709 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
710 if CondaInterface.isCondaAvailable():
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
711 self.__initCondaInterface()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
712
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
713 self.notAvailableWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
714 self.baseWidget.show()

eric ide

mercurial