Skip to content

Commit 82947ae

Browse files
authored
Merge pull request #402 from salopensource/fix_operatingsystem
Safely handle unexpected OS values.
2 parents a252801 + 64db0c3 commit 82947ae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

server/plugins/operatingsystem/operatingsystem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from server.utils import get_setting
1010

1111

12-
# This table is also used for sequnecing output, so use OrderedDict.
12+
# This table is also used for sequencing output, so use OrderedDict.
1313
OS_TABLE = OrderedDict(Darwin='macOS', Windows='Windows', Linux='Linux', ChromeOS='Chrome OS')
1414

1515

@@ -32,8 +32,9 @@ def get_context(self, machines, **kwargs):
3232

3333
grouped = defaultdict(list)
3434
for version in os_info:
35-
os_type = OS_TABLE[version['os_family']]
36-
grouped[os_type].append(version)
35+
os_type = OS_TABLE.get(version['os_family'])
36+
if os_type:
37+
grouped[os_type].append(version)
3738

3839
normalize_chromeos_versions = get_setting('normalize_chromeos_versions')
3940
if normalize_chromeos_versions:
@@ -63,7 +64,7 @@ def get_context(self, machines, **kwargs):
6364
chrome_items.append(item_to_add)
6465

6566
grouped['Chrome OS'] = chrome_items
66-
# you and your lanbda's @sheacraig...
67+
# you and your lambdas @sheacraig...
6768
os_key = lambda x: LooseVersion(x["operating_system"]) # noqa: E731
6869
output = [
6970
(key, sorted(grouped[key], key=os_key, reverse=True)) for key in OS_TABLE.values()]

0 commit comments

Comments
 (0)