@@ -198,9 +198,16 @@ def inventory(location, output, mapping, mapping_file, mapping_output, filter, q
198198 'Please correct and re-run.'
199199 print (msg )
200200
201+ error_count = 0
201202 finalized_errors = update_severity_level_about_resource_path_not_exist_error (errors )
202203
203- log_errors (finalized_errors , quiet , verbose , os .path .dirname (output ))
204+ for e in finalized_errors :
205+ # Only count as warning/error if CRITICAL, ERROR and WARNING
206+ if e .severity > 20 :
207+ error_count = error_count + 1
208+
209+ log_errors (finalized_errors , error_count , quiet , verbose , os .path .dirname (output ))
210+ click .echo (' %(error_count)d errors or warnings detected.' % locals ())
204211 sys .exit (0 )
205212
206213
@@ -282,9 +289,8 @@ def gen(location, output, mapping, mapping_file, license_notice_text_location, f
282289 # Only count as warning/error if CRITICAL, ERROR and WARNING
283290 if e .severity > 20 :
284291 error_count = error_count + 1
285- click .echo (
286- 'Generated %(about_count)d .ABOUT files with %(error_count)d errors or warnings' % locals ())
287- log_errors (finalized_errors , quiet , verbose , output )
292+ log_errors (finalized_errors , error_count , quiet , verbose , output )
293+ click .echo ('Generated %(about_count)d .ABOUT files with %(error_count)d errors or warnings' % locals ())
288294 sys .exit (0 )
289295
290296
@@ -365,9 +371,16 @@ def attrib(location, output, template, mapping, mapping_file, inventory, vartext
365371 for no_match_error in no_match_errors :
366372 inv_errors .append (no_match_error )
367373
374+ error_count = 0
368375 finalized_errors = update_severity_level_about_resource_path_not_exist_error (inv_errors )
369376
370- log_errors (finalized_errors , quiet , verbose , os .path .dirname (output ))
377+ for e in finalized_errors :
378+ # Only count as warning/error if CRITICAL, ERROR and WARNING
379+ if e .severity > 20 :
380+ error_count = error_count + 1
381+
382+ log_errors (finalized_errors , error_count , quiet , verbose , os .path .dirname (output ))
383+ click .echo (' %(error_count)d errors or warnings detected.' % locals ())
371384 click .echo ('Finished.' )
372385 sys .exit (0 )
373386
@@ -429,7 +442,7 @@ def check(location, verbose):
429442 sys .exit (0 )
430443
431444
432- def log_errors (errors , quiet , verbose , base_dir = False ):
445+ def log_errors (errors , err_count , quiet , verbose , base_dir = False ):
433446 """
434447 Iterate of sequence of Error objects and print and log errors with
435448 a severity superior or equal to level.
@@ -450,7 +463,9 @@ def log_errors(errors, quiet, verbose, base_dir=False):
450463 log_path = join (bdir , LOG_FILENAME )
451464 if exists (log_path ):
452465 os .remove (log_path )
453-
466+ f = open (log_path , "a" )
467+ error_msg = str (err_count ) + u" errors or warnings detected."
468+ f .write (error_msg )
454469 file_handler = logging .FileHandler (log_path )
455470 file_logger .addHandler (file_handler )
456471
0 commit comments