Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Guard against No such file or directory in /sys/class/net/.../uevent …

…-- sometimes it mysteriously doesn't exist
  • Loading branch information...
commit 3df50d098e9f6f86dfcd040f138d7a3762a28ca9 1 parent 63f5c1d
@akkana authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 netutils.py
View
9 netutils.py
@@ -67,7 +67,13 @@ def __repr__(self) :
def reload(self) :
print "Calling reload"
- fp = open("/sys/class/net/" + self.name + "/device/uevent")
+ try :
+ # Sometimes the device doesn't exist. I have no idea why.
+ fp = open("/sys/class/net/" + self.name + "/device/uevent")
+ except :
+ print "Couldn't open device /sys/class/net/" + self.name
+ sys.exit(0)
+
# Another way to get this: ethtool -i self.name
line = fp.readline()
fp.close()
@@ -86,6 +92,7 @@ def ifconfig_down(self) :
"""Mark the interface DOWN with ifconfig"""
subprocess.call(["ifconfig", self.name, "down"])
self.reload()
+ subprocess.call(["ifconfig", "-a"])
class Connection :
def __init__(self, iface=None) :
Please sign in to comment.
Something went wrong with that request. Please try again.