Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5086
Modified Files:
ImageStripper.py
Log Message:
Better (I hope) location and execution of ocrad on Windows.
Index: ImageStripper.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ImageStripper.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ImageStripper.py 9 Sep 2006 22:59:38 -0000 1.6
--- ImageStripper.py 5 Nov 2006 19:13:26 -0000 1.7
***************
*** 44,49 ****
return log(n)/c
- # I'm sure this is all wrong for Windows. Someone else can fix it. ;-)
def is_executable(prog):
info = os.stat(prog)
return (info.st_uid == os.getuid() and (info.st_mode & 0100) or
--- 44,50 ----
return log(n)/c
def is_executable(prog):
+ if sys.platform == "win32":
+ return True
info = os.stat(prog)
return (info.st_uid == os.getuid() and (info.st_mode & 0100) or
***************
*** 52,56 ****
def find_program(prog):
! for directory in os.environ.get("PATH", "").split(os.pathsep):
program = os.path.join(directory, prog)
if os.path.exists(program) and is_executable(program):
--- 53,65 ----
def find_program(prog):
! path = os.environ.get("PATH", "").split(os.pathsep)
! if sys.platform == "win32":
! # Outlook plugin puts executables in (for example):
! # C:/Program Files/SpamBayes/bin
! # so add that directory to the path and make sure we
! # look for a file ending in ".exe".
! path.append(os.path.dirname(sys.executable))
! prog = "%s.exe" % prog
! for directory in path:
program = os.path.join(directory, prog)
if os.path.exists(program) and is_executable(program):
***************
*** 180,185 ****
else:
self.misses += 1
! ocr = os.popen("ocrad -s %s -c %s -x %s < %s 2>/dev/null" %
! (scale, charset, orf, pnmfile))
ctext = ocr.read().lower()
ocr.close()
--- 189,195 ----
else:
self.misses += 1
! ocr = os.popen("%s -s %s -c %s -x %s -f %s 2>%s" %
! (find_program("ocrad"), scale, charset,
! orf, pnmfile, os.path.devnull))
ctext = ocr.read().lower()
ocr.close()
_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins