SSHLibrary icon indicating copy to clipboard operation
SSHLibrary copied to clipboard

AbstractSSHClient login is crashing, if keep_alive_interval is not given as argument

Open Thonuck opened this issue 4 years ago • 3 comments

If you call the login and no keep_alive_interval, then the keep_alive_inteval is set to None, with this the following line will not work:

(line 203) keep_alive_interval = int(TimeEntry(keep_alive_interval).value)

Thonuck avatar Nov 18 '21 14:11 Thonuck

Hello @Thonuck ! Thank you for opening an issue. Unfortunately, I was not able to replicate the issue as keep_alive_interval is correctly assigned to 0 given the default 0 seconds parameter. Might I ask if you were checking the value of the variable with the Evaluate Expression... feature offered by the JetBrains suite? Evaluating an assignment expression always results in a {NoneType} None. But by dessasembling the code at that specific line, we can see that the variable is correctly assigned the value 0 as illustrated in the photo below.

Thank you kindly for your involvement and please let me know if I misunderstood your problem. image

URunDEAD avatar Jan 05 '22 11:01 URunDEAD

Sorry, I did not see your reply earlier. Here is my more detailed findings:

If you look at the login function of the AbstractSSHClient, you have:

    def login(self, username=None, password=None, allow_agent=False, look_for_keys=False, delay=None, proxy_cmd=None,
              read_config=False, jumphost_connection=None, keep_alive_interval=None):

where keep_alive_interval is set by default to None The first line of the login function is

        keep_alive_interval = int(TimeEntry(keep_alive_interval).value)

which is then conform with

        keep_alive_interval = int(TimeEntry(None).value)

But this leads to TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

So this will always run in a TypeError, if the value is not given here.

I just checked it like this: image

Unfortunately, I'm not able to reproduce the use case right now, that this situation occurred.

But maybe setting in general the default value for keep_alive_interval to 0 in the argument list of "login" avoids this situation to occur again.

Thonuck avatar Feb 14 '22 15:02 Thonuck

Hi, @Thonuck! While what you showed in the picture is true, I have not been able to come up with a scenario where that would happen, because the default value for keep_alive_interval should be '0 seconds' as shown in the image below:

image

That being said, I do consider that there isn't any reason why keep_alive_interval should not be a valid value in the other function definitions, and such I have made a pull request with the specified changes #408 .

Thank you for your cooperation and involvement!

URunDEAD avatar Feb 21 '22 17:02 URunDEAD