From dadcbdea41656b515ccc3e65df85ed8c656a5d43 Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Thu, 4 Jan 2018 10:51:20 -0500 Subject: [PATCH] Good feedback Signed-off-by: Johnny Bieren --- JenkinsfileTrigger | 2 +- utils/package_checker.py | 36 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/JenkinsfileTrigger b/JenkinsfileTrigger index 135e46cd..a5f2a0ad 100644 --- a/JenkinsfileTrigger +++ b/JenkinsfileTrigger @@ -106,7 +106,7 @@ node('master') { # If $? -eq 0, we care about package if [ $CHKR_RC -eq 0 ]; then valid=1 - # If $? -eq 2, upstream package list didnt exist so use legacy method to check + # If $? -eq 2, upstream package list didn't exist so use legacy method to check elif [ $CHKR_RC -eq 2 ]; then for package in $(cat ${PROJECT_REPO}/config/package_list); do if [ "${package}" = "${fed_repo}" ]; then diff --git a/utils/package_checker.py b/utils/package_checker.py index 979b4144..2a9f7258 100755 --- a/utils/package_checker.py +++ b/utils/package_checker.py @@ -1,27 +1,25 @@ -#!/bin/env python +# !/bin/env python import json import sys -import os.path -# Exit 2 if upstream package list doesnt exist -# Exit 1 if file exists, but package isnt in the list +# Exit 2 if upstream package list doesn't exist +# Exit 1 if file exists, but package isn't in the list +# Exit 0 if file exists, and package is in the list jsonpath = 'fedora-atomic/fedora-atomic-host-base.json' -# Make sure json file exists -if not os.path.isfile(jsonpath): +try: + with open(jsonpath, 'r') as f: + atomicjson = json.load(f) + mypackage = sys.argv[1] + + # Check if package exists in the json file + # Check both all packages and x86_64 specific packages + if mypackage in atomicjson["packages"] or mypackage in atomicjson["packages-x86_64"]: + print ("Package of interest!") + sys.exit(0) + # Fail if not + sys.exit(1) +except IOError as e: print("Could not find upstream package json file") sys.exit(2) - -jsonfile = open(jsonpath, 'r').read() -atomicjson = json.loads(jsonfile) -mypackage = sys.argv[1] - -# Check if package exists in the json file -# Check both all packages and x86_64 specific packages -if mypackage in atomicjson["packages"] or mypackage in atomicjson["packages-x86_64"]: - print ("Package of interest!") - sys.exit(0) - -# Fail if not -sys.exit(1)