From 3be035f4156bd85d19d1b03e1fd6bae30566294d Mon Sep 17 00:00:00 2001 From: AmartC Date: Wed, 3 Aug 2016 13:58:45 -0400 Subject: [PATCH] Handle cases where container does not have a Status key Minor fixes in scan Closes: #512 Approved by: rhatdan --- Atomic/scan.py | 5 +++-- Atomic/syscontainers.py | 4 ++-- tests/atomic-client.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Atomic/scan.py b/Atomic/scan.py index 250a974..9dd3e38 100644 --- a/Atomic/scan.py +++ b/Atomic/scan.py @@ -170,10 +170,11 @@ class Scan(Atomic): def gen_containers(): slist = [] for con in self.get_containers(): - if con['Status'].upper() != 'DEAD': + # If con does not have 'Status' return empty string + if con.get('Status', '').upper() != 'DEAD': con['input'] = con['Id'] else: - raise ValueError("The container ID {} is Dead and therefor cannot be scanned.".format(con['Id'][:12])) + raise ValueError("The container ID {} is Dead.".format(con['Id'][:12])) slist.append(con) return slist diff --git a/Atomic/syscontainers.py b/Atomic/syscontainers.py index 37b803f..32700df 100644 --- a/Atomic/syscontainers.py +++ b/Atomic/syscontainers.py @@ -193,7 +193,7 @@ class SystemContainers(object): util.write_out("Extracting to %s" % destination) - if 'display' in self.args and self.args.display: + if hasattr(self.args, 'display') and self.args.display: return if extract_only: @@ -348,7 +348,7 @@ class SystemContainers(object): repo.create(OSTree.RepoMode.BARE_USER) else: repo.create(OSTree.RepoMode.BARE) - + repo.open(None) return repo diff --git a/tests/atomic-client.js b/tests/atomic-client.js index 366853e..7be46ee 100644 --- a/tests/atomic-client.js +++ b/tests/atomic-client.js @@ -131,7 +131,7 @@ require([ var text = "Repository Last Scanned\n"; call.done(function(result) { response = JSON.parse(result); - for (var i = 2; i < response.length; i++) { + for (var i = 0; i < response.length; i++) { text += response[i]["repo"] + " "; var checkbox = document.createElement('input'); checkbox.type = "checkbox";