php-deepface icon indicating copy to clipboard operation
php-deepface copied to clipboard

Issue when running the script

Open pablo-gbr opened this issue 1 year ago • 2 comments

I'm running this package on an Apache server, but every time I run any of the scripts, it gives me a Syntax Error at the try-except block.

It seems that when passing the script to the process, it runs it in a single line, causing the conflict since python can't handle a try-except block in a single line.

To test it, I removed the try-except block from a script, by doing this I get ProcessFailedException whenever the script raises a ValueError exception. I can catch it inside the run() function and parse the ValueError message to throw a DeepFaceException if necessary.

I would like some feedback, in order to submit a new MR to address this.

pablo-gbr avatar Jul 03 '24 15:07 pablo-gbr

Yeah, the script method replaces all linebreaks with a whitespace. I'm not sure if python can execute a multiline string from CLI or if it would have to be a file? 🤔

Gummibeer avatar Jul 04 '24 13:07 Gummibeer

I removed the try block from one of the scripts and running it in powershell with python -c "script code here" and it worked, seems that python doesn't like a try block in a single line.

And I came up that the str_replace(PHP_EOL in the script() function didn't replace \r characters somehow, replacing it with a preg_replace fixed it.

I'm getting all of this trying to run the package on an Apache server, I don't know if anyone came up with the same problems, and in case of submitting a new PR, it should not break any existing projects that depends on this (hopefully).

pablo-gbr avatar Jul 04 '24 14:07 pablo-gbr

There's a new release: https://github.com/Astrotomic/php-deepface/releases/tag/0.4.0

Gummibeer avatar Dec 20 '24 00:12 Gummibeer