So I have:
result = subprocess.check_output(['wine',
os.getcwd()+'/static/sigcheck.exe',
'-a','-i','-q',
self.tmpfile.path()])
But whenever I run this I get this error
CalledProcessError: Command '['wine', '/home/static/sigcheck.exe', '-a', '-i', '-q', '/tmp/tmpxnsN5j']' returned non-zero exit status 1
But if I change check_output
to call
it works fine:
Z:\tmp\tmpvOybcm:
Verified: Unsigned
File date: 9:08 AM 10/24/2012
Publisher: Hardcore Computer
Description: Farthest Emitters Converter
Product: Farthest Emitters Converter
Version: 3.2.0
File version: 3.2.0
fixme:mscoree:StrongNameSignatureVerificationEx (L"Z:\\tmp\\tmpvOybcm", 1, 0x33ec13): stub
Strong Name: Unsigned
Original Name: n/a
Internal Name: Farthest Emitters Converter
Copyright: Hardcore Computer 2006
Comments: n/a
Any reason why check_output
wouldn't work?
A non-zero return code is (usually) a way of indicating exit with error by a program. So subprocess.check_output
will raise an exception if the returncode of the process is non-zero. If you use:
retcode = call(...)
and then print the return code I guess you will see that it is returning 1.
To get output in a string without raising an error on non-zero exit status:
p = Popen(['wine',...], stdout=PIPE)
output = p.communicate()[0]
check_output()
executes rc = p.poll()
after p.communicate()
and raises an error if bool(rc) == True
.
Alternative way
proc = subprocess.Popen(['wine',
os.getcwd()+'/static/sigcheck.exe',
'-a','-i','-q',
self.tmpfile.path()], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout = proc.stdout.read()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.