Skip to content

Commit 5986ed6

Browse files
committed
Fixed silent fail when broken recipes are imported
1 parent 46df999 commit 5986ed6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pythonforandroid/toolchain.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,11 +1771,15 @@ def get_recipe(cls, name, ctx):
17711771
cls.recipes = {}
17721772
if name in cls.recipes:
17731773
return cls.recipes[name]
1774+
recipe_dir = join(ctx.root_dir, 'recipes', name)
1775+
if not exists(recipe_dir): # AND: This will need modifying
1776+
# for user-supplied recipes
1777+
raise IOError('Recipe folder does not exist')
17741778
mod = importlib.import_module("pythonforandroid.recipes.{}".format(name))
17751779
if len(logger.handlers) > 1:
17761780
logger.removeHandler(logger.handlers[1])
17771781
recipe = mod.recipe
1778-
recipe.recipe_dir = join(ctx.root_dir, "recipes", name)
1782+
recipe.recipe_dir = recipe_dir
17791783
recipe.ctx = ctx
17801784
return recipe
17811785

@@ -2240,10 +2244,17 @@ def get_recipe_order_and_bootstrap(ctx, names, bs=None):
22402244
continue
22412245
try:
22422246
recipe = Recipe.get_recipe(name, ctx)
2243-
except ImportError:
2247+
except IOError:
22442248
info('No recipe named {}; will attempt to install with pip'.format(name))
22452249
python_modules.append(name)
22462250
continue
2251+
except (KeyboardInterrupt, SystemExit):
2252+
raise
2253+
except:
2254+
warning('Failed to import recipe named {}; the recipe exists '
2255+
'but appears broken.'.format(name))
2256+
warning('Exception was:')
2257+
raise
22472258
graph.add(name, name)
22482259
info('Loaded recipe {} (depends on {}{})'.format(
22492260
name, recipe.depends,

0 commit comments

Comments
 (0)