mailRe: [sr #3117] Functionality to inspect interactively after running script - The equivalence to python -i


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

Header


Content

Posted by Edward d'Auvergne on February 14, 2014 - 10:47:
Hi,

This is rather simple:

- First execute the run_script() function to have the script execute
prior to reaching the prompt.

- Then execute the prompt() function.

Without the prompt() function call, the Python execution will just run
to the end of the relax.py file and terminate.  The prompt() function
call prevents this by jumping into the interpreter mode.  The
interpreter mode is then exited with the special objects 'q', 'quit',
'exit', and 'bye' and [Ctrl-D].  These commands cause the prompt()
function to be exited, allowing the Python execution to run to the end
of the relax.py file and quit.  As an aside, if you look you'll see
that this implementation (the _Exit class/object) is not ideal as it
uses sys.exit(), which really should never be used - this is simply
ancient code which should one day be updated.

So what you need is that when a script is supplied together with the
--prompt argument, then you just run both of these, one after the
other.  That's what the pseudo-code I suggested does
(http://thread.gmane.org/gmane.science.nmr.relax.devel/5000/focus=5008).
 I quickly tested running one function after the other and it works.
You don't need to worry about returning the status from the
run_script() function, as that's not used in relax yet.  But
eventually to allow for proper terminal behaviour, relax will one day
return a status value to the terminal.  The user combinations for
running relax would be:

- No arguments:  Run prompt(),
- Only the -p, --prompt arguments:  Run prompt(),
- Only a script file:  Run run_script(),
- Both the -p, --prompt arguments and a script file:  Run run_script()
then prompt().

I hope this is now clearer.

Regards,

Edward


On 14 February 2014 10:14, Troels Emtekær Linnet <tlinnet@xxxxxxxxxxxxx> 
wrote:
Hi Edward.

Thank you for the suggestions, which I will implement.

I wonder about the pseudo code.

My problem is that I don't know how to parse the script to the prompt?
Does the prompt needs to be modified to run the given script?

Best
Troels


2014-02-13 18:03 GMT+01:00 Edward d'Auvergne <edward@xxxxxxxxxxxxx>:

Hi,

The idea in the patch looks ok.  It's worth discussing on the list the
idea though, rather than relying on reading the patch itself.  The
--pedantic flag activates this feature that Chris MacRaild added to
relax back in 2006.  So I gather that the suggestion is to change the
argument:

-p, --pedantic, escalate all warnings to errors

to:

-e, --escalate, escalate all warnings to errors

I guess this is reasonable.  I suggest committing just that change as
one commit yourself.  The current patch also includes the argument:

-p, --prompt, 'Execute the given script and continue into the prompt
mode to allow for interactive inspection'

This should be in a separate commit.  Also, the first letter of the
help text should be in lowercase to match the rest of the help system.
 There is also a problem with the logic of the if-else statement in
the run() method.  I would suggest the pseudo-code:

if script:
    script_status = run_script()
if not script or (script and status.prompt):
    prompt()

So essentially two commits, the first renaming --pedantic, the second
adding the --prompt argument and logic.  What do you think?

Regards,

Edward




On 13 February 2014 17:48, Troels E. Linnet
<NO-REPLY.INVALID-ADDRESS@xxxxxxx> wrote:
Follow-up Comment #1, sr #3117 (project relax):

This follows the discussion at:
http://thread.gmane.org/gmane.science.nmr.relax.devel/5000

The next step would be to figure out to run the code and stay in the
interpreter.
Is it necessary to write a new function?

Initial pathc applied.

(file #20034)
    _______________________________________________________

Additional Item Attachment:

File name: first.patch                    Size:5 KB


    _______________________________________________________

Reply to this item at:

  <http://gna.org/support/?3117>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


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

This is the relax-devel mailing list
relax-devel@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-devel





Related Messages


Powered by MHonArc, Updated Fri Feb 14 11:00:11 2014