MCPcopy Index your code
hub / github.com/pyload/pyload / _update_plugins

Method _update_plugins

module/plugins/hooks/UpdateManager.py:247–337  ·  view source on GitHub ↗

Check for plugin updates

(self, server_data)

Source from the content-addressed store, hash-verified

245 return updatelist, blacklist
246
247 def _update_plugins(self, server_data):
248 """
249 Check for plugin updates
250 """
251 updated = []
252
253 updatelist, blacklist = self.parse_updates(server_data)
254
255 url = server_data[1]
256 req = self.pyload.requestFactory.getRequest(self.classname)
257
258 if blacklist:
259 #@NOTE: Protect UpdateManager from self-removing
260 if os.name == "nt":
261 #@NOTE: Windows filesystem is case insensitive, make sure we do not delete legitimate plugins
262 whitelisted_plugins = [
263 (plugin['type'], plugin['name'].upper()) for plugin in updatelist]
264 blacklisted_plugins = [(plugin['type'], plugin['name']) for plugin in blacklist
265 if not (plugin['name'] == self.classname and plugin['type'] == self.__type__)
266 and (plugin['type'], plugin['name'].upper()) not in whitelisted_plugins]
267 else:
268 blacklisted_plugins = [(plugin['type'], plugin['name']) for plugin in blacklist
269 if not (plugin['name'] == self.classname and plugin['type'] == self.__type__)]
270
271 c = 1
272 l = len(blacklisted_plugins)
273 for idx, plugin in enumerate(updatelist):
274 if c > l:
275 break
276 plugin_name = plugin['name']
277 plugin_type = plugin['type']
278 for t, n in blacklisted_plugins:
279 if n != plugin_name or t != plugin_type:
280 continue
281 updatelist.pop(idx)
282 c += 1
283 break
284
285 for t, n in self.remove_plugins(blacklisted_plugins):
286 self.log_info(_("Removed blacklisted plugin: %(type)s %(name)s") %
287 {'type': t.upper(),
288 'name': n,})
289
290 for plugin in updatelist:
291 plugin_name = plugin['name']
292 plugin_type = plugin['type']
293 plugin_version = plugin['version']
294
295 plugins = getattr(self.pyload.pluginManager,
296 "%sPlugins" % plugin_type.rstrip('s')) # @TODO: Remove rstrip in 0.4.10
297
298 oldver = float(plugins[plugin_name]['v']) if plugin_name in plugins else None
299 try:
300 newver = float(plugin_version)
301 except ValueError:
302 self.log_error(_("Error updating plugin: %s %s") % (plugin_type.rstrip('s').upper(), plugin_name),
303 _("Bad version number on the server"))
304 continue

Callers 1

update_pluginsMethod · 0.95

Calls 13

parse_updatesMethod · 0.95
remove_pluginsMethod · 0.95
fsjoinFunction · 0.85
encodeFunction · 0.85
getRequestMethod · 0.80
popMethod · 0.80
log_infoMethod · 0.80
log_errorMethod · 0.80
_Function · 0.50
loadMethod · 0.45
searchMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected