Commit 812a7175 authored by Mr Phong's avatar Mr Phong

add error log

parent 8f02e3ae
...@@ -50,11 +50,12 @@ with open(log_file, 'a') as file_output: ...@@ -50,11 +50,12 @@ with open(log_file, 'a') as file_output:
sys.stdout = file_output sys.stdout = file_output
for index, row in df_host.iterrows(): for index, row in df_host.iterrows():
logger.info("Connect to site " + str(row['name']) + " with host " + str(row['host'])) site_name = str(row['name'])
if(str(row['name'])==''): logger.info("Connect to site " + site_name + " with host " + str(row['host']))
if(site_name==''):
row["session_log"]=output_dir+str(index)+'.txt' row["session_log"]=output_dir+str(index)+'.txt'
else: else:
row["session_log"]=output_dir+str(row['name'])+'.txt' row["session_log"]=output_dir+site_name+'.txt'
row = row.drop(labels=['name']) row = row.drop(labels=['name'])
if(str(row["device_type"]).strip()=="autodetect"): if(str(row["device_type"]).strip()=="autodetect"):
guesser = SSHDetect(**row) guesser = SSHDetect(**row)
...@@ -66,7 +67,7 @@ with open(log_file, 'a') as file_output: ...@@ -66,7 +67,7 @@ with open(log_file, 'a') as file_output:
logger.info("Connect to host : " + str(row['host']) + " success !") logger.info("Connect to host : " + str(row['host']) + " success !")
run_commands(device_connect, df_command) run_commands(device_connect, df_command)
except Exception as ex: except Exception as ex:
logger.error("ERROR when execute command with device "+ str(row["host"])) logger.error("ERROR when execute command in site " + site_name + " with device "+ str(row["host"]))
logger.error(ex) logger.error(ex)
sys.stdout.close() sys.stdout.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment