ExifTool Forum

ExifTool => Developers => Topic started by: mahikeulbody on December 12, 2012, 07:22:22 AM

Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 12, 2012, 07:22:22 AM
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
Title: Re: stay_open fails with -q as common_args
Post by: Phil Harvey on December 12, 2012, 08:26:22 AM
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
Title: Re: stay_open fails with -q as common_args
Post by: mahikeulbody on December 12, 2012, 08:29:40 AM
Thanks for this quick and complete answer !

Michel

Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 12, 2012, 09:07:46 AM
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 ?
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: Phil Harvey on December 12, 2012, 09:16:55 AM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 12, 2012, 10:19:06 AM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: Phil Harvey on December 12, 2012, 10:57:52 AM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 12, 2012, 11:46:46 AM
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.
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: Phil Harvey on December 12, 2012, 12:04:15 PM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: Phil Harvey on December 12, 2012, 12:24:28 PM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 12, 2012, 01:03:48 PM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: Phil Harvey on December 12, 2012, 01:10:21 PM
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
Title: Re: stay_open fails with -q as common_args [SOLVED]
Post by: mahikeulbody on December 15, 2012, 09:26:21 AM
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