GithubHelp home page GithubHelp logo

pyiface's People

Contributors

alexvasiu avatar bat-serjo avatar harisokanovic avatar marchon avatar petri avatar yegorich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyiface's Issues

Can't read out IP address

I can read out the interfaces but if I want to get the addr property I get an error message. Here is a minimal example in the python console:

>>> import pyiface
>>> pyiface.getIfaces()[0].addr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyiface/iface.py", line 291, in addr
    ifr = self.__newIfreqWithName()
  File "/usr/local/lib/python2.7/dist-packages/pyiface/iface.py", line 181, in __newIfreqWithName
    ifr.ifr_name = self._name
TypeError: expected c_ubyte_Array_16 instance, got str

Any thoughts on what is going on? :)
Thanks!

Does not work for Solaris 10/Sparc

Hi,
nice module, works as a charm for me on Linux. On Solaris I don't retrieve any of the machine's interfaces with pyiface.getIfaces().
Chances are that you don't have access to the Solaris platform, but just to let you and potential users know:

$ uname -a
SunOS dev001 5.10 Generic_137111-07 sun4u sparc SUNW,Sun-Fire-V490 Solaris
0 $ ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000 
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet xx.yy.32.85 netmask fffff000 broadcast xx.yy.47.255
qfe0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet xx.yy.48.85 netmask fffff000 broadcast xx.yy.63.255
0  $ python2.7 -i -c 'import pyiface'
>>> pyiface.getIfaces()
[]

I guess that's due to some various platform-specific intricacies. Unfortunately I can't currently look into this any more but the error that is raised from Interface.__doIoctl(...) is

>>> pyiface.getIfaces()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyiface/iface.py", line 388, in getIfaces
ifa = Interface(idx=i)
File "pyiface/iface.py", line 174, in __init__
self._name = self.name
File "pyiface/iface.py", line 227, in name
self.__doIoctl(ifr, SIOCGIFNAME)
File "pyiface/iface.py", line 191, in __doIoctl
raise ioException
IOError: [Errno 22] Invalid argument

(your actual code doesn't raise and suppresses the exception I just quick-and-dirty changed that to get an idea)

Would be great if your approach could work cross-platform (Windows?).

MAC address change references non-existent sin_addr

Thanks for the fantastic module!

I run into an issue when attempting to change the MAC address on an interface. Can you tell me about the code path you expected this to follow? I see that sockaddr_dl wasn't used. Is this functionality still pending?

Traceback (most recent call last):
File "", line 1, in
File "/root/ConfigApp/speedy/lib/python2.7/site-packages/pyiface/iface.py", line 295, in hwaddr
ifr.data.ifr_hwaddr.sin_addr.s_addr = val
AttributeError: 'sockaddr' object has no attribute 'sin_addr'

IPv6 is not supported

@bat-serjo IPv6 doesn't work

t.addr = (socket.AF_INET6, '2001:db8:0:0:0:ff00:42:8329')
  File "/workspace/PyIface/pyiface/iface.py", line 314, in addr
    ifr.data.ifr_addr = self.__sockaddrFromTuple(val)
  File "/workspace/PyIface/pyiface/iface.py", line 365, in __sockaddrFromTuple
    inVal[1]))
TypeError: expected in6_u instance, got bytes

Also If I try to get addr for an interface it never returns IPv6 address, only IPv4 or None

Can't make Interface instance

>>> 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.

documentation glitch

README has a little documentation glitch:

"

Get a specific interface by name

eth0 = PyIface.Interface('eth0')

"
but

>>> pyiface.Interface("eth0").name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyiface/iface.py", line 174, in __init__
self._name = self.name
File "pyiface/iface.py", line 226, in name
ifr.data.ifr_ifindex = self._index
TypeError: an integer is required
>>> 
>>> pyiface.Interface(name="eth0") # use named parameter
<pyiface.iface.Interface object at 0x7f510151dc50>
>>> pyiface.Interface(name="eth0").name
'eth0'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.