[Spambayes] Unwanted stock solicitations
Luigi Pugnetti
pl at symbolic.it
Fri Nov 3 09:48:36 CET 2006
On Fri, 2006-11-03 at 02:10 +0100, Vibe Grevsen wrote:
> Hi again,
>
> good news - I fiddled a bit more and got it working under Windows :) :) :)
>
Hello,
>
> >> ocr = os.popen( ( "ocrad -s %s -c %s -x %s < %s 2>" + os.path.devnull ) %
> >> (scale, charset, orf, pnmfile))
>
> > or better use os.popen3 and discard stderr output.
>
> os.popen3() does not seem to support the read()-method?
Are you sure? I have used It on at least a couple of version of python.
If you look into the code snippet I sent yesterday you may see few line
commented calling ocrad using popen3 and it works (at least on of a few
computers I tested it)
>
>
> > On windows you have to put quote around pnmfile to protect against space
> > in path (also un linux you should have them but it's unlikely you get a
> > path with a space).
>
> Oh, YES, you're absolutely right.
> Thank you for this suggestion.
>
>
> > On windows there is also an other caveat.
> > you should put quote also around ocrad path but if you do that you have
> > to quote everything.
> > to explain the command should be:
>
> > ocr_cmd = r'""ocrad_path" -s %s -c %s "%s""'%(scale, charset, pnmfile)
> > fin, fout, ferrr = os.popen3(ocr_cmd)
>
> I tested your suggestion, but it seemed to resolve wrong in the interpreter.
> Also popen3() could not be read() so I changed it a bit
Strange. It's work for me
>
> # u: unicode support, r: raw string
> ocr_cmd = ur'ocrad -s %s -c %s "%s"' % (scale, charset, pnmfile)
> ocr = os.popen( ocr_cmd )
>
> I also tested this
>
> # u: unicode support, r: raw string
> ocr_cmd = ( ur'ocrad -s %s -c %s < "%s" 2>' + os.path.devnull ) % (scale, charset, pnmfile)
> ocr = os.popen( ocr_cmd )
>
> Both working in windows so Skip can pick whichever he likes best ;)
Does 2> really work? I think it kind of works because it's ignored by
cmd.exe but it's a unix sh construct (I'm not really sure if it even
works using csh derived shells)
>
>
> >> Maybe you could hint on other parts of the sources I should check for the next lead?
>
> With the above change I only had to do one more thing...
> Comment out the check for ocrad, then OCR is working. (Assuming ocrad 0.16 is in the path.)
>
> This means that we should probably work on testing the find_program and is_executable procedures.
> As soon as they are finished I could probably start on a new exe-installer-version.
> I think I figured how to include PIL in the exe aswell.
>
>
> >> ocrad -s4 -x out.txt >ocr.txt logo.pgm
> >> did produce an ocr.txt but no out.txt for this image http://www.unlockaarhus.dk/dev/logo.pgm.
>
> > using -s (and other flags as well) disable -x.
>
> Hmm, bug, no, better undocumented feature? :)
oh yes, you have to look inside the source code to find it
> (At least it's not explained in the ocrad readme as far as I can see...)
>
>
> > orf file is never used. probably is there from the start before skip
> > introduce the scale parameter
>
> Actually he tries to count the number of lines in orf I think
no, he looks for line starting with line that probably it's related to
the number of line in the output.
>
> for line in open(orf):
> ...
>
> But this could of course be done directly on ocr.read().
>
>
> Happy coding :)
>
> Vibe
> _______________________________________________
> SpamBayes at python.org
> http://mail.python.org/mailman/listinfo/spambayes
> Check the FAQ before asking: http://spambayes.sf.net/faq.html
--
Luigi Pugnetti
Symbolic S.p.A.
V.le Mentana, 29
I-43100 Parma
Italy
Tel: +39 0521 708811
Fax: +39 0521 776190
More information about the SpamBayes
mailing list