From c642ee91572bc8c71762b2ed03d22488d71b48c1 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2020 09:36:03 +0100 Subject: [PATCH] Fix #1435: mas : Fix "invalid literal" when no app (#1436) (#1448) * Fix #1435: mas : Fix "invalid literal" when no app * Add changelog fragment * Update changelogs/fragments/1436-mas-fix-no-app-installed.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit b80854ff503d01a47246402d520274acbb81a8a7) Co-authored-by: Jean-Pierre Matsumoto --- changelogs/fragments/1436-mas-fix-no-app-installed.yml | 3 +++ plugins/modules/packaging/os/mas.py | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/1436-mas-fix-no-app-installed.yml diff --git a/changelogs/fragments/1436-mas-fix-no-app-installed.yml b/changelogs/fragments/1436-mas-fix-no-app-installed.yml new file mode 100644 index 0000000000..4db32a1a91 --- /dev/null +++ b/changelogs/fragments/1436-mas-fix-no-app-installed.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "mas - fix ``invalid literal`` when no app can be found (https://github.com/ansible-collections/community.general/pull/1436)." diff --git a/plugins/modules/packaging/os/mas.py b/plugins/modules/packaging/os/mas.py index 289c10385f..bc3e6dfd66 100644 --- a/plugins/modules/packaging/os/mas.py +++ b/plugins/modules/packaging/os/mas.py @@ -183,6 +183,8 @@ class Mas(object): rc, raw_apps, err = self.run([command]) rows = raw_apps.split("\n") + if rows[0] == "No installed apps found": + rows = [] apps = [] for r in rows: # Format: "123456789 App Name"