mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 22:38:42 +00:00
fix async
This commit is contained in:
parent
a03fd72dbd
commit
4cb31cc3ed
|
|
@ -91,6 +91,7 @@ final class TesseractOcr
|
||||||
self::$bin,
|
self::$bin,
|
||||||
$image . ' '
|
$image . ' '
|
||||||
. ($temp = \tempnam(\sys_get_temp_dir(), 'ocr_'))
|
. ($temp = \tempnam(\sys_get_temp_dir(), 'ocr_'))
|
||||||
|
. ' -c preserve_interword_spaces=1'
|
||||||
. ' --psm ' . $psm
|
. ' --psm ' . $psm
|
||||||
. ' --oem ' . $oem
|
. ' --oem ' . $oem
|
||||||
. ' -l ' . \implode('+', $languages)
|
. ' -l ' . \implode('+', $languages)
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ final class SystemUtils
|
||||||
. $cmd;
|
. $cmd;
|
||||||
|
|
||||||
if ($async) {
|
if ($async) {
|
||||||
$cmd .= ' > nul 2>&1';
|
$cmd .= ' > nul 2>&1 &';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$cmd = \escapeshellarg($executable)
|
$cmd = \escapeshellarg($executable)
|
||||||
|
|
@ -164,7 +164,7 @@ final class SystemUtils
|
||||||
. $cmd;
|
. $cmd;
|
||||||
|
|
||||||
if ($async) {
|
if ($async) {
|
||||||
$cmd .= ' > /dev/null 2>&1';
|
$cmd .= ' > /dev/null 2>&1 &';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,8 +180,16 @@ final class SystemUtils
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stdout = \stream_get_contents($pipes[1]);
|
$stdout = '';
|
||||||
$stderr = \stream_get_contents($pipes[2]);
|
$stderr = '';
|
||||||
|
|
||||||
|
if ($async) {
|
||||||
|
\stream_set_blocking($pipes[1], false);
|
||||||
|
\stream_set_blocking($pipes[2], false);
|
||||||
|
} else {
|
||||||
|
$stdout = \stream_get_contents($pipes[1]);
|
||||||
|
$stderr = \stream_get_contents($pipes[2]);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pipes as $pipe) {
|
foreach ($pipes as $pipe) {
|
||||||
\fclose($pipe);
|
\fclose($pipe);
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class PdfParser
|
||||||
SystemUtils::runProc(
|
SystemUtils::runProc(
|
||||||
__DIR__ . '/../../../cOMS/Tools/InvoicePreprocessing/App',
|
__DIR__ . '/../../../cOMS/Tools/InvoicePreprocessing/App',
|
||||||
\escapeshellarg($file) . ' '
|
\escapeshellarg($file) . ' '
|
||||||
. \escapeshellarg($file)
|
. \escapeshellarg($file)
|
||||||
);
|
);
|
||||||
|
|
||||||
$ocr = new TesseractOcr();
|
$ocr = new TesseractOcr();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user