diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-08-05 15:48:00 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-03 23:45:54 +0100 |
commit | e616beba1c85e31246d1c798191b194d168b3489 (patch) | |
tree | 5b9d19e7c4a7caeb72f1bb9da4a2b221cfb1da96 /scripts/recipetool | |
parent | f2854c67ce963211f27223bd1194420621694bc2 (diff) | |
download | poky-e616beba1c85e31246d1c798191b194d168b3489.tar.gz |
scripts: ensure tinfoil is shut down correctly
We should always shut down tinfoil when we're finished with it, either
by explicitly calling the shutdown() method or by using it as a
context manager ("with ...").
(From OE-Core rev: 5ec6d9ef309b841cdcbf1d14ac678d106d5d888a)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/recipetool')
-rwxr-xr-x | scripts/recipetool | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/scripts/recipetool b/scripts/recipetool index 17233d4ef0..1052cd2b22 100755 --- a/scripts/recipetool +++ b/scripts/recipetool | |||
@@ -77,37 +77,40 @@ def main(): | |||
77 | scriptutils.logger_setup_color(logger, global_args.color) | 77 | scriptutils.logger_setup_color(logger, global_args.color) |
78 | 78 | ||
79 | tinfoil = tinfoil_init(False) | 79 | tinfoil = tinfoil_init(False) |
80 | for path in ([scripts_path] + | ||
81 | tinfoil.config_data.getVar('BBPATH', True).split(':')): | ||
82 | pluginpath = os.path.join(path, 'lib', 'recipetool') | ||
83 | scriptutils.load_plugins(logger, plugins, pluginpath) | ||
84 | |||
85 | registered = False | ||
86 | for plugin in plugins: | ||
87 | if hasattr(plugin, 'register_commands'): | ||
88 | registered = True | ||
89 | plugin.register_commands(subparsers) | ||
90 | elif hasattr(plugin, 'register_command'): | ||
91 | # Legacy function name | ||
92 | registered = True | ||
93 | plugin.register_command(subparsers) | ||
94 | if hasattr(plugin, 'tinfoil_init'): | ||
95 | plugin.tinfoil_init(tinfoil) | ||
96 | |||
97 | if not registered: | ||
98 | logger.error("No commands registered - missing plugins?") | ||
99 | sys.exit(1) | ||
100 | |||
101 | args = parser.parse_args(unparsed_args, namespace=global_args) | ||
102 | |||
103 | try: | 80 | try: |
104 | if getattr(args, 'parserecipes', False): | 81 | for path in ([scripts_path] + |
105 | tinfoil.config_data.disableTracking() | 82 | tinfoil.config_data.getVar('BBPATH', True).split(':')): |
106 | tinfoil.parseRecipes() | 83 | pluginpath = os.path.join(path, 'lib', 'recipetool') |
107 | tinfoil.config_data.enableTracking() | 84 | scriptutils.load_plugins(logger, plugins, pluginpath) |
108 | ret = args.func(args) | 85 | |
109 | except bb.BBHandledException: | 86 | registered = False |
110 | ret = 1 | 87 | for plugin in plugins: |
88 | if hasattr(plugin, 'register_commands'): | ||
89 | registered = True | ||
90 | plugin.register_commands(subparsers) | ||
91 | elif hasattr(plugin, 'register_command'): | ||
92 | # Legacy function name | ||
93 | registered = True | ||
94 | plugin.register_command(subparsers) | ||
95 | if hasattr(plugin, 'tinfoil_init'): | ||
96 | plugin.tinfoil_init(tinfoil) | ||
97 | |||
98 | if not registered: | ||
99 | logger.error("No commands registered - missing plugins?") | ||
100 | sys.exit(1) | ||
101 | |||
102 | args = parser.parse_args(unparsed_args, namespace=global_args) | ||
103 | |||
104 | try: | ||
105 | if getattr(args, 'parserecipes', False): | ||
106 | tinfoil.config_data.disableTracking() | ||
107 | tinfoil.parseRecipes() | ||
108 | tinfoil.config_data.enableTracking() | ||
109 | ret = args.func(args) | ||
110 | except bb.BBHandledException: | ||
111 | ret = 1 | ||
112 | finally: | ||
113 | tinfoil.shutdown() | ||
111 | 114 | ||
112 | return ret | 115 | return ret |
113 | 116 | ||