thombashi / pingparsing

pingparsing is a CLI-tool/Python-library parser and transmitter for ping command :arrow_right_hook:
https://pingparsing.rtfd.io/
MIT License
78 stars 10 forks source link

Attribute Error #25

Closed L1ghtn1ng closed 7 years ago

L1ghtn1ng commented 7 years ago
  File "/usr/lib/python3.6/site-packages/pingparsing/_pingparsing.py", line 198,            in parse
    self.__parse_linux_ping(ping_message)
  File "/usr/lib/python3.6/site-packages/pingparsing/_pingparsing.py", line 266,            in __parse_linux_ping
    line_list = _to_unicode(ping_message).splitlines()
AttributeError: 'PingResult' object has no attribute 'splitlines'

Running 8.0 of pingparsing and getting the above error on archlinux with python 3.6

thombashi commented 7 years ago

Thank you for your report.

I guess you had passing ping method result to parse method like following:

def main():
    ping_parser = pingparsing.PingParsing()
    transmitter = pingparsing.PingTransmitter()
    transmitter.destination_host = "8.8.8.8"
    transmitter.waittime = 10
    result = transmitter.ping()
    ping_parser.parse(result)

I could reproduce the problem by this code. In that case, you could easily fix the code.

def main():
    ping_parser = pingparsing.PingParsing()
    transmitter = pingparsing.PingTransmitter()
    transmitter.destination_host = "8.8.8.8"
    transmitter.waittime = 10
    result = transmitter.ping()
    ping_parser.parse(result.stdout)  # modified line
L1ghtn1ng commented 7 years ago

Think so will need to double check it when I get to work on Monday but it does from me testing your way does work and would be nice to have a changelog saying that there was a breaking change and how to fix it in release notes. Also your python version bage is broken in the readme and the the docs

thombashi commented 7 years ago

You're absolutely right.

I've change to accept for both ping_parser.parse(result) and ping_parser.parse(result.stdout) at pingparsing 0.8.2. You do not need to change the source code if you upgrade the package.

your python version bage is broken in the readme and the the docs

Looks like pingparsing PyPI page (python version badge source) always corrupt when I publish the package from Travis CI, I'm not sure how to fix that right now.

L1ghtn1ng commented 7 years ago

Yes I did have the code as that and have upgraded to 8.2 and my script now works

Sent from phone


From: Tsuyoshi Hombashi notifications@github.com Sent: Sunday, June 11, 2017 12:28:11 AM To: thombashi/pingparsing Cc: J.Townsend; Author Subject: Re: [thombashi/pingparsing] Attribute Error (#25)

Thank you for your report.

I guess you had passing ping method result to parse method like following:

def main(): ping_parser = pingparsing.PingParsing() transmitter = pingparsing.PingTransmitter() transmitter.destination_host = "8.8.8.8" transmitter.waittime = 10 result = transmitter.ping() ping_parser.parse(result)

I could reproduce the problem by this code. In that case, you could easily fix the code.

def main(): ping_parser = pingparsing.PingParsing() transmitter = pingparsing.PingTransmitter() transmitter.destination_host = "8.8.8.8" transmitter.waittime = 10 result = transmitter.ping() ping_parser.parse(result.stdout) # modified line

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/thombashi/pingparsing/issues/25#issuecomment-307596077, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADddQiOS4XKeiUY1qfI3wABr_cj7DIO5ks5sCyaLgaJpZM4N2PKz.

thombashi commented 7 years ago

Thank you for sharing. I'm glad that works for you.

Then, I'll close the issue.