I think an useful improvement can be the liberty to choose the input
message language...
Yaml is diffuse and supports in many languages, but, for example, if I
want to call func from Lisp (I hope nobody need to call func from Lisp
:)), there's no Yaml library... so?
If I can choose "language", as Adrian said in a previous post, with a
simple parameter we can really call from everywhere
func-transmit --xml < xml-input > xml-output
What do you think?
Marco
Michael DeHaan wrote:
So, previous discussion on the list indicated we needed a good way to
call the Func API over stdin/stdout to allow for non-Python programs
to act as if they were the overlord. Parsing just doesn't work here.
Marco Mornati contibuted a very nice initial version, which I've
tweaked a bit. For simplicity of working on it, have added to git and
packaged in the RPM. I am really excited about this feature as it
should allow for much more usage of Func in a lot of interesting
ways. Even more exciting is that this implementation is, as with
many things in Func, amazingly short!
This is called "func-transmit", and it's not quite done yet in that we
need a manpage, and we /might/ want to do XMLRPC marshalling instead
(just because it's one less dependency). Currently this uses the
relatively ancient YAML package that is packaged with cobbler. (yum
install cobbler if you are lazy). This will be resolved shortly.
Sources are in /func/func/scripts
Example usage:
[root@localhost scripts]# python func-transmit < func-transmit-demo
---
localhost.localdomain:
- 0
- |
Hello World
- ''
This shows command line usage, though more realistically, this would
be called by another program with a pipe for sending things from stdin
and recieving standard out.
Func-transmit-demo in the above case is a simple YAML file containing
info about what we want Func to do:
[root@localhost scripts]# cat func-transmit-demo
clients: "*"
aysnc: False
nforks: 1
module: command
method: run
parameters: "/bin/echo Hello World"
Note in the above case, there is only one parameter, a string. You
can also send in arrays and hashes and anything else that can go over
XMLRPC. This is easier when using YAML to first serialize a
datastructure (hash, map, dictionary, whatever you want to call it)
than writing the YAML yourself.
I'll make a Wiki topic on this also, as well as file Trac items for
including YAML in Func and making the man page.
Expansions and improvements to this are welcome, you can send in
patches against the version in git.
--Michael
--
Dott. Ing. Mornati Marco
Byte-Code s.r.l
via Antonio Cechov, 1
San Giuliano Milanese (MI)
E-Mail: mmornati@xxxxxxxxxxxxx
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list