Removed some reduntand (old) code.
The replacement is in the while statement.
This commit is contained in:
parent
3e5b77ee8d
commit
8eeedab529
5
main.py
5
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 <command>
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue