Bug#621507: Fail gently if config section is missing

2011-04-07 Thread Jan Hauke Rahm
*Gnarf*
Sorry, I messed up tabs and white spaces in the patch. Attached is a
corrected version that should be usable directly.

Hauke

-- 
 .''`.   Jan Hauke Rahmwww.jhr-online.de
: :'  :  Debian Developer www.debian.org
`. `'`   Member of the Linux Foundationwww.linux.com
  `- Fellow of the Free Software Foundation Europe  www.fsfe.org
From 588ebedc0f601c900e53695394b3a9d5d59d5818 Mon Sep 17 00:00:00 2001
From: Jan Hauke Rahm 
Date: Thu, 7 Apr 2011 15:15:57 +0200
Subject: [PATCH] Fail gently if config section is missing

If config has chosen a default_host that doesn't exist, i.e. by
misspelling it, fail more gently than with an uncaught exception.
---
 dput |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dput b/dput
index 1916eca..c184911 100755
--- a/dput
+++ b/dput
@@ -304,8 +304,12 @@ def verify_files(path, filename, host, check_only, check_version,
   sys.exit(1)
 
 # Run the check to verify that the package has been tested.
-if config.getboolean(host, 'check_version') == 1 or check_version:
-version_check (path, changes, debug)
+try:
+if config.getboolean(host, 'check_version') == 1 or check_version:
+version_check (path, changes, debug)
+except ConfigParser.NoSectionError, e:
+print >> sys.stderr, "Error in config file:\n%s" % str(e)
+sys.exit(1)
 
 # Verify the signature of the maintainer
 verify_signature(host, change_file, dsc_file, check_only, debug,\
-- 
1.7.4.1



signature.asc
Description: Digital signature


Bug#621507: Fail gently if config section is missing

2011-04-07 Thread Jan Hauke Rahm
Package: dput
Version: 0.9.6.2
Severity: normal
Tags: patch

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

dput runs into an uncaught exception if there is no section in the
config file for a given default_host. Attached patch should fix that.

Hauke

- -- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (700, 'unstable'), (300, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dput depends on:
ii  gnupg 1.4.11-3   GNU privacy guard - a free PGP rep
ii  python2.6.6-12   interactive high-level object-orie

dput recommends no packages.

Versions of packages dput suggests:
ii  lintian   2.5.0~rc2  Debian package checker
pn  mini-dinstall  (no description available)
ii  openssh-client1:5.8p1-4  secure shell (SSH) client, for sec
ii  rsync 3.0.7-2fast remote file copy program (lik

- -- Configuration Files:
/etc/dput.cf changed [not included]

- -- no debconf information

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

iQIcBAEBCgAGBQJNnbs1AAoJEOCD7BUSMcRlrEoP/iulNm3WpFYYUlF1tGS4ru9L
n0CdelP0igbEZK88lG5X2oHgx/19jU4FpEctvXbzNTAhw56XiXREzb13mTwq10fm
B17pb4l/BO6o1sB2AXDuDGEOIVoxN4aIZXkBNReuaCvRVswwCvmZ02m/acpTvDhB
Gk/WQVA+nKNuiVNaQ3EZrBpa8AxC3xvLJQjag/5JIQnY9DEXQKiwGjlXPz1smqaQ
Kg+CysmAMdykfvUg45QOm8jhXtntTX85MwZ/dhBw8VxzlEtBudes/oXGyrNmxIk3
zJT/5pu3OONyEV5MBJJp7PrJcdA3r3vheQ+VSLxIw3jtXVmg8KP4wO5QKthO0Bn9
Tj8UZDcx87Qdzjd3YcproEePL1jjWDgBCUyAAaZvV1ZybG1kzUyQHnjY6KxWIH8t
4ULRAclJGY8fioCpbCuJFP05S9d0BqGzRVVP8xfArkKwp28ZksXxlwPwQWQt/BRk
0JjvDkbNNE+qmomRArpJQjqvtQsDGAkufZxqAFLHcdXqdOtV7xLABxdDJQIfWOdS
dfxri+OgKiUrrzEjMTHagEU9Y7GcxY1RLw0ypfbx70U2eG5mQ9CWvRLSyKzqXnbR
nf7x9nGMMJ27u1byEQW0ip2HlMj2zxcHCvQT8NhmcChVxYMaWPtUoBc58Ne2zkiE
CC4D5gW4RJwYn0mCN5aV
=Ai2R
-END PGP SIGNATURE-
>From 51f9cc1cc1ffdf8fc6e60dee2d9ed7e0af9b8093 Mon Sep 17 00:00:00 2001
From: Jan Hauke Rahm 
Date: Thu, 7 Apr 2011 15:15:57 +0200
Subject: [PATCH] Fail gently if config section is missing

If config has chosen a default_host that doesn't exist, i.e. by
misspelling it, fail more gently than with an uncaught exception.
---
 dput |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dput b/dput
index 1916eca..7687632 100755
--- a/dput
+++ b/dput
@@ -304,8 +304,12 @@ def verify_files(path, filename, host, check_only, 
check_version,
   sys.exit(1)
 
 # Run the check to verify that the package has been tested.
-if config.getboolean(host, 'check_version') == 1 or check_version:
-version_check (path, changes, debug)
+try:
+   if config.getboolean(host, 'check_version') == 1 or check_version:
+   version_check (path, changes, debug)
+except ConfigParser.NoSectionError, e:
+   print >> sys.stderr, "Error in config file:\n%s" % str(e)
+sys.exit(1)
 
 # Verify the signature of the maintainer
 verify_signature(host, change_file, dsc_file, check_only, debug,\
-- 
1.7.4.1