eric6/PipInterface/PipPackagesWidget.py

Sat, 21 Sep 2019 18:30:02 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 21 Sep 2019 18:30:02 +0200
changeset 7255
d595f6f9cbf8
parent 7241
0c0c9015c40f
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

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

eric ide

mercurial