[Piuparts-devel] Bug#523958: piuparts: Piuparts could allow the user to stop it with control-C from the shell

Carl Chenet chaica at ohmytux.com
Mon Apr 13 21:41:20 UTC 2009


Package: piuparts
Version: 0.35
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Piuparts could allow the user to stop it with control-C keys from the
shell. At this time, if interrupted, piuparts throws KeyboardInterrupt
which crashes piuparts.
Here is a simple patch to catch this exception and exits properly.

Regards,
Carl Chenet

- -- System Information:
Debian Release: lenny/sid
  APT prefers hardy-updates
  APT policy: (500, 'hardy-updates'), (500, 'hardy-security'), (500, 'hardy')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-23-generic (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJ47GA8lge+lYYJUgRAlDqAJ9maSTz12rth6KUGZ4JTLRY3X4kGgCgiS1t
SPHWeidQ552ppv/Uq5pny9A=
=FF73
-----END PGP SIGNATURE-----
-------------- next part --------------
--- piuparts.py.ori	2009-04-13 23:32:24.000000000 +0200
+++ piuparts.py	2009-04-13 23:33:53.000000000 +0200
@@ -1933,8 +1933,13 @@
 
 
 if __name__ == "__main__":
-    if sys.argv[1:] == ["unittest"]:
-        del sys.argv[1]
-        unittest.main()
-    else:
-        main()
+    try:
+        if sys.argv[1:] == ["unittest"]:
+            del sys.argv[1]
+            unittest.main()
+        else:
+            main()
+    except KeyboardInterrupt:
+        print ''
+        print 'Piuparts interrupted by the user, exiting...'
+        sys.exit(1)


More information about the Piuparts-devel mailing list