try:
es1,es2 = es_connection()# call to es_connection function
path = " "
for files in os.listdir(path):
try:
if files.endswith('.json'):
name = files.strip(".json")
json_path = os.path.join(path, files)
with open(json_path, "r") as json_file:
action to be performed
except Exception as ex:
print(ex)
pass
#except2
except Exception as ex:
subject = "Unable to ping ES"
send_mail_parameters(subject) # call to sendmail function
I have following 2 queries
- I wanted to connect to ES and execute query in try block, if unable to connect to ES need to send mail (code in except2 block) but what is happening is even after code in try is executed, without executing except block mail is sent.
Need help to find out why is this happening
- is my pass statement indented right to continue for loop?