scancode: add logger and parse it to get count

pull/12437/head
Martin Kojtal 2020-02-21 15:36:53 +00:00
parent adaa2b6a0a
commit 1b4ad98787
2 changed files with 10 additions and 2 deletions

View File

@ -82,7 +82,8 @@ matrix:
echo "License check OK";
else
echo "License check failed, please review license issues found";
STATUSM="Needs review, ${retval} license issues found";
COUNT=$(cat scancode-evaluate.log | grep File: | wc -l)
STATUSM="Needs review, ${COUNT} license issues found";
set_status "success" "$STATUSM";
fi

View File

@ -32,6 +32,9 @@ import re
userlog = logging.getLogger("scancode-evaluate")
userlog.setLevel(logging.INFO)
logfile = os.path.join(os.getcwd(), 'scancode-evaluate.log')
log_file_handler = logging.FileHandler(logfile, mode='w')
userlog.addHandler(log_file_handler)
MISSING_LICENSE_TEXT = "Missing license header"
MISSING_PERMISIVE_LICENSE_TEXT = "Non-permissive license"
@ -120,7 +123,11 @@ if __name__ == "__main__":
args = parse_args()
if args.file and os.path.isfile(args.file):
sys.exit(license_check(args.directory_name, args.file))
count = license_check(args.directory_name, args.file)
if count == 0:
sys.exit(0)
else:
sys.exit(-1)
else:
userlog.warning("Could not find the scancode json file")
sys.exit(-1)