1 parent
b124de4f04
commit
1f97ee333d
2 files changed
+27
-16
No files matched your search
@@ -8,7 +8,6 @@ import octoprint.plugin
|
||||
from octoprint.access import ADMIN_GROUP
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.events import Events
|
||||
from octoprint.plugin.core import FolderOrigin
|
||||
from octoprint.server import NO_CONTENT
|
||||
from octoprint.server.util.flask import no_firstrun_access
|
||||
from octoprint.settings import default_settings
|
||||
@@ -980,22 +979,14 @@ class BackupPlugin(
|
||||
)
|
||||
|
||||
# add list of installed plugins
|
||||
plugins = []
|
||||
plugin_folder = settings.global_get_basefolder("plugins")
|
||||
for plugin in plugin_manager.plugins.values():
|
||||
if plugin.bundled or (
|
||||
isinstance(plugin.origin, FolderOrigin)
|
||||
and plugin.origin.folder == plugin_folder
|
||||
):
|
||||
# ignore anything bundled or from the plugins folder we already include in the backup
|
||||
continue
|
||||
helpers = plugin_manager.get_helpers(
|
||||
"pluginmanager", "generate_plugins_json"
|
||||
)
|
||||
if helpers and "generate_plugins_json" in helpers:
|
||||
plugins = helpers["generate_plugins_json"]()
|
||||
|
||||
plugins.append(
|
||||
{"key": plugin.key, "name": plugin.name, "url": plugin.url}
|
||||
)
|
||||
|
||||
if len(plugins):
|
||||
zip.writestr("plugin_list.json", json.dumps(plugins))
|
||||
if len(plugins):
|
||||
zip.writestr("plugin_list.json", json.dumps(plugins))
|
||||
|
||||
shutil.move(temporary_path, final_path)
|
||||
|
||||
|
||||
@@ -1755,6 +1755,21 @@ class PluginManagerPlugin(
|
||||
|
||||
return result
|
||||
|
||||
def generate_plugins_json(self, ignore_bundled=True, ignore_plugins_folder=True):
|
||||
plugins = []
|
||||
plugin_folder = self._settings.getBaseFolder("plugins")
|
||||
for plugin in self._plugin_manager.plugins.values():
|
||||
if (ignore_bundled and plugin.bundled) or (
|
||||
ignore_plugins_folder
|
||||
and isinstance(plugin.origin, octoprint.plugin.core.FolderOrigin)
|
||||
and plugin.origin.folder == plugin_folder
|
||||
):
|
||||
# ignore bundled or from the plugins folder already included in the backup
|
||||
continue
|
||||
|
||||
plugins.append({"key": plugin.key, "name": plugin.name, "url": plugin.url})
|
||||
return plugins
|
||||
|
||||
def _to_external_plugin(self, plugin):
|
||||
return {
|
||||
"key": plugin.key,
|
||||
@@ -1898,3 +1913,8 @@ def __plugin_load__():
|
||||
"octoprint.events.register_custom_events": _register_custom_events,
|
||||
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions,
|
||||
}
|
||||
|
||||
global __plugin_helpers__
|
||||
__plugin_helpers__ = {
|
||||
"generate_plugins_json": __plugin_implementation__.generate_plugins_json,
|
||||
}
|
||||
Reference in new issue
Block a user