python - pxssh exceptions when host is not completely booted -


i error when running script intended monitor tasks in group of servers, script loops among servers connecting via ssh , getting required information. problem sometimes, when 1 of servers tries connect not booted or strange happening , ssh server refuses connection, error stops script. want script omit error , wait next rounds because problem solves in few loops.

this error:

traceback (most recent call last):   file "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 144, in read_nonblocking     s = os.read(self.child_fd, size) oserror: [errno 5] input/output error  during handling of above exception, exception occurred:  traceback (most recent call last):   file "/usr/lib/python3/dist-packages/pexpect/expect.py", line 97, in expect_loop       incoming = spawn.read_nonblocking(spawn.maxread, timeout)   file "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 455, in read_nonblocking     return super(spawn, self).read_nonblocking(size)   file "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 149, in read_nonblocking     raise eof('end of file (eof). exception style platform.') pexpect.exceptions.eof: end of file (eof). exception style platform.  during handling of above exception, exception occurred:  traceback (most recent call last):   file "databasewriter.py", line 280, in <module>     if ping(a) == "online" , requestinfo().login(a) != "pxssh failed on login.":   file "databasewriter.py", line 36, in login     s.login (hostname, username, password)   file "/usr/lib/python3/dist-packages/pexpect/pxssh.py", line 280, in login     = self.expect(["(?i)are sure want continue connecting", original_prompt, "(?i)(?:password)|(?:passphrase key)", "(?i)permission denied", "(?i)terminal type", timeout, "(?i)connection closed remote host"], timeout=login_timeout)   file "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 315, in expect        timeout, searchwindowsize, async)   file "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 339, in expect_list     return exp.expect_loop(timeout)   file "/usr/lib/python3/dist-packages/pexpect/expect.py", line 102, in expect_loop      return self.eof(e)   file "/usr/lib/python3/dist-packages/pexpect/expect.py", line 49, in eof     raise eof(msg) pexpect.exceptions.eof: end of file (eof). exception style platform. <pexpect.pxssh.pxssh object @ 0x7f051c060b00> command: /usr/bin/ssh args: ['/usr/bin/ssh', '-q', '-l', 'user', '192.168.10.14'] searcher: none buffer (last 100 chars): b'' before (last 100 chars): b'' after: <class 'pexpect.exceptions.eof'> match: none match_index: none exitstatus: none flag_eof: true pid: 29625 child_fd: 6 closed: false timeout: 30 delimiter: <class 'pexpect.exceptions.eof'> logfile: none logfile_read: none logfile_send: none maxread: 2000 ignorecase: false searchwindowsize: none delaybeforesend: 0.05 delayafterclose: 0.1 delayafterterminate: 0.1 

and relevant functions when error arises:

def ping(hostname):     response = os.system("ping -c 1 " + hostname +" >/dev/null")     if response == 0:         return("online")     else:         return("offline")  def login(self, hostname):     try:         s.login (hostname, username, password)     except pxssh.exceptionpxssh e:         print (str(e))         print("pxssh failed on login.")         return("pxssh failed on login.")  in domains:     print(a)     s = pxssh.pxssh()     if ping(a) == "online" , requestinfo().login(a) != "pxssh failed on login.":        do(things)     else:         print("rig ip "+a+" offline") 

hope enough information, don't know why if raises exception, not caught in try, except of login(a) , else statement of loop.

thanks in advance!


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -