OWASP O2 Platform Blog

O2 Script to download O2 Reference DLLs from SVN

An O2 user today had a problem that sometimes happens inside networks with’ proxy based internet access’.

The issue is that if an O2 script needs a particular dll to run and it has not been downloaded before, O2 will fail to find it because the ping that it makes to check for online connectity will fail (this is a bug that needs to be fixed in the main O2 ClickOnce version).

So to address his short term need (and to show how easy it is to add new modules anf capabilities to O2), I ‘live coded’ the scrip below using ietherpad.com 🙂

Here is the link of the Etherpad timeslider (you can go back in time and see how the script evolved): http://ietherpad.com/ep/pad/view/uuSwFWulSf/latest

Here is a screenshot of what it looks like:

Here is the source code of this new O2 Util (which is already added to the main O2 Scripts folder (look for the script called ‘Util – Download O2 Reference File.h2’))

//var topPanel = panel.clear().add_Panel();
var topPanel = "Get O2 Reference dll (double click on file to download it)".popupWindow(400,500); 
topPanel.insert_LogViewer();</pre>
&nbsp;

var ie = topPanel.add_IE().silent(true);

var treeView = topPanel.insert_Left().add_TreeView().sort();

Action<string> addUrlMappingsToTreeView =
    (urlWithLinks)=>{
                        ie.open(urlWithLinks);
                        var links = from link in ie.links()
                            where link.text() != ".."
                            select new { filename = link.text() , url = link.url() };
                        foreach(var link in links)
                            treeView.add_Node(link.filename, link.url);
                    };
addUrlMappingsToTreeView("<a href="http://o2platform.googlecode.com/svn/trunk/O2%20-%20All%20Active%20Projects/_3rdPartyDlls/FilesWithNoCode/">http://o2platform.googlecode.com/svn/trunk/O2%20-%20All%20Active%20Projects/_3rdPartyDlls/FilesWithNoCode/</a>");
addUrlMappingsToTreeView("<a href="http://o2platform.googlecode.com/svn/trunk/O2%20-%20All%20Active%20Projects/_3rdPartyDlls/">http://o2platform.googlecode.com/svn/trunk/O2%20-%20All%20Active%20Projects/_3rdPartyDlls/</a>");

topPanel.splitContainer().panel2Collapsed(true);

treeView.onDoubleClick<string>(
    (url)=> {
                treeView.pink();
                "you selected the url: {0}".info(url);
                var localTempFile = url.uri().download();
                var copiedFile = Files.Copy(localTempFile,PublicDI.config.CurrentExecutableDirectory);
                "file was copied to: {0}".info(copiedFile);
                treeView.white();
            });
return "ok";

//O2File:WatiN_IE_ExtensionMethods.cs
//using O2.XRules.Database.Utils.O2
//O2Ref:WatiN.Core.1x.dll

July 13, 2011 - Posted by | O2 Internals, WatiN

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: