On Tue, Sep 28, 2010 at 9:51 AM, Nigel Kersten <ni...@explanatorygap.net>wrote:

> On Tue, Sep 28, 2010 at 9:29 AM, Douglas Garstang
> <doug.garst...@gmail.com> wrote:
> > Has anyone got/seen Python code to read puppet reports?
> > I added a bunch of these:
> > class PuppetReport(yaml.YAMLObject):
> >   yaml_tag = u'!ruby/object:Puppet::Transaction::Report'
> >   def __init__(self, host, logs, metrics, records, time):
> >     self.host = host
> >     self.logs = logs
> >     self.metrics = metrics
> >     self.records = records
> >     self.time = time
> > However, the Python YAML parser fails with:
> > "yaml.constructor.ConstructorError: expected a mapping node, but found
> > scalar"
> > On the ruby/sym line:
> >     !ruby/sym config_retrieval: 0.853000164031982
> > I don't know how to define the classes to accept a scalar data type
> rather
> > than a mapping node data type, and Mr Google is giving me ZERO answers.
>
> Huh. This must have changed, as I was doing it in exactly the same
> way. Is that actually from an old list message of mine?
>
> I think you've misread the error message. It basically doesn't know
> what to do with !ruby/sym at all.
>
> It may turn out nowadays to be simpler to do the parsing in Ruby and
> loading the puppet libraries so you get all this for free.
>
> I'll have a poke around and see if I can work out how to coerce
> !ruby/sym to something Python can understand.
>
>
>
Nigel, yep. It's an old message post of yours. I tried it too, and had the
same issue as Eduardo.

It seems that it fails on !ruby/sym because:

yaml.constructor.ConstructorError: expected a mapping node, but found scalar
  in "/var/lib/puppet/reports/foo.com/201009281644.yaml", line 3, column 5

where the code has:

class PuppetObj1(yaml.YAMLObject):
    yaml_tag = u'!ruby/sym'
    def __init__(self, attr):
        self.attr = attr

I really don't know how a scalar node is supposed to differ from a mapping
node in the python code.

Doug.


Doug.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to