From patchwork Fri Aug 16 18:40:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pagano X-Patchwork-Id: 2845750 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9A64BF546 for ; Fri, 16 Aug 2013 18:40:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FA8A202B8 for ; Fri, 16 Aug 2013 18:40:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FE4B202A1 for ; Fri, 16 Aug 2013 18:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754911Ab3HPSk4 (ORCPT ); Fri, 16 Aug 2013 14:40:56 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:33261 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753543Ab3HPSk4 (ORCPT ); Fri, 16 Aug 2013 14:40:56 -0400 Received: by smtp.gentoo.org (Postfix, from userid 2195) id 2971B33EBC2; Fri, 16 Aug 2013 18:40:56 +0000 (UTC) Date: Fri, 16 Aug 2013 14:40:56 -0400 From: Mike Pagano To: linux-kbuild@vger.kernel.org Subject: [PATCH RESEND] diffconfig: Gracefully exit if the default config files are not present Message-ID: <20130816184056.GA30565@woodpecker.gentoo.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Handle gracefully the instance where config files are not present. Compatible with python versions 2.5, 2.6 and 2.7. The try/except is forward compatible with python version 3 once the entire script is ported. Signed-off-by: Mike Pagano --- scripts/diffconfig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/diffconfig b/scripts/diffconfig index b91f3e3..0ee6583 100755 --- a/scripts/diffconfig +++ b/scripts/diffconfig @@ -94,8 +94,13 @@ def main(): configa_filename = sys.argv[1] configb_filename = sys.argv[2] - a = readconfig(file(configa_filename)) - b = readconfig(file(configb_filename)) + try: + a = readconfig(file(configa_filename)) + b = readconfig(file(configb_filename)) + except (IOError): + e = sys.exc_info()[1] + print("I/O error[%s]: %s\n" % (e.args[0],e.args[1])) + usage() # print items in a but not b (accumulate, sort and print) old = []