我试图在Mac终端中输入此命令
#!/usr/bin/env python
from sys import argv
from subprocess import check_call
from os.path import basename, dirname, splitext, join
from tempfile import NamedTemporaryFile
app = argv[-1]
ldid_path = join(dirname(__file__), 'ldid')
obj_path = join(app, splitext(basename(app))[0])
if '-gta' not in argv:
check_call([ldid_path, '-S', obj_path])
else:
with NamedTemporaryFile('w+b', 0) as f:
f.write("""
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>get-task-allow</key>
<true/>
</dict>
</plist>
""")
f.flush()
check_call([ldid_path, '-S' + f.name, obj_path])
但是我收到了一个错误:
iMac-Oleg:ldid olegmelnik$ f.flush()
check_call([ldid_path,&#39; -S&#39; + f.name,obj_path]) -bash:意外令牌`check_call&#39;
附近的语法错误
如何解决这个问题?非常感谢...
答案 0 :(得分:0)
in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/olegmelnik/Desktop/ldid', '-S', '/Users/olegmelnik/Desktop/ldid3.py/ldid3']' returned non-zero exit status 1
这是check_call
的作用。如果您不想要,请不要使用check_call
。有关详细信息,请参阅subprocess
documentation。