summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-02-13 13:55:48 +0100
committerFlorian Pritz <bluewind@xinu.at>2016-02-13 13:55:48 +0100
commit7bc7d05ad0aff3f3bb2453be691010f7ea46da3a (patch)
treede62ecfc6676aea432612367412fab20acbccb73
parentbcf3826fa633c9a0864752582bce01b711ec772e (diff)
Handle ctrl-c
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xfb.py6
1 files changed, 6 insertions, 0 deletions
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: