mailRe: r2533 - in /1.2: errors.py prompt/interpreter.py relax


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Chris MacRaild on August 10, 2006 - 13:28:
On Thu, 2006-08-10 at 20:51 +1000, Edward d'Auvergne wrote:
Thanks.  I have a suggestion to simplify the state saving code and
that is that the save_state function is called within the BaseError
class.  This means that save_state is only called from one place in
the code by placing it within the __str__ function (which is called to
get the error message).  For example something like:

    class BaseError(Exception):
        def __str__(self):
            # Save the program state.
            if Debug:
                self.save_state()

            # The RelaxError message.
            return ("RelaxError: " + self.text + "\n")

There are a couple of reasons I didn't do it this way. One is that
__str__ is a 'special' function as far as Python is concerned, and it
exists for a specific purpose (same with all the double-underscore
functions). Although it's difficult to imagine how it might cause
problems in this case, I'm inclined to avoid messing with it on
principle. The second reason is that the way I've implimented it now
gives us greater control - perhaps there will be a set of Errors that we
dont want to save state. Or, as I've done with RelaxFault, we might want
to save state in all cases, not just if Debug (the logic here being that
RelaxFault always reflects a bug, and we want all the info we can about
it especially if it is difficult to reproduce). I appreciate that the if
Debug: self.save_state() gets repeditive, but I think its a price worth
paying in this case.


        def save_state(self):
            """Function for saving the program state"""

            now = time.localtime()
            file_name = "relax_state_%i%i%i_%i%i%i" % (now[3], now[4], 
now[5],
                                                  now[2], now[1], now[0])
            self._relax.interpreter._State.save(file_name)

I would place the import statement at the top of the 'error.py' file
with the other import statements (and the save_state function probably
doesn't need the underscore out the front of it's name).  

fine.

Do you think
it's worth having a separate command line flag for saving the state?
I don't think so but it would result in finer control.


Not sure this is worth it, but fairly easy to impliment if anyone wants
to.

Edward


On 8/10/06, c.a.macraild@xxxxxxxxxxx <c.a.macraild@xxxxxxxxxxx> wrote:
Author: macraild
Date: Thu Aug 10 12:26:14 2006
New Revision: 2533

URL: http://svn.gna.org/viewcvs/relax?rev=2533&view=rev
Log:
Alterations to the debug mode.

These changes reflect the discussion on relax-devel at gna dot org:
https://mail.gna.org/public/relax-devel/2006-08/msg00049.html

Two functions are implimented when in debuging mode:
1) KeyboardInterupt during script execution will print the normal
python traceback
2) The all of the relax exception classes will save the program
state

Modified:
    1.2/errors.py
    1.2/prompt/interpreter.py
    1.2/relax

[This mail would be too long, it was shortened to contain the URLs only.]

Modified: 1.2/errors.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/errors.py?rev=2533&r1=2532&r2=2533&view=diff

Modified: 1.2/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/prompt/interpreter.py?rev=2533&r1=2532&r2=2533&view=diff

Modified: 1.2/relax
URL: 
http://svn.gna.org/viewcvs/relax/1.2/relax?rev=2533&r1=2532&r2=2533&view=diff


_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits






Related Messages


Powered by MHonArc, Updated Fri Aug 11 18:00:36 2006