From 8eeedab52935b85b2451b6c1dedb35dec6d8749f Mon Sep 17 00:00:00 2001 From: rasmus Date: Tue, 22 Dec 2020 01:50:02 +0200 Subject: [PATCH] Removed some reduntand (old) code. The replacement is in the while statement. --- main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.py b/main.py index 5b5c3d5..5ff30c1 100644 --- a/main.py +++ b/main.py @@ -29,16 +29,13 @@ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Ignore host key REMO ssh.connect(hostname, username=sshuser, key_filename=sshkeylocation) # Attempt to connect channel = ssh.invoke_shell() # Get a new shell(, and keep it open, since we need to exec multiple commands depending on the last command being executed successfully.) -def ssh_runcmd(command): # ssh_runcmd +def ssh_runcmd(command): # Some abstraction to run ssh commands. # Input validation if not type(command) is str: raise TypeError("ssh_runcmd: command must be a string, '" + command + "' is not.") channel.send(command + '\n') # Execute command. - while not channel.recv_ready(): # Wait for output to be recieved. - sleep(0.5) # The command could still be writing to output buffer after running for 0.5s. Assuming during the period we read the buffer, cmd can keep up with us, or at least till the 8th KiB end. - cmdout = "" # Init lockedoutCounter = 0 # Init