Today reenforced the rule that if I need to understand something really bizare, I need to go to the Ugly Mug and start drinking espresso.
For over two years I've wanted to write a python module for remctl (I remember working on this sitting out on the patio of Stomping Grounds, back in Ames). My initial attempt was using SWIG, which generated incredibly ugly code and required a small but annoying change to the remctl source. I abandoned that and decided I should try to write, from scratch, a Python module in C. This went nowhere quickly. It seems (to me, at least) that the documentation and examples on writing a Python module in C are a bit lacking.
Today, for some reason, it started to make sense. In a few hours I had a module that implements the "simple" remctl interface, and a wrapper module around that so I can do sanity checking and argument marshallling in Python, instead of having to do all that nonsense in C. The next step, well, the next step is to get more testing of it done. The next thing on the todo list, then, is to implement the "complex" remctl interface. This will be a little bit more difficult, for two reasons. The first reason, which I don't think will be all that hard, is that I'll have to pass around an opaque remctl struct from the C layer to Python and back. The second reason is that I will want to use the remctl_commandv, which uses iovecs, something I've never used before. That also doesn't look too terribly hard, just something new to try.
You can find the code here.