Skip to content

Commit

Permalink
Capture connection error , for #16
Browse files Browse the repository at this point in the history
  • Loading branch information
ltamaster committed Dec 27, 2018
1 parent 08775e2 commit fca7a50
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions contents/winrm_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,20 @@ def __init__(self, session, shell, command ):
self.shell = shell

def get_response(self):
if self.shell == "cmd":
response = self.session.run_cmd(self.exec_command, out_stream=self.o_stream, err_stream=self.e_stream)
self.o_std = response.std_out
self.e_std = response.std_err
self.stat = response.status_code

if self.shell == "powershell":
response = self.session.run_ps(self.exec_command, out_stream=self.o_stream, err_stream=self.e_stream)
self.o_std = response.std_out
self.e_std = response.std_err
self.stat = response.status_code
try:
if self.shell == "cmd":
response = self.session.run_cmd(self.exec_command, out_stream=self.o_stream, err_stream=self.e_stream)
self.o_std = response.std_out
self.e_std = response.std_err
self.stat = response.status_code

if self.shell == "powershell":
response = self.session.run_ps(self.exec_command, out_stream=self.o_stream, err_stream=self.e_stream)
self.o_std = response.std_out
self.e_std = response.std_err
self.stat = response.status_code

except Exception as e:
print(e)
self.e_std = e
self.stat=-1

0 comments on commit fca7a50

Please sign in to comment.