[Libguestfs] [PATCH 4/5] dib: require a Python interpreter

Richard W.M. Jones rjones at redhat.com
Wed Mar 22 21:37:54 UTC 2017


On Wed, Mar 22, 2017 at 06:03:07PM +0100, Pino Toscano wrote:
> On Wednesday, 22 March 2017 16:56:57 CET Richard W.M. Jones wrote:
> > On Wed, Mar 22, 2017 at 11:19:49AM +0100, Pino Toscano wrote:
> > >    if elements = [] && machine_readable then (
> > > @@ -246,6 +252,19 @@ read the man page virt-dib(1).
> > >    if elements = [] then
> > >      error (f_"at least one distribution root element must be specified");
> > >  
> > > +  let python =
> > > +    match python with
> > > +    | Some exe ->
> > > +      let p =
> > > +        if Filename.is_relative exe then
> > 
> > IIUC what you mean here is "the 'exe' filename doesn't contain
> > any slashes"?  That isn't what is written above.
> 
> Yes, sort of.  What about something like:
> 
>   let p =
>     try
>       ignore (String.find exe Filename.dir_sep);
>       Unix.access exe [Unix.X_OK];
>       exe
>     with
>     | Not_found ->
>       get_required_tool exe in

The String.find function in mllib/ returns -1 for not found.  I think
it never throws an exception.  But in general yes that's a better
approach.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list