From 7bc7d05ad0aff3f3bb2453be691010f7ea46da3a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 13 Feb 2016 13:55:48 +0100 Subject: Handle ctrl-c Signed-off-by: Florian Pritz --- fb.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fb.py b/fb.py index 3f83cfe..cbde9d1 100755 --- a/fb.py +++ b/fb.py @@ -14,6 +14,7 @@ import os import pycurl import re import shutil +import signal import subprocess import sys import tarfile @@ -397,6 +398,7 @@ class FBClient: self.config["useragent"] = "fb-client/%s" % self.version def run(self): + signal.signal(signal.SIGINT, self.handle_ctrl_c) defaultConfigFile = os.path.join(xdg.BaseDirectory.xdg_config_home, 'fb-client/config') parser = argparse.ArgumentParser( @@ -462,6 +464,10 @@ class FBClient: with make_temp_directory() as self.tempdir: functions[self.args.mode]() + def handle_ctrl_c(self, signal, frame): + print("\nReceived signal, aborting!") + sys.exit(1) + def makedirs(self, path): dirname = os.path.dirname(path) try: -- cgit v1.2.3-24-g4f1b