Catch an error from command line Python -
i need catch error command line without print error message on screen. when occurs need give command run.
this now:
hyst_cmd = "si viewhistory ..." process = subprocess.popen(hyst_cmd, stdout=subprocess.pipe) hyst = process.stdout.read().splitlines()
when projects receive error message, on screen.
sorry english!
according official document, common exception popen in subprocess oserror.
to catch error, can try following approach:
hyst_cmd = "si viewhistory ..." try: process = subprocess.popen(hyst_cmd, stdout=subprocess.pipe) hyst = process.stdout.read().splitlines() except oserror: <write_log_file or other action.>
for more information, can check link below:
subprocess exception
Comments
Post a Comment