PEP8 the rest of the file

This commit is contained in:
2013-07-14 14:50:04 -04:00
parent ce7a103066
commit 93c407a9e3
2 changed files with 49 additions and 43 deletions
+12 -6
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# Monitor Interfaces, send hb msg when add changes # Monitor Interfaces, send hb msg when add changes
import time, os, sys import time
import os
SLEEP = 60 SLEEP = 60
SRV = "colo2.wapanafa.org" SRV = "colo2.wapanafa.org"
@@ -15,13 +16,15 @@ f=os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
for l in f.readlines(): for l in f.readlines():
if len(l) > 1 and not l[0] in [' ', '\t']: if len(l) > 1 and not l[0] in [' ', '\t']:
r = l.split() r = l.split()
if DBG: print r if DBG:
print r
if r[0][-1] == ':': if r[0][-1] == ':':
r[0] = r[0][:-1] r[0] = r[0][:-1]
if r[0][:2] == 'lo': if r[0][:2] == 'lo':
continue continue
IFS.append(r[0]) IFS.append(r[0])
if DBG: print IFS if DBG:
print IFS
addrs = {} addrs = {}
for I in IFS: for I in IFS:
addrs[I] = "" addrs[I] = ""
@@ -33,7 +36,8 @@ while 1:
ifaddrs = [] ifaddrs = []
for l in f.readlines(): for l in f.readlines():
r = l.split() r = l.split()
if DBG > 1: print "x2", r if DBG > 1:
print "x2", r
if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'): if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
continue continue
if r[1].find('addr:') == 0: if r[1].find('addr:') == 0:
@@ -44,8 +48,10 @@ while 1:
if ifaddrs != [] and ifaddrs != addrs[I]: if ifaddrs != [] and ifaddrs != addrs[I]:
msg = '%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV) msg = '%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
if DBG: print msg if DBG:
else: os.system(msg) print msg
else:
os.system(msg)
addrs[I] = ifaddrs addrs[I] = ifaddrs
f.close() f.close()