From c6806662509575fd33de9f7d75f0d8df5f874473 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Wed, 20 Dec 2017 19:14:04 +0100 Subject: Added try-except to database script parser to skip invalid files --- scripts/database/database.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'scripts/database/database.py') diff --git a/scripts/database/database.py b/scripts/database/database.py index 28f6ebf8..57fbf74a 100755 --- a/scripts/database/database.py +++ b/scripts/database/database.py @@ -106,16 +106,20 @@ def main(argv): # Loops over all JSON files in the supplied folder for file_json in glob.glob(json_files): - - # Loads the newly imported data sys.stdout.write("[database] Processing '" + file_json + "' ") # No newline printed - imported_data = io.load_tuning_results(file_json) - # Adds the new data to the database - old_size = db.length(database) - database = db.add_section(database, imported_data) - new_size = db.length(database) - print("with " + str(new_size - old_size) + " new items") # Newline printed here + try: + # Loads the newly imported data + imported_data = io.load_tuning_results(file_json) + + # Adds the new data to the database + old_size = db.length(database) + database = db.add_section(database, imported_data) + new_size = db.length(database) + print("with " + str(new_size - old_size) + " new items") # Newline printed here + + except ValueError: + print("--- WARNING: invalid file, skipping") # Checks for tuning results with mis-matched entries remove_mismatched_arguments(database) -- cgit v1.2.3