2to3 and black

This commit is contained in:
2021-05-03 17:39:08 -04:00
parent e9c2ebf60e
commit 0d954937bb
+13 -13
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Monitor Interfaces, send hb msg when add changes
import time
@@ -8,23 +8,23 @@ SLEEP = 60
SRV = "colo2.wapanafa.org"
DBG = 0
home = os.environ.get('HOME', '/var/tmp')
home = os.environ.get("HOME", "/var/tmp")
HBC = "%s/bin/hbc" % home
IFS = []
f = os.popen('/sbin/ifconfig -a 2>/dev/null', 'r')
f = os.popen("/sbin/ifconfig -a 2>/dev/null", "r")
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()
if DBG:
print r
if r[0][-1] == ':':
print(r)
if r[0][-1] == ":":
r[0] = r[0][:-1]
if r[0][:2] == 'lo':
if r[0][:2] == "lo":
continue
IFS.append(r[0])
if DBG:
print IFS
print(IFS)
addrs = {}
for I in IFS:
addrs[I] = ""
@@ -32,15 +32,15 @@ for I in IFS:
while 1:
for I in IFS:
f = os.popen('/sbin/ifconfig %s 2>/dev/null' % I, 'r')
f = os.popen("/sbin/ifconfig %s 2>/dev/null" % I, "r")
ifaddrs = []
for l in f.readlines():
r = l.split()
if DBG > 1:
print "x2", r
if len(r) == 0 or (r[0] != 'inet' and r[0] != 'inet6'):
print("x2", r)
if len(r) == 0 or (r[0] != "inet" and r[0] != "inet6"):
continue
if r[1].find('addr:') == 0:
if r[1].find("addr:") == 0:
ifaddr = r[1][5:]
else:
ifaddr = r[1]
@@ -49,7 +49,7 @@ while 1:
if ifaddrs != [] and ifaddrs != addrs[I]:
msg = '%s -m "ifadd %s %s" %s' % (HBC, I, ",".join(ifaddrs), SRV)
if DBG:
print msg
print(msg)
else:
os.system(msg)
addrs[I] = ifaddrs