linux - Python subprocess AttributeError -
i have following issue:
try: subprocess.check_call(query): return 1 except valueerror: return -1
this code runs shell script , it's working far. script returns 0. nevertheless got error:
with subprocess.check_call(query): attributeerror: 'int' object has no attribute '__exit__'
so there has someting wrong try/except block.
subprocess.check_call()
returns int status code 0
, not context manager. cannot use in with
statement.
return subprocess.check_call(query)
just return return value of call. note not raise valueerror
exception either; it'll raise calledprocesserror
if process exits non-zero status code.
perhaps wanted use subprocess.call()
.
Comments
Post a Comment