Skip to content

Commit

Permalink
fix crash in 'fips list targets' when there are no targets to be list…
Browse files Browse the repository at this point in the history
…ed (fixes #295)
  • Loading branch information
floooh committed May 7, 2024
1 parent cb3d00c commit 3d05e74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions mod/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ def get_cfg_target_list(fips_dir, proj_dir, cfg):
if os.path.isfile(targets_path) :
targets = []
with open(targets_path) as f :
# NOTE: targets will be None if the file is empty
targets = yaml.load(f)
if targets is None:
targets = []
return True, targets
else :
return False, []
Expand Down
19 changes: 11 additions & 8 deletions verbs/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@ def list_targets(fips_dir, proj_dir, args) :
# get the target list
success, targets = project.get_target_list(fips_dir, proj_dir, cfg_name)
if success :
# split targets by type
for type in ['lib', 'module', 'sharedlib', 'app'] :
type_targets = [tgt for tgt in targets if targets[tgt] == type]
if len(type_targets) > 0 :
log.colored(log.BLUE, ' {}:'.format(type))
for tgt in type_targets :
log.info(' ' + tgt)
if targets:
# split targets by type
for type in ['lib', 'module', 'sharedlib', 'app'] :
type_targets = [tgt for tgt in targets if targets[tgt] == type]
if len(type_targets) > 0 :
log.colored(log.BLUE, ' {}:'.format(type))
for tgt in type_targets :
log.info(' ' + tgt)
else:
log.info(' none')
else :
log.info(" can't fetch project target list, please run 'fips gen' first!")
log.info(" can't fetch project target list, please run 'fips gen' first!")
else :
log.info(' currently not in a valid project directory')

Expand Down

0 comments on commit 3d05e74

Please sign in to comment.