OWASP O2 Platform Blog

PoC of IronPython REPL Scripting Environment

Based on http://www.ironpython.net/2.7 , here is an O2 script that creates a simple Python REPL scripting environment

Gui Created

Source Code

var topPanel = "PoC - IronPython REPL - Simple".popupWindow(800,400);
//var topPanel = panel.clear().add_Panel();

var code = "print 2+2;";

Action<string> executeScript = null;
new API_ConsoleOut().show_ConsoleOut(topPanel.title("Console Out"));
var codeEditor = topPanel.insert_Left("Python Code").add_SourceCodeViewer().set_Text(code,".cs");

var cmdLine = new PythonCommandLine();
var engine = Python.CreateEngine();
var runtime = engine.Runtime;
executeScript = (script) =>	{
									"Execucuring code".info();
									var source = engine.CreateScriptSourceFromString(script, SourceCodeKind.AutoDetect);
									var mod = engine.CreateScope();
								catch(Exception ex)

codeEditor.onTextChange((text)=> code = text);
codeEditor.parent().insert_Above(20).add_Link("Execute Pyhton code" , ()=> executeScript(code)).click();

//using Microsoft.Scripting
//using IronPython
//using IronPython.Hosting

April 23, 2012 - Posted by | Python

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: