romana / multi-ping

Python library to monitor one or many IP addresses via ICMP echo (ping) requests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError with 1.2.0 release on Windows

cleonello opened this issue · comments

Hi, the latest release (1.1.0) throws an error on Windows 7 under python 3.6.4 and under python 3.5.5. The previous release (1.0.7) does not. Here is the error when running the example code from the readme:

Traceback (most recent call last):
  File "pingtest.py", line 4, in <module>
    mp = MultiPing(["8.8.8.8", "youtube.com", "127.0.0.1"])
  File "C:\ProgramData\Miniconda3x86\envs\graphite\lib\site-packages\multiping\__init__.py", line 119, in __init__
    self._sock6 = self._open_icmp_socket(socket.AF_INET6)
  File "C:\ProgramData\Miniconda3x86\envs\graphite\lib\site-packages\multiping\__init__.py", line 130, in _open_icmp_socket
    else socket.IPPROTO_ICMPV6
AttributeError: module 'socket' has no attribute 'IPPROTO_ICMPV6'

Hi, I can confirm the same happens in Ubuntu Linux

Thank you for reporting this issue. I'll have a look at it.

Recently, IPv6 support was added to multi-ping. The issue seems to stem from that. The code works for me as is and the IPPROTO_ICMPV6 symbol is defined for me.

@cleonello and @geokal, since I can't reproduce it here, could you please help me out and run a small test for me? Could you please start a Python shell and import the socket module, then check one attribute value for me?

>>> import socket
>>> socket.has_ipv6

What output do you get?

@geokal, could you please also let me know what version of Ubuntu you are running?

Hi, @jbrendel in my Windows terminal the output of socket.has_ipv6 is equal to true. But again the result after running the python script located in the readme section:
is the same as @cleonello. I will report back on Ubuntu cause I don't have access right now. Thanks again!!

commented

Having the same issue on Windows 10 using python 3.5.2

>>> import socket
>>> socket.has_ipv6

returns True

Hi, I can confirm the same happens on Win 10 Python 3.6.5
socket.has_ipv6 returns True

This solves the issue:
Open ...\lib\site-packages\multiping_init_.py
Line 129 where IF starts and delete "if ..... " to the end of the line and the line 130.
image

@mametov's solution doesn't work for me under python 3.4.3 on Windows XP (nor does replacing socket.IPPROTO_ICMPV6 with the hardcoded value 58). What does work is to comment out the self._sock6... statements on lines 119 and 120 (effectively removing IPv6 from multiping).

Technically, this shouldn't be a problem, given that Microsoft says that IPPROTO_ICMPV6 should be available on Windows XP. Maybe this has something to do with this bug.

commented

Can confirm @mametov's workaround on win10 3.6.5, but still hoping for a real solution

Hello everyone. Thank you for continuing to follow up on this. My apologies for not checking back earlier.

I have just pushed what I believe is a patch for this. In effect, it checks whether the IPPROTO_ICMPV6 attribute is present in socket or not. And if not then it uses the hardcoded value of 58.

I tested this on Ubuntu 14.04, 16.04 and on Windows 10 and it works (no surprise on the Ubuntus, since they have that value available anyway).

I'm concerned about @geostar1024 report, though, since apparently you tried hardocding 58 and it did not work for you? I really don't know what to say to that. This, as patched right now, seems to work. At least with Python3 on Windows 10.

If everyone could give the current version a go, please, and let me know? I don't want to just close this issue without getting your feedback first.

Thank you again!

If this works for everyone, I will mark this issue as closed...

@jbrendel thanks a lot will check tomorrow!