From 031b6ca7cd7944e1d51ace169013cec4f54b5543 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 7 Jan 2016 17:33:18 +0530 Subject: [PATCH] add socket base ip lookup --- oml/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/oml/utils.py b/oml/utils.py index 5fed8e0..7e4c39f 100644 --- a/oml/utils.py +++ b/oml/utils.py @@ -286,6 +286,13 @@ def get_local_ipv4(): local_ip = re.compile('inet (\d+\.\d+\.\d+.\d+)').findall(local_ip[0]) if local_ip: ip = local_ip[0] + if not ip: + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect(("8.8.8.8", 53)) + return s.getsockname()[0] + except: + pass return ip def update_dict(root, data):