Re: [BangPypers] suppressing the exception stack trace
On Tue, Sep 15, 2009 at 9:07 PM, steve st...@lonetwin.net wrote: On 09/15/2009 08:56 PM, Vishal wrote: Hello, I would like to raise an exception of type Exception(), however the regular exception stack trace needs to be supressed. This is needed in a function that takes raw_input() from the user and based on 'Y' or 'N', the function suspends further execution and returns to the python prompt or Hicontinues. An exit() brings it out of the python processwhere as what is needed is coming back to the python prompt. I want a custom message to appear instead of a regular exception stack trace message. How to do this? any pointers...? Python 2.6 (r26:66714, Jun 8 2009, 16:07:29) [GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2 Type help, copyright, credits or license for more information. import traceback try: ... 1 + foo ... except Exception, e: ... traceback.format_stack(limit=1) ... [' File stdin, line 4, in module\n'] help(traceback) HTH, - steve Forgot to mention that we are currently stuck with python2.5.2 As part of a debug/test hook, I would like to suspend further action of a program, after a certain point in the procedure. What I had come up with is a function named testHook() which does this: def testHook(): choice = raw_input(Would you like to continue (Y or N): ) try: if(str(choice).lower() != 'y'): print(You chose not to go ahead. Ok!!\nAborting Now...) raise Exception(User initiated Abort...) except Exception: raise # re-raise it..so we come out of execution loop In this case, a stack trace gets printed out, before the string 'user initiated abort' comes up. I want to remove that stack trace...so it looks more clean to a user. What can be done in this case? or any other way of creating such a hook? -- Thanks and best regards, Vishal Sapre ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] suppressing the exception stack trace
On Wed, Sep 16, 2009 at 11:39 AM, Vishal vsapr...@gmail.com wrote: On Tue, Sep 15, 2009 at 9:07 PM, steve st...@lonetwin.net wrote: On 09/15/2009 08:56 PM, Vishal wrote: Hello, I would like to raise an exception of type Exception(), however the regular exception stack trace needs to be supressed. This is needed in a function that takes raw_input() from the user and based on 'Y' or 'N', the function suspends further execution and returns to the python prompt or Hicontinues. An exit() brings it out of the python processwhere as what is needed is coming back to the python prompt. I want a custom message to appear instead of a regular exception stack trace message. How to do this? any pointers...? Python 2.6 (r26:66714, Jun 8 2009, 16:07:29) [GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2 Type help, copyright, credits or license for more information. import traceback try: ... 1 + foo ... except Exception, e: ... traceback.format_stack(limit=1) ... [' File stdin, line 4, in module\n'] help(traceback) HTH, - steve Forgot to mention that we are currently stuck with python2.5.2 As part of a debug/test hook, I would like to suspend further action of a program, after a certain point in the procedure. What I had come up with is a function named testHook() which does this: def testHook(): choice = raw_input(Would you like to continue (Y or N): ) try: if(str(choice).lower() != 'y'): print(You chose not to go ahead. Ok!!\nAborting Now...) raise Exception(User initiated Abort...) except Exception: raise # re-raise it..so we come out of execution loop is this what you want, def testHook(): choice = raw_input(Would you like to continue (Y or N): ) try: if(str(choice).lower() != 'y'): print(You chose not to go ahead. Ok!!\nAborting Now...) raise Exception(User initiated Abort...) except Exception, e: print e.message In this case, a stack trace gets printed out, before the string 'user initiated abort' comes up. I want to remove that stack trace...so it looks more clean to a user. What can be done in this case? or any other way of creating such a hook? -- Thanks and best regards, Vishal Sapre ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- ashok raavi ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] suppressing the exception stack trace
On 09/16/2009 11:39 AM, Vishal wrote: On Tue, Sep 15, 2009 at 9:07 PM, steve st...@lonetwin.net mailto:st...@lonetwin.net wrote: On 09/15/2009 08:56 PM, Vishal wrote: Hello, I would like to raise an exception of type Exception(), however the regular exception stack trace needs to be supressed. This is needed in a function that takes raw_input() from the user and based on 'Y' or 'N', the function suspends further execution and returns to the python prompt or Hicontinues. An exit() brings it out of the python processwhere as what is needed is coming back to the python prompt. I want a custom message to appear instead of a regular exception stack trace message. How to do this? any pointers...? Python 2.6 (r26:66714, Jun 8 2009, 16:07:29) [GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2 Type help, copyright, credits or license for more information. import traceback try: ... 1 + foo ... except Exception, e: ... traceback.format_stack(limit=1) ... [' File stdin, line 4, in module\n'] help(traceback) HTH, - steve Forgot to mention that we are currently stuck with python2.5.2 As part of a debug/test hook, I would like to suspend further action of a program, after a certain point in the procedure. What I had come up with is a function named testHook() which does this: def testHook(): choice = raw_input(Would you like to continue (Y or N): ) try: if(str(choice).lower() != 'y'): print(You chose not to go ahead. Ok!!\nAborting Now...) raise Exception(User initiated Abort...) except Exception: raise # re-raise it..so we come out of execution loop In this case, a stack trace gets printed out, before the string 'user initiated abort' comes up. I want to remove that stack trace...so it looks more clean to a user. What can be done in this case? Well, I don't understand how and from what context you are calling testHook(). My first instinct is to ask, why you can't simply return instead of 'raise' on an abort ? like so ... def testHook(exc): choice = raw_input(Would you like to continue (Y or N): ) if(str(choice).lower() != 'y'): print(You chose not to go ahead. Ok!!\nAborting Now...) print User initiated Abort... return -1 # ...or any other value that makes sense to your app. else: raise exc # re-raise the passed exception In which case, I am assuming testHook() called like this: try: 1 + foo except Exception, e: return testHook(e) or any other way of creating such a hook? Yes. The way I would do this sort of this is by using decorators: def testHook(func): ... def wrap_exception(*args): ... try: ... func(*args) ... except Exception, e: ... choice = raw_input(Would you like to continue (Y or N): ) ... if (str(choice).lower() != 'y'): ... print(You chose not to go ahead. Ok!!\nAborting Now...) ... print User initiated abort ... ... print on recieving %s % e.message ... return ... else: ... print redirect to debugger in this block ... ... return wrap_exception ... @testHook ... def main(a, b): ... return a + b ... main(1, foo) Would you like to continue (Y or N): n You chose not to go ahead. Ok!! Aborting Now... User initiated abort ... on recieving unsupported operand type(s) for +: 'int' and 'str' Here is a good article for introducing decorators: http://www.ibm.com/developerworks/linux/library/l-cpdecor.html HTH, cheers, - steve -- random non tech spiel: http://lonetwin.blogspot.com/ tech randomness: http://lonehacks.blogspot.com/ what i'm stumbling into: http://lonetwin.stumbleupon.com/ ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Fwd: Join Us for Mozilla Service Week
-- Forwarded message -- From: SourceForge.net Team nore...@sourceforge.net Date: Wed, Sep 16, 2009 at 6:20 AM Subject: Join Us for Mozilla Service Week To: shivraj...@gmail.com Helping others - it comes naturally to people who write open source software. Now the Mozilla Foundation is trying to employ the power of the community in a more direct and hands-on way during Mozilla Service Week (http://mozillaservice.org/learn_more/volunteer/en_US). During this week, Mozilla (and SourceForge) encourage you to volunteer in your community. Tech savvy folks can apply their skills in a variety of ways. Some ideas from the foundation: . Teach senior citizens how to use the Web. . Show a non-profit how to use social networking to grow its base of supporters. . Help install a wireless network at a school. . Create Web how-to materials for a library's computer cluster. . Refurbish hardware for a local computer center. . Update a non-profit organization's web site. Organizations and projects that need assistance can also register to get help. As a company and as individuals, we at SourceForge will be participating in Mozilla Service Week. We encourage you to get out there in your own community and make a difference! -- This message was sent on behalf of SourceForge.net. To unsubscribe from future mailings, login to the SourceForge.net site and modify your subscription preferences at: https://sourceforge.net/account/ Or contact us by postal mail at: Attn: SourceForge.net Legal Services - Unsubscribe SourceForge, Inc. 650 Castro Street, Suite 450 Mountain View, CA 94041 Unsubscribe requests will be processed within 10 days of receipt. -- Regards ___ Shivaraj ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Help Python framework for report creation (bar graph, pie etc)
Hi all, I'm relatively a newbie to python. But i do read most of the posts in this list. Currently I'm doing a study on developing one reporting framework to pull the data from the database and project in appealing way like pie charts, normal charts, bar graphs etc. Would any body please comment on some good frameworks in python (web based GUI), which is already available on which i can add my customizations. This is to replace one of the reporting frameworks provided by Business Objects Web Intelligence. Any comments on where to start, how to start are much appreciated. Please help. Many Thanks Jins Thomas ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [Inpycon] PyCon blog
The dates on the blog have to be corrected. On the blog it is NOV 26,27. On Thu, Sep 17, 2009 at 8:46 AM, Anand Balachandran Pillai abpil...@gmail.com wrote: Done. http://pycon.blogspot.com/2009/09/just-one-week-to-go-for-pycon-india.html Can others also spread the word around ? If you have twitter accounts, please use it to the fullest. Also guys with blogs on planet python etc, please make noise. Those on facebook can post articles on PyCon. Ramdas, have we talked with any newspapers yet ? Thanks --Anand PS: X-posted to BangPypers also. On Tue, Sep 15, 2009 at 11:49 PM, Noufal Ibrahim nou...@gmail.com wrote: Can someone update the PyCon blog with a one week to go kind of post? -- ~noufal http://nibrahim.net.in ___ Inpycon mailing list inpy...@python.org http://mail.python.org/mailman/listinfo/inpycon -- --Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers -- Kumar Gaurav Developer http://www.kumargaurav.info Latest Post -- Gitting things right http://wp.me/pbU2Q-2j ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers