On 24.08.19 16:19, Rogier Wolff wrote:
On Sat, Aug 24, 2019 at 03:30:35PM +0200, 'Kay F. Jahnke' via hugin and other 
free panoramic software wrote:

The 'shebang' is a hint to a shell how to process code which is
launched by the shell; it's not part of python syntax (seen from the
python side, it's merely a comment, like the offending api-min and
api-max tags).

If I remember correctly in the very old days when the shell was asked
to execute say "/bin/which" (which is a #!/bin/sh shell script on my
current system), the kernel would return "not an executable". The
shell would indeed then open the file, check for #! as the first two
characters and then launch the interpreter with the proper argument.

This was in the days that we ran Unix on a PDP-11 with 256k RAM. (I
don't remember if we ran BSD or sysV on that thing.....)

Anyway, on modern systems it is the kernel and not the shell that does
this.

I would vote for keeping the #! as the first two characters.
What comes after that could either be /usr/bin/python, or
/usr/bin/hugin .

In both cases, this should be made to "do the right thing".

If possible, this would mean starting the script within hugin.  (I
don't know what kinds of scripts we're talking about,

We are talking about the scripts in

 src/hugin_script_interface/plugins/

and

 src/hugin_script_interface/plugins_dev/

but a script
that asks the user to browse to say a specific type of pictures and
then causes some preprocessing to happen before triggering an
optimization and output step would make this possible. On the other
hand if a script can only be run when you already have images loaded
inside hugin, then this option does not apply. )

When the python plugins are invoked by hugin they all take a panorama object as their sole argument - so there has to be a panorama in hugin.

The other option for "right thing" would be to print an error message:
"This can only be run from inside hugin". (*)

It depends on the python file: you can write it so that it only runs as a hugin plugin, or you can write it so that it can run as a plugin and stand-alone as well. But maybe that's too much artistry; I thought this would make it simpler to maintain because both modes of operation are in a single file. Maybe it's better to stick to plugins only and remove the stand-alone capability.

When executing scripts hugin should try to enforce this first line
to be correct.

So you mean hugin should look for a "#! /usr/bin/hugin" shebang and refuse to run the plugin if that is missing?

Take care that when it makes sense to be able to start scripts on
their own, you should NOT check the PATH part of the
"#!/...path.../program\n" . Just check for the #!/ first three letters
and the right program name at the end of the line.

        Roger.

(*)
So the easiest way would be to have:
#!/usr/bin/hugin -s
as the first line of the script. Then the manual page for
hugin would say:

   -s <filename>
      print "This script must be started from inside hugin" and exit.


I'm not sure if I follow. The plugins are not launched by invocation of 'hugin' on the command line. They are executed by clicking on an entry in the 'actions' menu (which is only present if hugin was compiled with plugin capability and if there are plugins passing the api-min and api-max test). This is the only way users get access to them, unless they explicitly invoke the python files in the relevant subdirectory of their hugin installation.

Kay

--
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/d563f64b-7a10-0dd0-6c5b-92ab7246c9c7%40yahoo.com.

Reply via email to