Hi,
Just put your first argument in pOpen() or call() in a list such as:
call([‘command’, ‘option’, ‘argument’, ‘…’], stderr, stdout, shell= whatever)
Cheers
Yuma Antoine Decaux
"Light has no value without darkness"
Mob: +61 410732547
Skype: Shainobi1
twitter: http://www.twitter.com/triple7
On 2/04/2015, at 11:48 am, Pranav Lal <pranav.lal@xxxxxxxxx> wrote:
Hi all,
I need to execute an external program from my python script which is running
on
windows 7.
The commandline of the program is below.
convert img-150330141312.pdf -auto-level -compress none ocr.tiff
How do I use subprocess to do this? I have tried the below code and it is
failing by stating that -auto-level is an invalid parameter.
Note:
The convert.exe utility is a part of the image magic program.
def convertPDFImage(fpn,tempPath):
ocrOutputName=os.path.join(tempPath, 'ocr.tif')
cmList=[]
cmList.append('convert')
cmList.append(fpn)
cmList.append("-auto-level")
cmList.append("-compress none")
cmList.append(ocrOutputName)
try:
subprocess.check_call(cmList)
except CalledProcessError as e:
print(e.returncode)
ocrOutputName='error'
return ocrOutputName
Pranav
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq