Skip to content

Commit

Permalink
Better handle ItemNotFoundError when printing platforms config
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Apr 11, 2024
1 parent 394d70d commit 30a1163
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
17 changes: 10 additions & 7 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1994,26 +1994,29 @@ def platform_dump(
"""Print informations about platforms currently defined.
"""
if print_platform_names:
with suppress(ItemNotFoundError):
self.dump_platform_names(self)
self.dump_platform_names(self)
if print_platforms:
with suppress(ItemNotFoundError):
self.dump_platform_details(self)
self.dump_platform_details(self)

@staticmethod
def dump_platform_names(cfg) -> None:
"""Print a list of defined platforms and groups.
"""
# Platforms is always defined with at least localhost
platforms = '\n'.join(cfg.get(['platforms']).keys())
platform_groups = '\n'.join(cfg.get(['platform groups']).keys())
print(f'{PLATFORM_REGEX_TEXT}\n\nPlatforms\n---------', file=stderr)
print(platforms)
print('\n\nPlatform Groups\n--------------', file=stderr)
try:
platform_groups = '\n'.join(cfg.get(['platform groups']).keys())
except ItemNotFoundError:
return
print('\nPlatform Groups\n--------------', file=stderr)
print(platform_groups)

@staticmethod
def dump_platform_details(cfg) -> None:
"""Print platform and platform group configs.
"""
for config in ['platforms', 'platform groups']:
printcfg({config: cfg.get([config], sparse=True)})
with suppress(ItemNotFoundError):
printcfg({config: cfg.get([config], sparse=True)})
1 change: 0 additions & 1 deletion tests/functional/cylc-config/09-platforms.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ They are searched from the bottom up, until the first match is found.
Platforms
---------
Platform Groups
--------------
__HEREDOC__
Expand Down
1 change: 0 additions & 1 deletion tests/functional/cylc-config/10-platform-expansion.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ foo
bar...
baz\d\d
qux\S\S
__HEREDOC__

exit

0 comments on commit 30a1163

Please sign in to comment.