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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -