def get_localhost_ip():
    cmd = ['/sbin/ifconfig']
    eth_ip = {}
    try:
        r = exec_command(cmd)
    except:
        current_app.logger.error('[Dial Helpers]: exec_command error: %s:%s', cmd,
                                 sys.exc_info()[1])
        return False
    if r['return_code'] == 0:
        r_data = r['stdout'].split('\n')
        for index, line in enumerate(r_data):
            if line.startswith('inet addr:'):
                eth_ip[r_data[1-index].split()[0]] = line.split().split(':')[1]
    else:
        current_app.logger.error('[Dial Helpers]: exec_command return: %s:%s:%s', cmd,
                                 r['return_code'], r['stderr'])
        return False
    return eth_ip
dataset/ETHPy150Open alibaba/FlexGW/website/vpn/dial/helpers.py/get_localhost_ip/swapped operands of `-`