forked from 0x2620/pandora
close filedescriptor after use
This commit is contained in:
parent
e4133ffa1d
commit
79c5d948b5
1 changed files with 2 additions and 1 deletions
|
@ -19,10 +19,11 @@ def extract_text(pdf, page=None):
|
||||||
# split page from pdf and ocr
|
# split page from pdf and ocr
|
||||||
fd, page_pdf = tempfile.mkstemp('.pdf')
|
fd, page_pdf = tempfile.mkstemp('.pdf')
|
||||||
cmd = ['pdfseparate', '-f', page, '-l', page, pdf, page_pdf]
|
cmd = ['pdfseparate', '-f', page, '-l', page, pdf, page_pdf]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
text = ocr_image(page_pdf)
|
text = ocr_image(page_pdf)
|
||||||
os.unlink(page_pdf)
|
os.unlink(page_pdf)
|
||||||
|
os.close(fd)
|
||||||
return text
|
return text
|
||||||
else:
|
else:
|
||||||
return ocr_image(pdf)
|
return ocr_image(pdf)
|
||||||
|
|
Loading…
Reference in a new issue