diff options
Diffstat (limited to 'scripts/lib/mic')
| -rw-r--r-- | scripts/lib/mic/plugin.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/scripts/lib/mic/plugin.py b/scripts/lib/mic/plugin.py index df03c15081..bec33d6164 100644 --- a/scripts/lib/mic/plugin.py +++ b/scripts/lib/mic/plugin.py | |||
| @@ -20,12 +20,14 @@ import os, sys | |||
| 20 | from mic import msger | 20 | from mic import msger |
| 21 | from mic import pluginbase | 21 | from mic import pluginbase |
| 22 | from mic.utils import errors | 22 | from mic.utils import errors |
| 23 | 23 | from mic.utils.oe.misc import * | |
| 24 | 24 | ||
| 25 | __ALL__ = ['PluginMgr', 'pluginmgr'] | 25 | __ALL__ = ['PluginMgr', 'pluginmgr'] |
| 26 | 26 | ||
| 27 | PLUGIN_TYPES = ["imager", "source"] # TODO "hook" | 27 | PLUGIN_TYPES = ["imager", "source"] # TODO "hook" |
| 28 | 28 | ||
| 29 | PLUGIN_DIR = "/lib/mic/plugins" # relative to scripts | ||
| 30 | SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR | ||
| 29 | 31 | ||
| 30 | class PluginMgr(object): | 32 | class PluginMgr(object): |
| 31 | plugin_dirs = {} | 33 | plugin_dirs = {} |
| @@ -42,8 +44,23 @@ class PluginMgr(object): | |||
| 42 | mic_path = os.path.dirname(__file__) | 44 | mic_path = os.path.dirname(__file__) |
| 43 | eos = mic_path.find('scripts') + len('scripts') | 45 | eos = mic_path.find('scripts') + len('scripts') |
| 44 | scripts_path = mic_path[:eos] | 46 | scripts_path = mic_path[:eos] |
| 47 | self.scripts_path = scripts_path | ||
| 48 | self.plugin_dir = scripts_path + PLUGIN_DIR | ||
| 49 | self.layers_path = None | ||
| 50 | |||
| 51 | def _build_plugin_dir_list(self, dl, ptype): | ||
| 52 | if self.layers_path is None: | ||
| 53 | self.layers_path = get_bitbake_var("BBLAYERS") | ||
| 54 | layer_dirs = [] | ||
| 55 | |||
| 56 | for layer_path in self.layers_path.split(): | ||
| 57 | path = os.path.join(layer_path, SCRIPTS_PLUGIN_DIR, ptype) | ||
| 58 | layer_dirs.append(path) | ||
| 45 | 59 | ||
| 46 | self.plugin_dir = scripts_path + "/lib/mic/plugins" | 60 | path = os.path.join(dl, ptype) |
| 61 | layer_dirs.append(path) | ||
| 62 | |||
| 63 | return layer_dirs | ||
| 47 | 64 | ||
| 48 | def append_dirs(self, dirs): | 65 | def append_dirs(self, dirs): |
| 49 | for path in dirs: | 66 | for path in dirs: |
| @@ -56,7 +73,7 @@ class PluginMgr(object): | |||
| 56 | path = os.path.abspath(os.path.expanduser(path)) | 73 | path = os.path.abspath(os.path.expanduser(path)) |
| 57 | 74 | ||
| 58 | if not os.path.isdir(path): | 75 | if not os.path.isdir(path): |
| 59 | msger.warning("Plugin dir is not a directory or does not exist: %s"\ | 76 | msger.debug("Plugin dir is not a directory or does not exist: %s"\ |
| 60 | % path) | 77 | % path) |
| 61 | return | 78 | return |
| 62 | 79 | ||
| @@ -93,8 +110,9 @@ class PluginMgr(object): | |||
| 93 | if ptype not in PLUGIN_TYPES: | 110 | if ptype not in PLUGIN_TYPES: |
| 94 | raise errors.CreatorError('%s is not valid plugin type' % ptype) | 111 | raise errors.CreatorError('%s is not valid plugin type' % ptype) |
| 95 | 112 | ||
| 96 | self._add_plugindir(os.path.join(self.plugin_dir, ptype)) | 113 | plugins_dir = self._build_plugin_dir_list(self.plugin_dir, ptype) |
| 97 | self._load_all() | 114 | |
| 115 | self.append_dirs(plugins_dir) | ||
| 98 | 116 | ||
| 99 | return pluginbase.get_plugins(ptype) | 117 | return pluginbase.get_plugins(ptype) |
| 100 | 118 | ||
