[Libguestfs] [PATCH v2 2/3] v2v: utils: Add utility functions for running external Python code.
Richard W.M. Jones
rjones at redhat.com
Wed Feb 28 12:42:09 UTC 2018
On Wed, Feb 28, 2018 at 12:21:07PM +0100, Tomáš Golembiovský wrote:
> On Tue, 27 Feb 2018 21:33:23 +0000
> "Richard W.M. Jones" <rjones at redhat.com> wrote:
>
> > ---
> > v2v/utils.ml | 23 +++++++++++++++++++++++
> > v2v/utils.mli | 11 +++++++++++
> > 2 files changed, 34 insertions(+)
> >
> > diff --git a/v2v/utils.ml b/v2v/utils.ml
> > index 1ceba94cd..bf4106620 100644
> > --- a/v2v/utils.ml
> > +++ b/v2v/utils.ml
> > @@ -196,3 +196,26 @@ let find_file_in_tar tar filename =
> > )
> > in
> > loop lines
> > +
> > +let run_python ?(python = "python") code =
> > + (* In debug mode output the python code into the log. *)
> > + debug "running python code using ‘%s’:\n%s" python code;
> > +
> > + (* Write the Python code to a temporary file so we don't have to
> > + * quote things.
> > + *)
> > + let filename, chan = Filename.open_temp_file "py" ".py" in
> > + output_string chan code;
> > + close_out chan;
> > +
> > + let cmd = sprintf "%s %s" (quote python) filename in
>
> quote filename
Thanks, will be fixed in the next version.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the Libguestfs
mailing list