Skip to content

Commit 54438f7

Browse files
Gustrynyalldawson
authored andcommittedAug 3, 2023
Minor review of the Python code in the QGIS plugin manager
1 parent ac45ceb commit 54438f7

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed
 

‎python/pyplugin_installer/installer.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from qgis.PyQt.QtNetwork import QNetworkRequest
4444

4545
import qgis
46-
from qgis.core import Qgis, QgsApplication, QgsNetworkAccessManager, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
46+
from qgis.core import Qgis, QgsApplication, QgsMessageLog, QgsNetworkAccessManager, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
4747
from qgis.gui import QgsMessageBar, QgsPasswordLineEdit, QgsHelp
4848
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin, OverrideCursor,
4949
reloadPlugin, updateAvailablePlugins, plugins_metadata_parser)
@@ -155,30 +155,30 @@ def checkingDone(self):
155155
plugins.rebuild()
156156
# look for news in the repositories
157157
plugins.markNews()
158-
status = None
159158
# then check for updates (and eventually overwrite status)
160-
updatable_count = 0
161-
updatable_plugin_name = None
159+
updatable_plugin_names = []
162160
for _, properties in plugins.all().items():
163161
if properties["status"] == "upgradeable":
164-
updatable_count += 1
165-
updatable_plugin_name = properties["name"]
162+
updatable_plugin_names.append(properties["name"])
166163

167-
if updatable_count:
168-
if updatable_count > 1:
169-
status = self.tr("Multiple plugin updates are available")
170-
else:
171-
status = self.tr("An update to the {} plugin is available").format(updatable_plugin_name)
172-
tabIndex = 3 # PLUGMAN_TAB_UPGRADEABLE
173-
174-
# finally set the notify label
175-
if status:
176-
bar = iface.messageBar()
177-
self.message_bar_widget = bar.createMessage('', status)
178-
update_button = QPushButton("Install Updates…")
179-
update_button.pressed.connect(partial(self.showPluginManagerWhenReady, tabIndex))
180-
self.message_bar_widget.layout().addWidget(update_button)
181-
bar.pushWidget(self.message_bar_widget, Qgis.Info)
164+
if not updatable_plugin_names:
165+
return
166+
167+
if len(updatable_plugin_names) >= 2:
168+
status = self.tr("Multiple plugin updates are available")
169+
else:
170+
status = self.tr("An update to the {} plugin is available").format(updatable_plugin_names[0])
171+
172+
QgsMessageLog.logMessage(
173+
"Plugin update(s) available : {}".format(','.join(updatable_plugin_names)), self.tr("Plugins"))
174+
175+
bar = iface.messageBar()
176+
self.message_bar_widget = bar.createMessage('', status)
177+
update_button = QPushButton(self.tr("Install Updates…"))
178+
tab_index = 3 # PLUGMAN_TAB_UPGRADEABLE
179+
update_button.pressed.connect(partial(self.showPluginManagerWhenReady, tab_index))
180+
self.message_bar_widget.layout().addWidget(update_button)
181+
bar.pushWidget(self.message_bar_widget, Qgis.Info)
182182

183183
# ----------------------------------------- #
184184
def exportRepositoriesToManager(self):

0 commit comments

Comments
 (0)
Please sign in to comment.