From 376e5485dc190ffe3c35ea3654617285b90d6adb Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 1 Oct 2015 15:09:45 +0200 Subject: [PATCH] prepare rclmpdf->rclmpdf.py for windows --- src/filters/{rclmpdf => rclmpdf.py} | 31 +++++++++++++++++++---------- src/sampleconf/mimeconf | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) rename src/filters/{rclmpdf => rclmpdf.py} (94%) diff --git a/src/filters/rclmpdf b/src/filters/rclmpdf.py similarity index 94% rename from src/filters/rclmpdf rename to src/filters/rclmpdf.py index d3d72da6..27f221ec 100755 --- a/src/filters/rclmpdf +++ b/src/filters/rclmpdf.py @@ -22,7 +22,6 @@ import sys import re import rclexecm import subprocess -import distutils.spawn import tempfile import atexit import signal @@ -39,10 +38,22 @@ def signal_handler(signal, frame): atexit.register(finalcleanup) -signal.signal(signal.SIGHUP, signal_handler) -signal.signal(signal.SIGINT, signal_handler) -signal.signal(signal.SIGQUIT, signal_handler) -signal.signal(signal.SIGTERM, signal_handler) +try: + signal.signal(signal.SIGHUP, signal_handler) +except: + pass +try: + signal.signal(signal.SIGINT, signal_handler) +except: + pass +try: + signal.signal(signal.SIGQUIT, signal_handler) +except: + pass +try: + signal.signal(signal.SIGTERM, signal_handler) +except: + pass def vacuumdir(dir): if dir: @@ -173,14 +184,14 @@ class PDFExtractor: self.currentindex = -1 self.attextractdone = False - if self.pdftotext == "": - self.pdftotext = distutils.spawn.find_executable("pdftotext") - if self.pdftotext is None: + if not self.pdftotext: + self.pdftotext = rclexecm.which("pdftotext") + if not self.pdftotext: print("RECFILTERROR HELPERNOTFOUND pdftotext") sys.exit(1); - if self.pdftk == "": - self.pdftk = distutils.spawn.find_executable("pdftk") + if not self.pdftk: + self.pdftk = rclexecm.which("pdftk") if self.pdftk: global tmpdir diff --git a/src/sampleconf/mimeconf b/src/sampleconf/mimeconf index 8732d030..26418ca2 100644 --- a/src/sampleconf/mimeconf +++ b/src/sampleconf/mimeconf @@ -63,7 +63,7 @@ application/vnd.ms-office = exec rcldoc application/ogg = execm rclaudio application/pdf = exec rclpdf -# application/pdf = execm rclmpdf +# application/pdf = execm rclmpdf.py application/postscript = exec pstotext;charset=iso-8859-1;mimetype=text/plain application/vnd.ms-excel = exec rclxls application/vnd.ms-powerpoint = exec rclppt