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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -