On Fri, 2010-10-22 at 12:22 -0400, Darren Chamberlain wrote:
> * Richard Crowley <r at rcrowley.org> [2010/10/22 08:57]:
> > > We're writing a few scripts at the moment that could really make
> > > use of Facter, however the vast majority of them team (including
> > > my self!) are not proficient in Ruby, however they are highly
> > > proficient in other languages such as (dare I say it!) Python.
> >
> > Many of the facts already fork so wiring in the command-line
> > facter tool might not be a bad idea and is certainly possible
> > right now.
>
> I was thinking that, too:
>
> import os
>
> facts = {}
> for fact in os.popen("facter").readlines():
> n, v = fact.split(" => ")
> facts[ n ] = v.rstrip()
>
>
> That gives you the facts as a dictionary.
I was afraid someone would suggest that... ;) :P
I'm really looking for bindings that are built into the language (in the
same way that I can do a "require 'facter'" for my mcollective agents!)
but for Python etc.
If all else fails, I guess I could write a wrapper around the above to
create a "facts" class, but if it was a native pypi module or egg, that
would be ace!
I'll take a look at the sourcecode for Facter and see how easy it would
be to translate it into Python.
M.
Thanks in advance,
Matt
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.