bat-serjo / PyIface

Python module to control network interfaces.
GNU General Public License v3.0
21 stars 10 forks source link

Can't make Interface instance #15

Closed chaebh closed 6 years ago

chaebh commented 6 years ago
>>> import pyiface
>>> ff = pyiface.Interface(name='eth0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyiface/iface.py", line 186, in __init__
    self._index = self.index
  File "/usr/local/lib/python2.7/dist-packages/pyiface/iface.py", line 233, in index
    self.__doIoctl(ifr, SIOCGIFINDEX)
  File "/usr/local/lib/python2.7/dist-packages/pyiface/iface.py", line 195, in __doIoctl
    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) as skt:
AttributeError: __exit__
>>> exit()
> # pip list | grep pyiface
> pyiface                  0.0.9

I tried to make the instance pyiface.interface but it was NOT made. When I use this module in version 0.0.7, it have worked.

alexvasiu commented 6 years ago

@chaebh What Linux do you use?

On Arch Linux works

chaebh commented 6 years ago
# uname -a
Linux dzytest001 4.15.0-24-generic #26~16.04.1-Ubuntu SMP Fri Jun 15 14:35:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
alexvasiu commented 6 years ago

python version? I assuming it's python2 because I was able to reproduce now on Arch using python 2.7.15, but with python 3.6.6 worked ... I'll investigate now that problem. Thanks for reporting

alexvasiu commented 6 years ago

@yegorich Your change from #13 affects this because python 2 implementation for socket doesn't have __exit__ @chaebh I fixed it here in #17

chaebh commented 6 years ago

I think it is different the version of python. My project's python version is 2.7. Thanks for your support.

alexvasiu commented 6 years ago

@bat-serjo please close this as Fixed