Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'debug': 0.03; 'wed,': 0.03; 'warnings': 0.05; 'python': 0.08; 'linux.': 0.09; 'received:64.4': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'btw:': 0.16; 'looked': 0.16; 'header:In-Reply-To:1': 0.21; 'modification': 0.23; 'module,': 0.23; 'unsure': 0.23; 'code': 0.24; 'there.': 0.25; 'tried': 0.27; "i'm": 0.27; 'thanks': 0.28; 'module': 0.30; 'catching': 0.30; 'url:library': 0.31; 'does': 0.33; 'to:addr :python-list': 0.33; 'header:User-Agent:1': 0.35; 'using': 0.35; 'charset:us-ascii': 0.36; 'log': 0.36; '(to': 0.37; 'url:docs': 0.37; 'url:python': 0.38; 'url:org': 0.38; 'but': 0.38; 'docs': 0.38; 'subject:: ': 0.38; 'comments': 0.39; 'skip:s 20': 0.39; 'should': 0.39; 'johnson': 0.39; 'printed': 0.39; 'to:addr:python.org': 0.39; 'getting': 0.40; 'forward': 0.62; 'subject': 0.62; 'world.': 0.65; 'day': 0.67; 'tomorrow.': 0.84; 'warning.': 0.84 Date: Wed, 15 Jun 2011 18:38:29 -0800 From: Tim Johnson To: python-list@python.org Subject: Re: Trapping MySQLdb warnings References: <20110616015837.GA1885@johnsons-web.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: AkWebsoft User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308191913 news.xs4all.nl 49180 [::ffff:82.94.164.166]:52075 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7723 * geremy condra [110615 18:03]: > On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson wrote: > > Using Python 2.6.5 on linux. > > > > When using MySQLdb I am getting warnings printed to stdout, but I would > > like to trap, display and log those warnings. <.....> > Have you tried http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings Hi Geremy: I just looked at the docs there. This is a new module (to me), and I am unsure of the implementation or whether this is what I should use. I tried the following : try : self.__rdb.execute(S) except warnings.catch_warnings: std.mrk('',0,"mysql.py:196") ## DEBUG call ## and it does not look like my code modification ## is catching the warning. Thanks for introducing me to this new module, but I'm not sure if it is what I should be using. BTW: End of day in this part of the world. I look forward to any other comments on this subject tomorrow. chees -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com