Delete plugins from disk
(self, plugin_ids)
| 346 | |
| 347 | @Expose |
| 348 | def remove_plugins(self, plugin_ids): |
| 349 | """ |
| 350 | Delete plugins from disk |
| 351 | """ |
| 352 | if not plugin_ids: |
| 353 | return |
| 354 | |
| 355 | removed = set() |
| 356 | |
| 357 | self.log_debug("Requested deletion of plugins: %s" % plugin_ids) |
| 358 | |
| 359 | for plugin_type, plugin_name in plugin_ids: |
| 360 | rootplugins = os.path.join(pypath, "module", "plugins") |
| 361 | |
| 362 | for basedir in ("userplugins", rootplugins): |
| 363 | py_filename = fsjoin(basedir, plugin_type, plugin_name + ".py") |
| 364 | pyc_filename = py_filename + "c" |
| 365 | |
| 366 | if plugin_type == "hook": |
| 367 | try: |
| 368 | self.manager.deactivateHook(plugin_name) |
| 369 | |
| 370 | except Exception, e: |
| 371 | self.log_debug(e, trace=True) |
| 372 | |
| 373 | for filename in (py_filename, pyc_filename): |
| 374 | if not exists(filename): |
| 375 | continue |
| 376 | |
| 377 | try: |
| 378 | os.remove(filename) |
| 379 | |
| 380 | except OSError, e: |
| 381 | self.log_warning(_("Error removing `%s`") % filename, e) |
| 382 | |
| 383 | else: |
| 384 | plugin_id = (plugin_type, plugin_name) |
| 385 | removed.add(plugin_id) |
| 386 | |
| 387 | #: Return a list of the plugins successfully removed |
| 388 | return list(removed) |
no test coverage detected