From 19c912866d72f3d7df6cc9e9c88fc6db10982d9f Mon Sep 17 00:00:00 2001 From: Justin Findlay Date: Fri, 5 Jun 2015 16:52:02 -0600 Subject: [PATCH] catch exception from softwarerepositories Fixes #24318. --- salt/modules/aptpkg.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py index 33f85fed9b..b2bd8d44dc 100644 --- a/salt/modules/aptpkg.py +++ b/salt/modules/aptpkg.py @@ -1249,13 +1249,18 @@ def get_repo(repo, **kwargs): ppa_name, dist) else: if HAS_SOFTWAREPROPERTIES: - if hasattr(softwareproperties.ppa, 'PPAShortcutHandler'): - repo = softwareproperties.ppa.PPAShortcutHandler(repo).expand( - __grains__['lsb_distrib_codename'])[0] - else: - repo = softwareproperties.ppa.expand_ppa_line( - repo, - __grains__['lsb_distrib_codename'])[0] + try: + if hasattr(softwareproperties.ppa, 'PPAShortcutHandler'): + repo = softwareproperties.ppa.PPAShortcutHandler( + repo).expand(dist)[0] + else: + repo = softwareproperties.ppa.expand_ppa_line( + repo, + dist)[0] + except NameError as name_error: + raise CommandExecutionError( + 'Could not find ppa {0}: {1}'.format(repo, name_error) + ) else: repo = LP_SRC_FORMAT.format(owner_name, ppa_name, dist)