Skip to content

Commit 51bc39a

Browse files
committed
Display error if template processing error detected
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 6665a22 commit 51bc39a

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/attributecode/cmd.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,30 @@ def attrib(location, output, template, mapping, inventory, quiet, show_all,
323323
use_mapping=mapping, template_loc=template,
324324
inventory_location=inventory)
325325

326-
for no_match_error in no_match_errors:
327-
inv_errors.append(no_match_error)
328-
329-
finalized_errors = []
330-
331-
if not validate_about_resource:
332-
finalized_errors = ignore_about_resource_path_error(inv_errors)
326+
# Check for template error
327+
template_error = False
328+
with open(output, 'r') as output_file:
329+
first_line = output_file.readline()
330+
if first_line.startswith('Template processing error'):
331+
template_error = True
332+
333+
if template_error:
334+
click.echo('Template processing error. Please check the template.')
335+
sys.exit(errno.ENOEXEC)
333336
else:
334-
finalized_errors = inv_errors
335-
336-
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
337-
click.echo('Finished.')
338-
sys.exit(0)
337+
for no_match_error in no_match_errors:
338+
inv_errors.append(no_match_error)
339+
340+
finalized_errors = []
341+
342+
if not validate_about_resource:
343+
finalized_errors = ignore_about_resource_path_error(inv_errors)
344+
else:
345+
finalized_errors = inv_errors
346+
347+
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
348+
click.echo('Finished.')
349+
sys.exit(0)
339350

340351

341352
######################################################################

0 commit comments

Comments
 (0)