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