Posts

Showing posts with the label snippet

A Good Mix 32: Alpha Encoding Files, Embedding IronPython in Russian, IronSharePoint, IronRuby, World's Worst Paint Program

More IronPython and DLR related projects, articles and news from around the web. Alpha-encoding file versions  Steve Gilham shows how to generated encoded version strings for installers using IronPython: When building installers the UpgradeVersion must have a unique property value that is an installer public property (upper-case alpha). So, what better way of adding uniqueness than making it have the form "product name + product version" with the version suitably encoded... So, a script for turning a file version (4 x 16bit ints) encoded as a System.Version into a short alpha string, assuming that Major and Minor will be small, and that common approaches are to step Build, to use a stepped Build plus date-stamped Revision, or a timestamp Build and Revision. C# + IronPython: вызов методов An article on IronPython, and in particular using IronPython from C#, in Russian. IronSharePoint Source Code Available   A while ago Christian Glessner announced the start of the I...

Face Detection with IronPython

Face detection in images is very cool (and perhaps a little bit scary), and with the help of Emgu CV it can be done from IronPython. Emgu CV is a cross platform .Net wrapper to the Intel OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono and run on Linux / Mac OS X. This blog entry from Clark Updike shows how. Face Detection "Hello World" in IronPython using Emgu CV and OpenCV  A couple notes compared to the Emgu wiki version--I was able to get everything working without having to disturb the IronPython install (I didn't copy any files into the IronPython start directory). I simply linked used sys.path to add the locations where the dll's live. Also, I did explicit import for everything. It's a bit more work to figure out what needs to be imported, but it avoids namespace pollution issues. Also, the img.Draw line needed a few tweaks....

A Good Mix 21: 3D Modelling, WMI, and IronPython Startup

Another collection of blog entries and articles related to IronPython and the Dynamic Language Runtime. Scripting (IronPython) exposing Naro document API IronPython was integrated for some time to NaroCAD . But in fact it has two problems: It was not able to access NaroCAD shapes or anything from NaroCAD so it was not powerful enough to do something useful, excluding you did want to make a processing task using python IronPython implementation (and python in itself) do not work with Generics. So even you had access to Naro's document model, the Naro's extensible model was not accessible to IronPython script programmers. This is why it was used lazy loading of IronPython as it does useless slowdown on startup of NaroCAD. Right now both are addressed, exposing to you a document reference that you can create from it using a PyNodeUtil class a shape node. This is fairly important achievement as it can make easier without recompile NaroCAD to migrate your shapes if you can expose t...

A Good Mix 18: Amazon S3, Professional IronPython, Silverlight Spy, Loading Data from CSV Files and Sharepoint

A collection of projects, articles and blog entries on IronPython from the last few weeks. Lit S3 Commander 1.0 Lits3 is " a library written in C# that provides comprehensive and straightforward access to Amazon S3 for .NET developers ". The commander is a command line interface to LitS3, written in IronPython by Atif Aziz , and it just had a 1.0 release. Professional IronPython by John Paul Meuller This is a book by John Wiley due out on 20th April 2010. I can't find any other references to it on the net other than this Amazon.co.uk page, but it's been up for a while. Paperback: 504 pages Publisher: John Wiley & Sons (20 April 2010) ISBN-10: 0470548592 ISBN-13: 978-0470548592 I've not crossed paths with John Paul Meuller in the IronPython community, but it seems he's written quite a few technical books . Silverlight Spy with DLR Integration Silverlight Spy is a tool for doing runtime inspection of Silverlight applications: "Use the built...

A Good Mix 14: Open Source, XML, XNA and more

Another selection of blog entries and articles on IronPython and the DLR. Microsoft and Open Source A Korean translation of a presentation about the future of Open Source at Microsoft by Harry Pierson, the IronPython program manager. IronPython, and its two companion projects IronRuby and the Dynamic Language Runtime, are at the forefront of pushing the adoption and acceptance of open source in the corporate behemoth we all know and love. bridge version 0.3.8 released bridge is an open source Python library for handling XML that works with CPython and IronPython. Its homepage describes it as: " a Python XML library trying to provide a high level and clean interface for manipulating XML documents. " bridge allows you to write code dealing with XML that will run unmodified on both CPython and IronPython. Most common Python packages for dealing with XML rely on C extensions not available on IronPython (except through Ironclad ) although the FePy project contains an implementat...

A Good Mix 13: ActiveRecord, Guids and Strings (etc)

Another selection of IronPython snippets and articles from around the web. IronPython ActiveRecord in Action The Active Record pattern is a pattern for working with databases named by Martin Fowler and popularised by Rails: " The interface to such an object would include functions such as Insert, Update, and Delete, plus properties that correspond more-or-less directly to the columns in the underlying database table. " Creating classes where the shape of the class corresponds to the shape of a database table is particularly easy with dynamic languages. This Chinese blog entry demonstrates the pattern with IronPython hosted in C#. Generating Strong Repeatable Guids Blog entries by Steve Gilham have made frequent appearances here on IronPython-URLs, although I believe it has been a while since the last one. This entry isn't specifically about IronPython - but the example code is in IronPython. He shows a couple of example functions he uses in his build scripts to solve th...

A Good Mix 12: Upcoming Presentations, XML Namespaces, ArcGIS and the Hungarian Phrasebook

Yet another selection of blog entries and articles relating to IronPython from the last few weeks. Upcoming Presentations - Summer Edition The Coding Geekette (Sarah Dutkiewicz) is a regular at .NET and Python conferences speaking, amongst other things, about IronPython. In this blog entry she lists her forthcoming talks: Cleveland .NET group (Python 101 for .NET developer) PyOhio 2009 (Pumping Iron into Python + IronPython Show & Tell) devLink (going cross-platform with C#) There is also quite a bit of IronPython content at the forthcoming EuroPython 2009 in Birmingam (28th June to 4th July): an IronPython tutorial , ArcGIS and IronPython talk , Introduction to IronPython talk , Ironclad talk and a general Python VM panel discussion . IronPython and XHTML A Japanese blog demonstrating how to load and save XML from IronPython - using the .NET APIs and working with namespaces. In this case he is iterating through a directory of XHTML files and adding valid namespace declarations...

A Good Mix 5: Cookbook entries, ADODBAPI and IronPython with Asterisk

Only the finest selection of articles and blog posts on IronPython and related topics. Connection String Editor A recipe in the IronPython Cookbook showing how you can prompt the user for a connection string (for connecting to databases) using a built-in connection string editor dialog box from the Microsoft .NET Framework. IPY as AMI client thru AMIConnector A blog entry demonstrating the power of the interactive interpreter for exploring new libraries. This entry investigates AmiConnector , which is a .NET library for working with the Asterisk Manager. Kudos to Vernon Cole Dave Fugate, IronPython testing and infrastructure guy, pays homage to Vernon Cole for pywin32's adodbapi which runs under both CPython and IronPython. The tests have now been added to the IronPython test infrastructure so that the IronPython team will get early warning if they break it. Dave comments " Now I just need to setup Northwind databases on 40+ test machines... ". Self-executable scripts A...

ZLIB and .NET

Steve Gilham has been involved in some odd experiments with a codebase involving IronPython, Jython and Scala (with Erlang occasionally in the mix as well). His latest post shows the IronPython code needed for ZLIB compression on .NET, even though it isn't provided directly by the framework: ZLIB and .Net A recurring problem in several of the projects I have in the pipeline is the matter of handling ZLIB. Java, though java.util.zip offers ZLIB compression with a 32k byte window (but no means of tuning the window) through the DeflaterOutputStream. The .Net framework doesn't offer direct ZLIB at all, but provides naked Deflate via System.IO.Compression.DeflateStream . That gives us enough to be able to reflate the output of a ZLIB deflation, since a ZLIB is a 2 byte header, a deflate section and finally a 4 byte checksum. That works fine; but the converse, taking a .Net deflate and adding the appropriate top and tail took a bit of getting to work. First pitfall -- the Inflater...

A Sweet Selection

A collection of projects, articles and links related to IronPython. Twitter IRC Gateway A C# project which, as far as I can tell, (the project page is in Japanese) sets up a local IRC server that acts as a gatway to twitter. It is scriptable in both IronPython and IronRuby and includes some example scripts to get you started. s3cmd.py - LitS3 A Small and fast library for Amazon S3 " LitS3 is a library written in C# that provides comprehensive and straightforward access to Amazon S3 for .NET developers ". s3cmd.py, by Atif Aziz is a command line interface to LitS3 written in IronPython: Usage: %(this)s COMMAND ARGS where: COMMAND is one of: ls (list), put, get, puts, gets, pops, rm (del), authurl, mkbkt, rmbkt, ids ARGS COMMAND-specific arguments All commands require two arguments: --aws-key-id VALUE Your AWS access key ID --aws-secret-key VALUE Your AWS secret access key IPY with Google Data Calendar API Here's some code that I've done w...

The Not English Edition

Four blog posts on IronPython in Japanese and Chinese containing interesting code examples. Environment Variables in Python and IronPython This Japanese blog entry shows two code examples for working with environment variables. The example for Python (CPython - the 'standard' implementation of Python) uses the os.environ , although the code shown should work fine with IronPython as well. The IronPython example uses the .NET class System.Environment to access environment variables and System.IO.StreamWriter to save data to a file. Embedding IronPython in C# This Japanese blog entry starts with a brief example of Python syntax and then a fairly complete example of embedding IronPython 2 in C#. It includes setting up the DLR classes (engine and execution scope etc) and then accessing Python variables by type, pulling a Python list out as an instance of IronPython.Runtime.List . Using Extension Methods in C# and IronPython Extension methods are a statically typed version of monke...

A Good Mix 3: Releases, Tweeting and DIE

Another selection of recent posts on IronPython related subjects. All the posts in this mix are by Harry Pierson and Davy Mitchell ! First, DevHawk (Harry Pierson) has some comments on recent IronPython releases. AgDLR 0.5 This is the Dynamic Languages SDK for Silverlight that recently had a refresh for Silverlight 3. In this post Harry discusses XapHttpHandler , an ASP.NET handler for IIS that can dynamically build dynamic applications using Chiron. He particularly likes this feature as he wrote it! XapHttpHandler does the same exact on-demand XAP packaging for dynamic language Silverlight applications that Chiron does, but it’s implemented as an IHttpHandler so it plugs into the standard ASP.NET pipeline. All you have to do is put the Chiron.exe in your web application’s bin directory and add XapHttpHandler to your web.config IronPython 2.6 Alpha 1 Something else that got releases recently was the first alpha of IronPython 2.6. This version of IronPython will target Python 2.6, ...

YAAS 2 (Another Yet Another Awesome Selection)

Another blog entry accreted from only the finest selection of IronPython related blog postings from the last few weeks: A Simple DLR Binder This entry is notable because Dino Viehland (core IronPython developer) has finally written another blog post! This post is on writing DLR binders, a core part of creating dynamic languages that use the Dynamic Language Runtime. DLR binders define the semantics of your language, and Dino explains them along with some C# example code implementing integer addition: There’s a few key pieces you need to understand here. First you’re returning an expression tree back to the DLR to tell the DLR what to do. The DLR will compile this expression tree and run it. You’re also returning a set of restrictions. These will be evaluated by the DLR to see if it can re-use the same code for other objects in the future. You’re unlimited in what you can do with restrictions as they can be arbitrary Expression trees. But here I’m simply restricting based upon th...

LiveFX using IronPython

Ori Amiga is the group program manager of the Live Framework development platform. He has started a blog, and in his first entry he demonstrates how to use the LiveFX SDK from IronPython. According to the website: "The Live Framework is the uniform way for programming Live Services from a variety of platforms, programming languages, applications and devices. Consume and combine Live Services to build applications that span across digital devices and the web." LiveFX using IronPython Download and install the latest IronPython console from [here] Grab the sample LiveOE.py file from [here] Edit the LiveOE.py file and change the line sdkLibsPath = r"..\LiveFrameworkSDK\Libraries\.Net Library" to reflect the path where you’ve installed the LiveFX SDK .NET libraries Launch the IronPython console from the command line: [ ipy.exe -X:TabCompletion ] At the console, you can now type something like: import LiveOE livefx = LiveOE.Conn...

A Whole Bunch of Stuff: Part II

More IronPython and DLR related stuff collected over the last few weeks. IronPython en Mandriva 2009 This looks like a very interesting blog entry, and the only reason it is here rather than having a post to itself is that it is in Spanish and so I can't tell you much about what it says... It is by Jacobnix and about using IronPython with Mandriva Linux and Mono. PATCH: System.Type.FindMembers return type PATCH: System.IO.TextReader.Null implementation Two patches to Mono (by Bill Holmes) allowing you to compile and use recent versions of IronPython 2. This is great news as the version of IronPython 2 included with Mono (from FePy ) is 2.0 alpha 5 - which is pretty out of date now. IronPython Cookbook: XML Settings File IronPython Cookbook: Reading Eventlogs Two new recipes in the IronPython Cookbook (both by Davy Mitchell I believe). Accessing mssql with Python or IronPython This StackOverflow question yielded several answers, including this example IronPython code for working wit...

A Whole Bunch of Stuff: Part I

My backlog includes a lot of interesting snippets and blog entries that probably don't warrant a whole entry to themselves. There's a lot of good stuff in them, so I'm splitting them out into two separate entries. Calling IronPython Functions from C# A blog entry on using the IronPython 1 hosting API to call functions - including embedding it in ASP.NET pages. Microsoft Announces Windows HPC Server 2008 Windows High Performance Computing Goes Mainstream This happened a while ago, but I missed it. Windows High Performance Computing Operating System is out (HPC Server 2008) - and it includes IronPython 'out of the box'! " To tempt Unix users and coders in scientific programming languages, there is a built-in POSIX shell, support for IronPython, IronRuby and Fortran. Microsoft is also developing new tools such as the F# programming language and .NET Parallel Extensions. " " Much of the legacy code that developers may need to support is Linux-based, he sa...

Assorted Snippets

Here are a collection of recent blog entries that feature IronPython but don't quite qualify for an IronPython-URLs entry of their own. Starting with two new pages on the IronPython Cookbook : Validating a Filename A short recipe by Davy Mitchell that ensures user input is valid as a possible filename, removing invalid characters. Profiling for Silverlight An entry by Dan Eloff demonstrating performance profiling for IronPython Silverlight applications. Steve Gilham has been doing some odd things. Notably creating Java libraries in Java and Scala and then running them on .NET using the IKVM cross-compiler. I haven't been tracking them on this blog because most of the experiments have only been tangentially related to IronPython, but his latest entry is interesting. Here he is writing Scala (a very statically typed language for the Java Virtual Machine) code and using it from IronPython: Scaling the tower of Babel II Which of course begs the question why ?... it's still c...

Simple IronPython Example Using XML, Oracle and SQL Server

From the " Head Above The Clouds Blog ": This is an IronPython example of using .NET classes to load a XML document, query it with a simple XPath expression, and then using the results to transfer data from an Oracle to a SQL Server database. Simple IronPython Example Using XML, Oracle and SQL Server

IronPython Parser AST Walker

A post by Michael (not me - another one...) on how to use the IronPython 1.1. parser from C#. By creating new expression walkers that inherit from the AstWalker class you can do interesting things with Python code parsed into an IronPython Abstract Syntax Tree: IronPython Parser AST Walker

Python Generation using the Code Dom

IronPython 1 has a CodeDom provider. This means that IronPython Studio can use it to generate Python code from the Windows Forms and WPF designers, and even generate executable files from Python projects. This is one feature that hasn't yet made it into IronPython 2, but there are strange rumblings from the IronPython team that it may just make it. In the meantime, 'tech-michael' has a blog entry showing how to use IronPython CodeDom to generate Python code from metadata. Python Generation using the Code Dom