alessandromaggio/pythonping

response.Success

pavants opened this issue · 7 comments

I get an error everytime I try to read the succcess value:
AttributeError: 'ResponseList' object has no attribute 'success'

ResponseList has attribute '_responses', which represents the list of Response objects, Response object has the 'success' property.

This is a good thing I actually would like to implement. In fact, as you can tell, _responses is not really meant to be used from outside the class.

I can try to make it. It is necessary to decide on behavior. Success true - if at least one of the list success or other logic.

I would say can go with three options, which translate into three constants:

  • SUCCESS_ON_ONE (1 request is enough to be successful)
  • SUCCESS_ON_MOST (conservative, success on more than 50%)
  • SUCCESS_ON_ALL (100%)

We set the value of a property, let's say success_behaviour or whatever to one of these constants, and based on that the success property behaves differently.

I would say that SUCCESS_ON_ONE should be the default. I believe that most people use this library just to check the availability of a node. Checking network stability to connect to that node is something more advanced, and the users who wish to do so can afford to change a parameter.

If you have something different in mind let me know

Vote Alessandro proposal, is exactly what I had in mind.
One packet in a LAN environment is enough to see if it is online.

Thanks

I added the tests - implemented in release v1.0.5, already out and installable.
Closing the issue, thanks to @EzR1d3r!

How can i use the error_message?
when i do:
r_list=ping(ip_addr)
print(r_list.error_message)
it says no error_message attribute