alessandromaggio / pythonping

A simple way to ping in Python
MIT License
195 stars 73 forks source link

Cisco Like output #9

Open p3rtinax opened 5 years ago

p3rtinax commented 5 years ago

Dear Alessandro, Very useful code, Following you from https://www.ictshore.com/python/python-ping-tutorial When you gonna make it, or add Cisco like output flag to it? It will be very more advanced if you add Cisco like output option, I look forward to it

Thank you

alessandromaggio commented 5 years ago

Hello p3rtinax,

I'd really love to add the Cisco output on pythonping ASAP! Sadly, as I am busy on other projects, this won't happen soon. However, I would love to get other people on board on this project, so if you feel like contributing I'll try to write down some more specific requirements and you can fork me. I'll do my best to be available for any help or question!

Let me know what you think, And many thanks!

ecdestro commented 1 year ago

Sorry to bump an old issue, but I'm looking for my first open source project to contribute to, and github's recommended projects listed this one. So, hello!

Is there a good documentation on what the Cisco-like output should look like? Maybe I can take a look at this issue. I don't have really any Cisco terminal experience, but I'm feeling better about my Python experience lately, so let me know if there's anything I can pick up or start learning about.

alessandromaggio commented 1 year ago

@ecdestro, thanks for reaching out! In short, the Cisco output is a series of characters that represent the status of the ping. They appear on screen on the same line as soon as we get a result for the ping (either response, timeout, or something else). The line is truncated at 80 characters, so that if you have more than 80 pings they will go onto the next line.

You should read the full reference here: https://www.cisco.com/c/en/us/support/docs/ios-nx-os-software/ios-software-releases-121-mainline/12778-ping-traceroute.html

This output is great because it is quicker to understand if you are troubleshooting and do not really care about milliseconds for each packet. Furthermore, as this library is used extensively by network engineers, Cisco-like format is something they are well accustomed to.

AleksaZatezalo commented 1 year ago

Hey @alessandromaggio

Can I take a crack at this issue if it's still open? We have a long weekend in my region this Friday. I want to get started with my first open source contribution... Formatting output should not be to big of an issue :+1:

ecdestro commented 1 year ago

Hey @alessandromaggio

Can I take a crack at this issue if it's still open? We have a long weekend in my region this Friday. I want to get started with my first open source contribution... Formatting output should not be to big of an issue 👍

Sounds great to me! I'm excited to see this in action

alessandromaggio commented 1 year ago

Hey @alessandromaggio

Can I take a crack at this issue if it's still open? We have a long weekend in my region this Friday. I want to get started with my first open source contribution... Formatting output should not be to big of an issue 👍

@AleksaZatezalo I think @ecdestro was the first one to spot this issue so he should work on that. You mentioned documentation in another thread. True, we are good on documentation in the code but the README.md is pretty basic and does not fully explain the logic within the application itself. You may work on that, or extent tests to reach 100% coverage (which would be amazing to have a more reliable app).

ecdestro commented 1 year ago

Also getting used to contributing on github, so please pardon my ignorance.

I've created a preliminary function in executor.py to just try some outputs:

class Response:
    ...
    def cisco_repr(self):
        if self.message is None:
            return "."
        elif self.success:
            return "!"
        else:
            return "U"

And have implemented out_format='cisco'

class Response:
    ...
    def __repr__(self):
        ...
        elif self.repr_format == 'cisco':
            return self.cisco_repr()

So I can get outputs of !, ., and U, but currently they are on individual lines. I'm curious about formatting the output to print the info line, then the symbol output line, then the stats line like Cisco's example:

Sending 5, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/8 ms

I'm searching through the code to find the print statements looped through the count of pings, or the function that outputs results but I kinda end up chasing my own tail lol. I think it's in Response, or something that calls Response and iterates through it.

This is my first time really looking at someone else's code in an environment like this, so again I apologize for my ignorance. If you can point me in the right direction of how to control output messages, I think I have a handle on how to format this Cisco-like output for each message case, I just wanted to see what it might currently look like.

EDIT: I feel like it's somewhere within the append call or the Repeat object, but I don't know which one is telling the responses to enter a newline character.

AleksaZatezalo commented 1 year ago

Hey @alessandromaggio

Thank you!

I will work on the README and help implement test cases :)

Kind Regards, Aleksa

batman004 commented 1 year ago

Hi @alessandromaggio, is this issue still up for grabs?

alessandromaggio commented 1 year ago

Hey folks sorry for late reply.

So, @ecdestro you are on the right path for this, you need to represent the individual response as you are alredy doing. However, in the ResponseList we need to make some tweaks because if we just iterate through responses and print them it wil be in individual lines as you said. So we need to fetch the string value from the response. Then, it is just a matter of printing on the same line as we go, using end="" in the native print() function.

@batman004 feel free to join @ecdestro to work on this.

batman004 commented 1 year ago

Sure @alessandromaggio, thanks

estaji commented 1 year ago

Hello dear @alessandromaggio , I am a newbie in Open Source. May I contribute to this issue?

FahadYameen commented 1 year ago

Hi @alessandromaggio, I was looking to my first open source contribution and found this issue. Is this still an issue and if no one is working on this so can I start working on this issue? I will appreciate your response in this regard. Thanks.

estaji commented 1 year ago

Hi dear @FahadYameen , I added a commit for this issue , but dear @alessandromaggio has not seen my commit yet. I worked on this issue. you can find and review my commit here #101

ecdestro commented 1 year ago

Sorry for the delay, life has gotten in the way of me working on this, I might have to pull back if someone else has a clearer idea of how to do this, I bow to your expertise.

FahadYameen commented 1 year ago

Hi @estaji, your changes LGTM. Thanks for the update 👍