From f4e7fd73f5aa36c455294d5d9c693103c9cda02e Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sat, 3 Aug 2019 21:11:57 +0300 Subject: [PATCH] csv_metadata_quality/app.py: Handle Ctrl-C Instead of printing an ugly two-page stack trace. --- csv_metadata_quality/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/csv_metadata_quality/app.py b/csv_metadata_quality/app.py index f88360a..f06d1dc 100644 --- a/csv_metadata_quality/app.py +++ b/csv_metadata_quality/app.py @@ -4,6 +4,8 @@ import csv_metadata_quality.check as check import csv_metadata_quality.fix as fix import pandas as pd import re +import signal +import sys def parse_args(argv): @@ -18,9 +20,16 @@ def parse_args(argv): return args +def signal_handler(signal, frame): + sys.exit(1) + + def run(argv): args = parse_args(argv) + # set the signal handler for SIGINT (^C) + signal.signal(signal.SIGINT, signal_handler) + # Read all fields as strings so dates don't get converted from 1998 to 1998.0 df = pd.read_csv(args.input_file, dtype=str)