PipInterface/PipPackagesWidget.py

Fri, 22 Feb 2019 19:34:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 22 Feb 2019 19:34:44 +0100
branch
pypi
changeset 6798
3985c1a67fa2
parent 6795
6e2ed2aac325
child 6801
df623ed5aaa6
permissions
-rw-r--r--

PipInterface: continued with the pip interface widget.

6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the pip packages management widget.
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
12 import textwrap
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
13 import os
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
14
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
15 from PyQt5.QtCore import pyqtSlot, Qt, QEventLoop, QRegExp
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt5.QtGui import QCursor
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
17 from PyQt5.QtWidgets import QWidget, QToolButton, QApplication, QHeaderView, \
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
18 QTreeWidgetItem, QInputDialog, QMenu, QDialog
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
19
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
20 from E5Gui.E5Application import e5App
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
21 from E5Gui import E5MessageBox
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
22
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
23 from E5Network.E5XmlRpcClient import E5XmlRpcClient
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from .Ui_PipPackagesWidget import Ui_PipPackagesWidget
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import UI.PixmapCache
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 from .Pip import Pip
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
32 # TODO: use icons for action buttons
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
33 # TODO: show package details for installed packages
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 class PipPackagesWidget(QWidget, Ui_PipPackagesWidget):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
36 Class implementing the pip packages management widget.
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
38 ShowProcessGeneralMode = 0
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
39 ShowProcessClassifiersMode = 1
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
40 ShowProcessEntryPointsMode = 2
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
41 ShowProcessFilesListMode = 3
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
42
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
43 SearchStopwords = {
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
44 "a", "and", "are", "as", "at", "be", "but", "by",
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
45 "for", "if", "in", "into", "is", "it",
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
46 "no", "not", "of", "on", "or", "such",
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
47 "that", "the", "their", "then", "there", "these",
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
48 "they", "this", "to", "was", "will",
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
49 }
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
50 SearchVersionRole = Qt.UserRole + 1
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
51
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def __init__(self, parent=None):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Constructor
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @param parent reference to the parent widget
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @type QWidget
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 super(PipPackagesWidget, self).__init__(parent)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.setupUi(self)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.pipMenuButton.setObjectName(
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 "navigation_supermenu_button")
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.pipMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu"))
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.pipMenuButton.setToolTip(self.tr("pip Menu"))
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.pipMenuButton.setPopupMode(QToolButton.InstantPopup)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.pipMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.pipMenuButton.setFocusPolicy(Qt.NoFocus)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.pipMenuButton.setAutoRaise(True)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.pipMenuButton.setShowMenuInside(True)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.searchToggleButton.setIcon(UI.PixmapCache.getIcon("find"))
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__pip = Pip(self)
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
75 self.__client = E5XmlRpcClient(self.__pip.getIndexUrlXml(), self)
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
77 self.packagesList.header().setSortIndicator(0, Qt.AscendingOrder)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
78
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
79 self.__infoLabels = {
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
80 "name": self.tr("Name:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
81 "version": self.tr("Version:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
82 "location": self.tr("Location:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
83 "requires": self.tr("Requires:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
84 "summary": self.tr("Summary:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
85 "home-page": self.tr("Homepage:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
86 "author": self.tr("Author:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
87 "author-email": self.tr("Author Email:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
88 "license": self.tr("License:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
89 "metadata-version": self.tr("Metadata Version:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
90 "installer": self.tr("Installer:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
91 "classifiers": self.tr("Classifiers:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
92 "entry-points": self.tr("Entry Points:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
93 "files": self.tr("Files:"),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
94 }
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
95 self.infoWidget.setHeaderLabels(["Key", "Value"])
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
96
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
97 venvManager = e5App().getObject("VirtualEnvManager")
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
98 venvManager.virtualEnvironmentAdded.connect(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
99 self.on_refreshButton_clicked)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
100 venvManager.virtualEnvironmentRemoved.connect(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
101 self.on_refreshButton_clicked)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
102
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
103 project = e5App().getObject("Project")
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
104 project.projectOpened.connect(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
105 self.on_refreshButton_clicked)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
106 project.projectClosed.connect(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
107 self.on_refreshButton_clicked)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
108
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.__initPipMenu()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__populateEnvironments()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__updateActionButtons()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.statusLabel.hide()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.searchWidget.hide()
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
115
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
116 self.__queryName = []
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
117 self.__querySummary = []
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
118
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
119 self.__packageDetailsDialog = None
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 def __populateEnvironments(self):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 Private method to get a list of environments and populate the selector.
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.environmentsComboBox.addItem("")
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 projectVenv = self.__pip.getProjectEnvironmentString()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if projectVenv:
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.environmentsComboBox.addItem(projectVenv)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.environmentsComboBox.addItems(self.__pip.getVirtualenvNames())
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
131 def __isPipAvailable(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
132 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
133 Private method to check, if the pip package is available for the
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
134 selected environment.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
135
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
136 @return flag indicating availability
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
137 @rtype bool
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
138 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
139 available = False
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
140
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
141 venvName = self.environmentsComboBox.currentText()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
142 if venvName:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
143 available = len(self.packagesList.findItems(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
144 "pip", Qt.MatchExactly | Qt.MatchCaseSensitive)) == 1
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
145
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
146 return available
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
147
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
148 #######################################################################
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
149 ## Slots handling widget signals below
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
150 #######################################################################
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
151
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
152 def __selectedUpdateableItems(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
153 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
154 Private method to get a list of selected items that can be updated.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
155
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
156 @return list of selected items that can be updated
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
157 @rtype list of QTreeWidgetItem
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
158 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
159 return [
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
160 itm for itm in self.packagesList.selectedItems()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
161 if bool(itm.text(2))
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
162 ]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
163
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
164 def __allUpdateableItems(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
165 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
166 Private method to get a list of all items that can be updated.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
167
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
168 @return list of all items that can be updated
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
169 @rtype list of QTreeWidgetItem
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
170 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
171 updateableItems = []
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
172 for index in range(self.packagesList.topLevelItemCount()):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
173 itm = self.packagesList.topLevelItem(index)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
174 if itm.text(2):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
175 updateableItems.append(itm)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
176
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
177 return updateableItems
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
178
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 def __updateActionButtons(self):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 Private method to set the state of the action buttons.
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
183 if self.__isPipAvailable():
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
184 self.upgradeButton.setEnabled(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
185 bool(self.__selectedUpdateableItems()))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
186 self.uninstallButton.setEnabled(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
187 bool(self.packagesList.selectedItems()))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
188 self.upgradeAllButton.setEnabled(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
189 bool(self.__allUpdateableItems()))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
190 else:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
191 self.upgradeButton.setEnabled(False)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
192 self.uninstallButton.setEnabled(False)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
193 self.upgradeAllButton.setEnabled(False)
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
195 def __refreshPackagesList(self):
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
197 Private method to referesh the packages list.
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.packagesList.clear()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 venvName = self.environmentsComboBox.currentText()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 if venvName:
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 interpreter = self.__pip.getVirtualenvInterpreter(venvName)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 if interpreter:
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.statusLabel.show()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.statusLabel.setText(
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.tr("Getting installed packages..."))
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 QApplication.processEvents()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 # 1. populate with installed packages
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
211 self.packagesList.setUpdatesEnabled(False)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
212 installedPackages = self.__pip.getInstalledPackages(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
213 venvName,
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
214 localPackages=self.localCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
215 notRequired=self.notRequiredCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
216 usersite=self.userCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
217 )
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
218 for package, version in installedPackages:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
219 QTreeWidgetItem(self.packagesList, [package, version])
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
220 self.packagesList.setUpdatesEnabled(True)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
221 self.statusLabel.setText(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
222 self.tr("Getting outdated packages..."))
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
223 QApplication.processEvents()
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 # 2. update with update information
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
226 self.packagesList.setUpdatesEnabled(False)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
227 outdatedPackages = self.__pip.getOutdatedPackages(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
228 venvName,
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
229 localPackages=self.localCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
230 notRequired=self.notRequiredCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
231 usersite=self.userCheckBox.isChecked(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
232 )
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
233 for package, _version, latest in outdatedPackages:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
234 items = self.packagesList.findItems(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
235 package, Qt.MatchExactly | Qt.MatchCaseSensitive)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
236 if items:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
237 itm = items[0]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
238 itm.setText(2, latest)
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 self.packagesList.sortItems(0, Qt.AscendingOrder)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 for col in range(self.packagesList.columnCount()):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 self.packagesList.resizeColumnToContents(col)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 self.packagesList.setUpdatesEnabled(True)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 QApplication.restoreOverrideCursor()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.statusLabel.hide()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self.__updateActionButtons()
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.__updateSearchActionButtons()
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
249 self.__updateSearchButton()
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
251 @pyqtSlot(int)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
252 def on_environmentsComboBox_currentIndexChanged(self, index):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
253 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
254 Private slot handling the selection of a conda environment.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
255
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
256 @param index index of the selected conda environment
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
257 @type int
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
258 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
259 self.__refreshPackagesList()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
260
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
261 @pyqtSlot(bool)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
262 def on_localCheckBox_clicked(self, checked):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
263 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
264 Private slot handling the switching of the local mode.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
265
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
266 @param checked state of the local check box
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
267 @type bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
268 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
269 self.__refreshPackagesList()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
270
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
271 @pyqtSlot(bool)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
272 def on_notRequiredCheckBox_clicked(self, checked):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
273 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
274 Private slot handling the switching of the 'not required' mode.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
275
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
276 @param checked state of the 'not required' check box
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
277 @type bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
278 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
279 self.__refreshPackagesList()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
280
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
281 @pyqtSlot(bool)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
282 def on_userCheckBox_clicked(self, checked):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
283 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
284 Private slot handling the switching of the 'user-site' mode.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
285
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
286 @param checked state of the 'user-site' check box
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
287 @type bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
288 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
289 self.__refreshPackagesList()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
290
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
291 @pyqtSlot()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
292 def on_packagesList_itemSelectionChanged(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
293 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
294 Private slot handling the selection of a package.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
295 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
296 self.infoWidget.clear()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
297
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
298 if len(self.packagesList.selectedItems()) == 1:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
299 itm = self.packagesList.selectedItems()[0]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
300
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
301 environment = self.environmentsComboBox.currentText()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
302 interpreter = self.__pip.getVirtualenvInterpreter(environment)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
303 if not interpreter:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
304 return
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
305
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
306 QApplication.setOverrideCursor(Qt.WaitCursor)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
307
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
308 args = ["-m", "pip", "show"]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
309 if self.verboseCheckBox.isChecked():
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
310 args.append("--verbose")
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
311 if self.installedFilesCheckBox.isChecked():
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
312 args.append("--files")
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
313 args.append(itm.text(0))
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
314 success, output = self.__pip.runProcess(args, interpreter)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
315
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
316 if success and output:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
317 mode = self.ShowProcessGeneralMode
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
318 for line in output.splitlines():
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
319 line = line.rstrip()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
320 if line != "---":
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
321 if mode != self.ShowProcessGeneralMode:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
322 if line[0] == " ":
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
323 QTreeWidgetItem(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
324 self.infoWidget,
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
325 [" ", line.strip()])
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
326 else:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
327 mode = self.ShowProcessGeneralMode
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
328 if mode == self.ShowProcessGeneralMode:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
329 try:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
330 label, info = line.split(": ", 1)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
331 except ValueError:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
332 label = line[:-1]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
333 info = ""
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
334 label = label.lower()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
335 if label in self.__infoLabels:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
336 QTreeWidgetItem(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
337 self.infoWidget,
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
338 [self.__infoLabels[label], info])
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
339 if label == "files":
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
340 mode = self.ShowProcessFilesListMode
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
341 elif label == "classifiers":
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
342 mode = self.ShowProcessClassifiersMode
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
343 elif label == "entry-points":
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
344 mode = self.ShowProcessEntryPointsMode
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
345 self.infoWidget.scrollToTop()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
346
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
347 header = self.infoWidget.header()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
348 header.setStretchLastSection(False)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
349 header.resizeSections(QHeaderView.ResizeToContents)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
350 if header.sectionSize(0) + header.sectionSize(1) < header.width():
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
351 header.setStretchLastSection(True)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
352
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
353 QApplication.restoreOverrideCursor()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
354
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
355 self.__updateActionButtons()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
356
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
357 @pyqtSlot(bool)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
358 def on_verboseCheckBox_clicked(self, checked):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
359 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
360 Private slot to handle a change of the verbose package information
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
361 checkbox.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
362
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
363 @param checked state of the checkbox
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
364 @type bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
365 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
366 self.on_packagesList_itemSelectionChanged()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
367
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
368 @pyqtSlot(bool)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
369 def on_installedFilesCheckBox_clicked(self, checked):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
370 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
371 Private slot to handle a change of the installed files information
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
372 checkbox.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
373
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
374 @param checked state of the checkbox
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
375 @type bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
376 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
377 self.on_packagesList_itemSelectionChanged()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
378
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
379 @pyqtSlot()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
380 def on_refreshButton_clicked(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
381 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
382 Private slot to refresh the display.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
383 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
384 currentEnvironment = self.environmentsComboBox.currentText()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
385 self.environmentsComboBox.clear()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
386 self.packagesList.clear()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
387
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
388 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
389 QApplication.processEvents()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
390
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
391 self.__populateEnvironments()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
392
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
393 index = self.environmentsComboBox.findText(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
394 currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
395 if index != -1:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
396 self.environmentsComboBox.setCurrentIndex(index)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
397
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
398 QApplication.restoreOverrideCursor()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
399 self.__updateActionButtons()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
400
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
401 @pyqtSlot()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
402 def on_upgradeButton_clicked(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
403 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
404 Private slot to upgrade selected packages of the selected environment.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
405 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
406 packages = [itm.text(0) for itm in self.__selectedUpdateableItems()]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
407 if packages:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
408 ok = self.__executeUpgradePackages(packages)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
409 if ok:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
410 self.on_refreshButton_clicked()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
411
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
412 @pyqtSlot()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
413 def on_upgradeAllButton_clicked(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
414 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
415 Private slot to upgrade all packages of the selected environment.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
416 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
417 packages = [itm.text(0) for itm in self.__allUpdateableItems()]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
418 if packages:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
419 ok = self.__executeUpgradePackages(packages)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
420 if ok:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
421 self.on_refreshButton_clicked()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
422
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
423 @pyqtSlot()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
424 def on_uninstallButton_clicked(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
425 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
426 Private slot to remove selected packages of the selected environment.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
427 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
428 packages = [itm.text(0) for itm in self.packagesList.selectedItems()]
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
429 if packages:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
430 ok = self.__pip.uninstallPackages(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
431 packages,
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
432 venvName=self.environmentsComboBox.currentText())
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
433 if ok:
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
434 self.on_refreshButton_clicked()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
435
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
436 def __executeUpgradePackages(self, packages):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
437 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
438 Private method to execute the pip upgrade command.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
439
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
440 @param packages list of package names to be upgraded
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
441 @type list of str
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
442 @return flag indicating success
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
443 @rtype bool
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
444 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
445 ok = self.__pip.upgradePackages(
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
446 packages, venvName=self.environmentsComboBox.currentText(),
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
447 userSite=self.userCheckBox.isChecked())
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
448 return ok
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
449
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 #######################################################################
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 ## Search widget related methods below
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 #######################################################################
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 def __updateSearchActionButtons(self):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 Private method to update the action button states of the search widget.
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
458 installEnable = (
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
459 len(self.searchResultList.selectedItems()) > 0 and
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
460 self.environmentsComboBox.currentIndex() > 0 and
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
461 self.__isPipAvailable()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
462 )
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
463 self.installButton.setEnabled(installEnable)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
464 self.installUserSiteButton.setEnabled(installEnable)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
465
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 self.showDetailsButton.setEnabled(
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
467 len(self.searchResultList.selectedItems()) == 1 and
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
468 self.__isPipAvailable()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
469 )
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
470
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
471 def __updateSearchButton(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
472 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
473 Private method to update the state of the search button.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
474 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
475 self.searchButton.setEnabled(
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
476 (bool(self.searchEditName.text()) or
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
477 bool(self.searchEditSummary.text())) and
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
478 self.__isPipAvailable()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
479 )
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 @pyqtSlot(bool)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 def on_searchToggleButton_toggled(self, checked):
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 Private slot to togle the search widget.
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 @param checked state of the search widget button
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 @type bool
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 """
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 self.searchWidget.setVisible(checked)
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 if checked:
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
492 self.searchEditName.setFocus(Qt.OtherFocusReason)
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
493 self.searchEditName.selectAll()
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.__updateSearchActionButtons()
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
496 self.__updateSearchButton()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
497
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
498 @pyqtSlot(str)
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
499 def on_searchEditName_textChanged(self, txt):
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
500 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
501 Private slot handling a change of the search term.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
502
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
503 @param txt search term
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
504 @type str
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
505 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
506 self.__updateSearchButton()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
507
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
508 @pyqtSlot()
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
509 def on_searchEditName_returnPressed(self):
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
510 """
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
511 Private slot initiating a search via a press of the Return key.
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
512 """
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
513 self.__search()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
514
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
515 @pyqtSlot(str)
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
516 def on_searchEditSummary_textChanged(self, txt):
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
517 """
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
518 Private slot handling a change of the search term.
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
519
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
520 @param txt search term
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
521 @type str
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
522 """
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
523 self.__updateSearchButton()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
524
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
525 @pyqtSlot()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
526 def on_searchEditSummary_returnPressed(self):
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
527 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
528 Private slot initiating a search via a press of the Return key.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
529 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
530 self.__search()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
531
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
532 @pyqtSlot()
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
533 def on_searchButton_clicked(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
534 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
535 Private slot handling a press of the search button.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
536 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
537 self.__search()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
538
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
539 @pyqtSlot()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
540 def on_searchResultList_itemSelectionChanged(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
541 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
542 Private slot handling changes of the search result selection.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
543 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
544 self.__updateSearchActionButtons()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
545
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
546 def __search(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
547 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
548 Private method to perform the search.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
549 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
550 self.searchResultList.clear()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
551 self.searchInfoLabel.clear()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
552
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
553 self.searchButton.setEnabled(False)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
554 QApplication.setOverrideCursor(Qt.WaitCursor)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
555 QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
556
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
557 self.__queryName = [
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
558 term for term in self.searchEditName.text().strip().split()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
559 if term not in self.SearchStopwords
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
560 ]
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
561 self.__querySummary = [
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
562 term for term in self.searchEditSummary.text().strip().split()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
563 if term not in self.SearchStopwords
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
564 ]
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
565 self.__client.call(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
566 "search",
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
567 ({"name": self.__queryName,
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
568 "summary": self.__querySummary},
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
569 self.searchTermCombineComboBox.currentText()),
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
570 self.__processSearchResult,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
571 self.__searchError
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
572 )
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
573
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
574 def __processSearchResult(self, data):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
575 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
576 Private method to process the search result data from PyPI.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
577
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
578 @param data result data with hits in the first element
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
579 @type tuple
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
580 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
581 if data:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
582 packages = self.__transformHits(data[0])
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
583 if packages:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
584 self.searchInfoLabel.setText(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
585 self.tr("%n package(s) found.", "", len(packages)))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
586 wrapper = textwrap.TextWrapper(width=80)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
587 count = 0
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
588 total = 0
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
589 for package in packages:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
590 itm = QTreeWidgetItem(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
591 self.searchResultList, [
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
592 package['name'].strip(),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
593 "{0:4d}".format(package['score']),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
594 "\n".join([
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
595 wrapper.fill(line) for line in
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
596 package['summary'].strip().splitlines()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
597 ])
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
598 ])
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
599 itm.setData(0, self.SearchVersionRole, package['version'])
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
600 count += 1
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
601 total += 1
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
602 if count == 100:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
603 count = 0
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
604 QApplication.processEvents()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
605 else:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
606 QApplication.restoreOverrideCursor()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
607 E5MessageBox.warning(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
608 self,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
609 self.tr("Search PyPI"),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
610 self.tr("""<p>The package search did not return"""
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
611 """ anything.</p>"""))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
612 self.searchInfoLabel.setText(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
613 self.tr("""<p>The package search did not return"""
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
614 """ anything.</p>"""))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
615 else:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
616 QApplication.restoreOverrideCursor()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
617 E5MessageBox.warning(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
618 self,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
619 self.tr("Search PyPI"),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
620 self.tr("""<p>The package search did not return anything."""
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
621 """</p>"""))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
622 self.searchInfoLabel.setText(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
623 self.tr("""<p>The package search did not return anything."""
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
624 """</p>"""))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
625
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
626 header = self.searchResultList.header()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
627 self.searchResultList.sortItems(1, Qt.DescendingOrder)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
628 header.setStretchLastSection(False)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
629 header.resizeSections(QHeaderView.ResizeToContents)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
630 headerSize = 0
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
631 for col in range(header.count()):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
632 headerSize += header.sectionSize(col)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
633 if headerSize < header.width():
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
634 header.setStretchLastSection(True)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
635
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
636 self.__finishSearch()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
637
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
638 def __finishSearch(self):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
639 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
640 Private slot performing the search finishing actions.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
641 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
642 QApplication.restoreOverrideCursor()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
643
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
644 self.__updateSearchActionButtons()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
645 self.__updateSearchButton()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
646
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
647 self.searchEditName.setFocus(Qt.OtherFocusReason)
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
648
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
649 def __searchError(self, errorCode, errorString):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
650 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
651 Private method handling a search error.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
652
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
653 @param errorCode code of the error
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
654 @type int
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
655 @param errorString error message
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
656 @type str
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
657 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
658 self.__finish()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
659 E5MessageBox.warning(
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
660 self,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
661 self.tr("Search PyPI"),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
662 self.tr("""<p>The package search failed.</p><p>Reason: {0}</p>""")
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
663 .format(errorString))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
664 self.searchInfoLabel.setText(self.tr("Error: {0}").format(errorString))
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
665
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
666 def __transformHits(self, hits):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
667 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
668 Private method to convert the list returned from pypi into a
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
669 packages list.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
670
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
671 @param hits list returned from pypi
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
672 @type list of dict
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
673 @return list of packages
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
674 @rtype list of dict
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
675 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
676 # we only include the record with the highest score
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
677 packages = {}
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
678 for hit in hits:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
679 name = hit['name'].strip()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
680 summary = (hit['summary'] or "").strip()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
681 version = hit['version'].strip()
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
682 score = self.__score(name, summary)
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
683 # cleanup the summary
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
684 if summary in ["UNKNOWN", "."]:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
685 summary = ""
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
686
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
687 if name not in packages:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
688 packages[name] = {
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
689 'name': name,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
690 'summary': summary,
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
691 'version': [version.strip()],
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
692 'score': score}
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
693 else:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
694 if score > packages[name]['score']:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
695 packages[name]['score'] = score
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
696 packages[name]['summary'] = summary
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
697 packages[name]['version'].append(version.strip())
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
698
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
699 return list(packages.values())
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
700
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
701 def __score(self, name, summary):
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
702 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
703 Private method to calculate some score for a search result.
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
704
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
705 @param name name of the returned package
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
706 @type str
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
707 @param summary summary text for the package
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
708 @type str
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
709 @return score value
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
710 @rtype int
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
711 """
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
712 score = 0
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
713 for queryTerm in self.__queryName:
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
714 if queryTerm.lower() in name.lower():
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
715 score += 4
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
716 if queryTerm.lower() == name.lower():
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
717 score += 4
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
718
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
719 for queryTerm in self.__querySummary:
6793
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
720 if queryTerm.lower() in summary.lower():
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
721 if QRegExp(r'\b{0}\b'.format(QRegExp.escape(queryTerm)),
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
722 Qt.CaseInsensitive).indexIn(summary) != -1:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
723 # word match gets even higher score
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
724 score += 2
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
725 else:
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
726 score += 1
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
727
cca6a35f3ad2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
728 return score
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
730 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
731 def on_installButton_clicked(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
732 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
733 Private slot to handle pressing the Install button..
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
734 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
735 self.__install()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
736
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
737 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
738 def on_installUserSiteButton_clicked(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
739 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
740 Private slot to handle pressing the Install to User-Site button..
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
741 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
742 self.__install(userSite=True)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
743
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
744 def __install(self, userSite=False):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
745 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
746 Private slot to install the selected packages.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
747
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
748 @param userSite flag indicating to install to the user directory
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
749 @type bool
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
750 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
751 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
752 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
753 packages = []
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
754 for itm in self.searchResultList.selectedItems():
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
755 packages.append(itm.text(0).strip())
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
756 if packages:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
757 self.__pip.installPackages(packages, venvName=venvName,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
758 userSite=userSite)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
759
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
760 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
761 def on_showDetailsButton_clicked(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
762 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
763 Private slot to handle pressing the Show Details button.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
764 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
765 self.__showDetails()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
766
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
767 @pyqtSlot(QTreeWidgetItem, int)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
768 def on_searchResultList_itemActivated(self, item, column):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
769 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
770 Private slot reacting on an search result item activation.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
771
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
772 @param item reference to the activated item
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
773 @type QTreeWidgetItem
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
774 @param column activated column
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
775 @type int
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
776 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
777 self.__showDetails(item)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
778
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
779 def __showDetails(self, item=None):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
780 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
781 Private slot to show details about the selected package.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
782
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
783 @param item reference to the search result item to show details for
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
784 @type QTreeWidgetItem
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
785 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
786 self.showDetailsButton.setEnabled(False)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
787 QApplication.setOverrideCursor(Qt.WaitCursor)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
788 QApplication.processEvents(QEventLoop.ExcludeUserInputEvents)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
789
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
790 if not item:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
791 item = self.searchResultList.selectedItems()[0]
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
792
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
793 packageVersions = item.data(0, self.SearchVersionRole)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
794 if len(packageVersions) == 1:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
795 packageVersion = packageVersions[0]
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
796 elif len(packageVersions) == 0:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
797 packageVersion = ""
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
798 else:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
799 packageVersion, ok = QInputDialog.getItem(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
800 self,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
801 self.tr("Show Package Details"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
802 self.tr("Select the package version:"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
803 packageVersions,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
804 0, False)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
805 if not ok:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
806 return
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
807 packageName = item.text(0)
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
808 packageData = self.__pip.getPackageDetails(packageName, packageVersion)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
809
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
810 QApplication.restoreOverrideCursor()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
811 if packageData:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
812 from .PipPackageDetailsDialog import PipPackageDetailsDialog
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
813
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
814 self.showDetailsButton.setEnabled(True)
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
815
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
816 if self.__packageDetailsDialog is not None:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
817 self.__packageDetailsDialog.close()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
818
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
819 self.__packageDetailsDialog = \
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
820 PipPackageDetailsDialog(packageData, self)
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
821 self.__packageDetailsDialog.show()
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
822 else:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
823 E5MessageBox.warning(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
824 self,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
825 self.tr("Search PyPI"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
826 self.tr("""<p>No package details info for <b>{0}</b>"""
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
827 """ available.</p>""").format(packageName))
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
828
6785
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 #######################################################################
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 ## Menu related methods below
058d63c537a4 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 #######################################################################
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
832
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
833 def __initPipMenu(self):
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
834 """
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
835 Private method to create the super menu and attach it to the super
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
836 menu button.
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
837 """
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
838 self.__pipMenu = QMenu()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
839 self.__installPipAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
840 self.tr("Install Pip"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
841 self.__installPip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
842 self.__installPipUserAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
843 self.tr("Install Pip to User-Site"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
844 self.__installPipUser)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
845 self.__repairPipAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
846 self.tr("Repair Pip"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
847 self.__repairPip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
848 self.__pipMenu.addSeparator()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
849 self.__installPackagesAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
850 self.tr("Install Packages"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
851 self.__installPackages)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
852 self.__installLocalPackageAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
853 self.tr("Install Local Package"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
854 self.__installLocalPackage)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
855 self.__pipMenu.addSeparator()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
856 self.__installRequirementsAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
857 self.tr("Install Requirements"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
858 self.__installRequirements)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
859 self.__uninstallRequirementsAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
860 self.tr("Uninstall Requirements"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
861 self.__uninstallRequirements)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
862 self.__generateRequirementsAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
863 self.tr("Generate Requirements..."),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
864 self.__generateRequirements)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
865 self.__pipMenu.addSeparator()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
866 # editUserConfigAct
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
867 self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
868 self.tr("Edit User Configuration..."),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
869 self.__editUserConfiguration)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
870 self.__editVirtualenvConfigAct = self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
871 self.tr("Edit Current Virtualenv Configuration..."),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
872 self.__editVirtualenvConfiguration)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
873 self.__pipMenu.addSeparator()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
874 # pipConfigAct
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
875 self.__pipMenu.addAction(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
876 self.tr("Configure..."),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
877 self.__pipConfigure)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
878
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
879 self.__pipMenu.aboutToShow.connect(self.__aboutToShowPipMenu)
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
880
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6785
diff changeset
881 self.pipMenuButton.setMenu(self.__pipMenu)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
882
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
883 def __aboutToShowPipMenu(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
884 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
885 Private slot to set the action enabled status.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
886 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
887 enable = bool(self.environmentsComboBox.currentText())
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
888 enablePip = self.__isPipAvailable()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
889
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
890 self.__installPipAct.setEnabled(not enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
891 self.__installPipUserAct.setEnabled(not enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
892 self.__repairPipAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
893
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
894 self.__installPackagesAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
895 self.__installLocalPackageAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
896
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
897 self.__installRequirementsAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
898 self.__uninstallRequirementsAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
899 self.__generateRequirementsAct.setEnabled(enablePip)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
900
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
901 self.__editVirtualenvConfigAct.setEnabled(enable)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
902
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
903 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
904 def __installPip(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
905 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
906 Private slot to install pip into the selected environment.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
907 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
908 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
909 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
910 self.__pip.installPip(venvName)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
911
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
912 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
913 def __installPipUser(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
914 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
915 Private slot to install pip into the user site for the selected
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
916 environment.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
917 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
918 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
919 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
920 self.__pip.installPip(venvName, userSite=True)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
921
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
922 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
923 def __repairPip(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
924 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
925 Private slot to repair the pip installation of the selected
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
926 environment.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
927 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
928 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
929 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
930 self.__pip.repairPip(venvName)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
931
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
932 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
933 def __installPackages(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
934 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
935 Private slot to install packages to be given by the user.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
936 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
937 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
938 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
939 from .PipPackagesInputDialog import PipPackagesInputDialog
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
940 dlg = PipPackagesInputDialog(self, self.tr("Install Packages"))
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
941 if dlg.exec_() == QDialog.Accepted:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
942 packages, user = dlg.getData()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
943 if packages:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
944 self.__pip.installPackages(packages, venvName=venvName,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
945 userSite=user)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
946
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
947 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
948 def __installLocalPackage(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
949 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
950 Private slot to install a package available on local storage.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
951 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
952 venvName = self.environmentsComboBox.currentText()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
953 if venvName:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
954 from .PipFileSelectionDialog import PipFileSelectionDialog
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
955 dlg = PipFileSelectionDialog(self, "package")
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
956 if dlg.exec_() == QDialog.Accepted:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
957 package, user = dlg.getData()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
958 if package and os.path.exists(package):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
959 self.__pip.installPackages([package], venvName=venvName,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
960 userSite=user)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
961
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
962 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
963 def __installRequirements(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
964 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
965 Private slot to install packages as given in a requirements file.
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
966 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
967 venvName = self.environmentsComboBox.currentText()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
968 if venvName:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
969 self.__pip.installRequirements(venvName)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
970
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
971 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
972 def __uninstallRequirements(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
973 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
974 Private slot to uninstall packages as given in a requirements file.
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
975 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
976 venvName = self.environmentsComboBox.currentText()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
977 if venvName:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
978 self.__pip.uninstallRequirements(venvName)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
979
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
980 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
981 def __generateRequirements(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
982 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
983 Private slot to generate the contents for a requirements file.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
984 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
985 venvName = self.environmentsComboBox.currentText()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
986 if venvName:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
987 from .PipFreezeDialog import PipFreezeDialog
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
988 self.__freezeDialog = PipFreezeDialog(self.__pip, self)
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
989 self.__freezeDialog.show()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
990 self.__freezeDialog.start(venvName)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
991
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
992 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
993 def __editUserConfiguration(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
994 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
995 Private slot to edit the user configuration.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
996 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
997 self.__editConfiguration()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
998
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
999 @pyqtSlot()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1000 def __editVirtualenvConfiguration(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1001 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1002 Private slot to edit the configuration of the selected environment.
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1003 """
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1004 venvName = self.environmentsComboBox.currentText()
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1005 if venvName:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1006 self.__editConfiguration(venvName=venvName)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1007
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1008 def __editConfiguration(self, venvName=""):
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1009 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1010 Private method to edit a configuration.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1011
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1012 @param venvName name of the environment to act upon
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1013 @type str
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1014 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1015 from QScintilla.MiniEditor import MiniEditor
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1016 if venvName:
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1017 cfgFile = self.__pip.getVirtualenvConfig(venvName)
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1018 if not cfgFile:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1019 return
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1020 else:
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1021 cfgFile = self.__pip.getUserConfig()
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1022 cfgDir = os.path.dirname(cfgFile)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1023 if not cfgDir:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1024 E5MessageBox.critical(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1025 None,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1026 self.tr("Edit Configuration"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1027 self.tr("""No valid configuration path determined."""
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1028 """ Aborting"""))
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1029 return
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1030
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1031 try:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1032 if not os.path.isdir(cfgDir):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1033 os.makedirs(cfgDir)
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1034 except OSError:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1035 E5MessageBox.critical(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1036 None,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1037 self.tr("Edit Configuration"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1038 self.tr("""No valid configuration path determined."""
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1039 """ Aborting"""))
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1040 return
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1041
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1042 if not os.path.exists(cfgFile):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1043 try:
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1044 f = open(cfgFile, "w")
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1045 f.write("[global]\n")
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1046 f.close()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1047 except (IOError, OSError):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1048 # ignore these
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1049 pass
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1050
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1051 # check, if the destination is writeable
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1052 if not os.access(cfgFile, os.W_OK):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1053 E5MessageBox.critical(
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1054 None,
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1055 self.tr("Edit Configuration"),
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1056 self.tr("""No valid configuartion path determined."""
6798
3985c1a67fa2 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6795
diff changeset
1057 """ Aborting"""))
6795
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1058 return
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1059
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1060 self.__editor = MiniEditor(cfgFile, "Properties")
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1061 self.__editor.show()
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1062
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1063 def __pipConfigure(self):
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1064 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1065 Private slot to open the configuration page.
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1066 """
6e2ed2aac325 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6793
diff changeset
1067 e5App().getObject("UserInterface").showPreferences("pipPage")

eric ide

mercurial