15472 - rewrite puppet agent

Add additional error checking when printing results in the
plugins own printrpc like function to avoid failures when no
results were received