Closes #6617: behave as good as possible when interrupted with ctrl-c

authorJulien Jehannet <julien.jehannet@logilab.fr>
changesetdd45ac180d7b
branchdefault
phasepublic
hiddenno
parent revision#cde9ef82a0f0 (merge)
child revision#4b876b893c30 clean default options
files modified by this revision
lgp/build.py
# HG changeset patch
# User Julien Jehannet <julien.jehannet@logilab.fr>
# Date 1246986430 -7200
# Tue Jul 07 19:07:10 2009 +0200
# Node ID dd45ac180d7bc88c9b492b4f3c2dbaff7aa37b0e
# Parent cde9ef82a0f07f0e7686ba07956f93e0fe7d4422
Closes #6617: behave as good as possible when interrupted with ctrl-c

diff --git a/lgp/build.py b/lgp/build.py
@@ -57,10 +57,14 @@
1          for arch in builder.architectures:
2              for distrib in builder.distributions:
3                  if builder.compile(distrib=distrib, arch=arch):
4                      if not builder.config.no_treatment and builder.packages:
5                          run_post_treatments(builder, distrib)
6 +    except KeyboardInterrupt:
7 +        logging.critical('lgp aborted by keyboard interrupt')
8 +        builder.clean_tmpdir()
9 +        return 1
10      except LGPException, exc:
11          logging.critical(exc)
12          #if hasattr(builder, "config") and builder.config.verbose:
13          #    logging.debug("printing traceback...")
14          #    raise
@@ -259,11 +263,12 @@
15              self.copy_package_files()
16          return True
17 
18      def clean_tmpdir(self):
19          if not self.config.keep_tmpdir:
20 -            shutil.rmtree(self._tmpdir)
21 +            if hasattr(self, '_tmpdir'):
22 +                shutil.rmtree(self._tmpdir)
23          else:
24              logging.warn("keep temporary directory '%s' for further investigation"
25                           % self._tmpdir)
26 
27      def make_debian_source_package(self, origpath):