INNER CODE UNIT · Python
get_server_iface_ip
ab77/netflix-proxy · auth/auth.py:78
def get_server_iface_ip():
iface = get_iface()
cmd = """ip addr show dev %s | \
grep inet | \
grep -v inet6 | \
awk '{print $2}' | \
grep -Po '[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+(?=\/)'""" % iface
web.debug('DEBUG: getting ipaddr from iface=%s cmd=%s' % (iface, cmd))
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
output, err = p.communicate()
rc = p.returncode
web.debug('DEBUG: get_server_iface_ip()=%s' % [rc, err, output])
if rc == 0:
try:
ipaddr = output[0].rstrip().decode()
except:
ipaddr = output[0].rstrip()