Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: akkana/netutils
base: 8fe877425a
...
head fork: akkana/netutils
compare: 3df50d098e
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 18 additions and 4 deletions.
  1. +10 −3 netscheme
  2. +8 −1 netutils.py
View
13 netscheme
@@ -289,8 +289,10 @@ psk="%s"
# Are we on debian?
is_deb = is_debian()
if is_deb :
+ print "Using Debian-style networking"
self.set_scheme_debian(iface, add)
else :
+ print "Using standard (non-Debian) network commands"
self.set_scheme_manual(iface, add)
# Either way, update resolv.conf if applicable
@@ -371,9 +373,14 @@ psk="%s"
# #print >>fp, "post-up chattr -i /etc/resolv.conf"
def is_debian() :
- # Ubuntu 12.04 Precise Pangolin has broken Debian-style networking,
- # so check whether we're running it:
- #return False
+ # Lately, Debian networking has become so flaky and unmaintained
+ # that even though the standard networking commands sometimes
+ # don't work right on Debian/Ubuntu systems, they're still
+ # a better bet. The problem was first on Ubuntu 12.04 Precise Pangolin
+ # but with recent updates I'm even having problems on Debian Squeeze.
+ # So just forget about it unless someone decides to go back
+ # to maintaining it.
+ return False
try :
lsb = open("/etc/lsb-release")
is_ubuntu = False
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) :

No commit comments for this range

Something went wrong with that request. Please try again.