Login  Register

Re: Running a Jython Script from the Command Prompt

Posted by Michael Entrup on Feb 15, 2017; 8:16am
URL: http://imagej.273.s1.nabble.com/Running-a-Jython-Script-from-the-Command-Prompt-tp5018100p5018102.html

Hi Mike,

the python doc [1] tells me that os.popen() is deprecated since version
2.6 and this was released about 9 years ago. Your problem does not have
to be related to this, but I would try to use the subprocess module.

At the forum there are a lot of topics about the headless mode [2].

Best regards
Michael


[1]: https://docs.python.org/2/library/os.html#os.popen
[2]: http://forum.imagej.net/search?q=--headless


On 14.02.2017 23:05, MChapman wrote:

> Hello again,
>
> I have a set of image processing codes that go between Python and ImageJ by
> calling macro scripts from Python through the command prompt.  One of these
> calls looks like:
>
> os.popen('"C:\Program Files\Fiji.app\ImageJ-win64.exe" --headless -macro
> "SomeScript.ijm"')
>
> In attempting to integrate "Register Virtual Stack Slices" the only way that
> I could figure out how to script it to work autonomously was with a Jython
> script.  The script works fine on its own, but when I try to call it from
> Python it won't execute, it just opens up the script in the script editor
> instead of executing.  The call looks like this:
>
> os.popen('"C:\Program Files\Fiji.app\ImageJ-win64.exe" --headless -jython
> "SomeScript.py"')
>
> I saw on the wiki that there is a known bug with jython and running
> headless, so I tried:
>
> os.popen('"C:\Program Files\Fiji.app\ImageJ-win64.exe" -jython
> "SomeScript.py"')
> os.popen('"C:\Program Files\Fiji.app\ImageJ-win64.exe" -jython --run
> "SomeScript.py"')
>
> but neither worked.
>
> Any advice on how to get this to execute properly?
>
> Thanks!
> Mike
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Running-a-Jython-Script-from-the-Command-Prompt-tp5018100.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html