Re: stay_open fails with -q as common_args [SOLVED]

Started by mahikeulbody, December 12, 2012, 07:22:22 AM

Previous topic - Next topic

mahikeulbody

I am using Exiftool v9.03 with stay_open and PIPEs for stdin, stdout and stderr. It is running fine.

Today I added -q to my common_args in order to avoid messages such as "1 image files updated" on my stderr PIPE. But with this option, my application does not see anymore the {ready} mark on my stdout PIPE. Am I doing something wrong ?

Thanks for your fantastic work.
Michel

Phil Harvey

Hi Michel,

From the application documentation for the -stay_open option:

            3) Write "-execute\n" to ARGFILE, where "\n" represents a newline
            sequence.  (Note: You may need to flush your write buffers here if
            using buffered output.)  Exiftool will then execute the command
            with the arguments received up to this point, send a "{ready}"
            message to stdout when done (unless the -q option is used),
            [...]


If you want to use the -q option and still get the "{ready}" message, you will have to generate it yourself.  You can do this with the -echo option in a separate command afterwards.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mahikeulbody

Thanks for this quick and complete answer !

Michel


mahikeulbody

Your suggestion to add an -echo option in a separate command afterwards needs to specify a file. Only
-echo
{ready}
-execute


doesn't work. Which command I should set in order to sent "{ready}" - and only that - on my stdout PIPE ?

Phil Harvey

There is something else going on here.  Here is a cut-n-paste from my console (Mac):

> cat a.args
-echo
{ready}
-execute

> exiftool -@ a.args -common_args -q
{ready}

>


Are you sure there is a newline after your -execute ?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mahikeulbody

Absolutely sure.
I send my command through the stdin PIPE :
-XMP-dc:Description=aaa
-XMP-dc:Subject=bbb
/home/michel/image.jpg
-execute
-echo
{ready}
-execute


and common_args : '-charset', 'iptc=UTF8', '-G1', '-e', '-j', '-q'
Then I read the stdout PIPE but my process get blocked : it never return from the readline function.

The same code with
-XMP-dc:Description=aaa
-XMP-dc:Subject=bbb
/home/michel/image.jpg
-execute


and common_args : '-charset', 'iptc=UTF8', '-G1', '-e', '-j'
runs fine...

I will check it deeper tomorow.

Michel

Phil Harvey

Odd.  I tried this here and it works for me:

> exiftool -stay_open true -@ a.args -common_args -charset iptc=UTF8 -G1 -e -j -q
[{
  "SourceFile": "a.jpg"
}]
{ready1}
{ready2}
[{
  "SourceFile": "a.jpg",
  "XMP-dc:Description": "aaa",
  "XMP-dc:Subject": "bbb"
}]
{ready3}


and here is my "a.args" file, which I generated line-by-line after running the command to make sure the -stay_open option was working:

-XMP-dc:Description
-XMP-dc:Subject
a.jpg
-execute
-echo
{ready1}
-execute
-XMP-dc:Description=aaa
-XMP-dc:Subject=bbb
a.jpg
-execute
-echo
{ready2}
-execute
-XMP-dc:Description
-XMP-dc:Subject
a.jpg
-execute
-echo
{ready3}
-execute


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mahikeulbody

Mine args runs ok also, even with -q common_args option, but from an args file, not from a PIPE (except without -q, of course). I call the Python readline from my stdout PIPE and it never returns, as if Exiftool never put a "line" inside stdout.

Very odd.

Phil Harvey

Ah, OK.  The difference is that the -echo output is buffered like all of the other output, while I manually flush the "{ready}" message. (stderr messages are also flushed at this time.)

Hmm.  Tough to know how to work around this.  The -v0 option enables output autoflush, but this won't help because it also adds the type of messages you are trying to avoid.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

ExifTool 9.09 will flush output after each command when using -stay_open, even if the -q option is used. (Provided IO::Handle is available, but it should be.)

This may solve the problem.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mahikeulbody

I am really impressed with your responsiveness... Of course, that is not as if Exiftool was free (as beer and as freedom).
What you said ? It is free ?!   :o

Phil Harvey

Free as beer?  Where?  I may need to re-think living in Canada.  (Here we pay for beer!)

But don't worry, ExifTool will always be free.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mahikeulbody

I just tested -q with Exiftool v9.09 : that runs fine :)

Thank you very much, Phil !


If you travel some day in France (Grenoble), we will talk about "free beer"  ;)

Michel