Skip to content

Commit

Permalink
Merge pull request #6 from icgc-dcc/fix/ip_address
Browse files Browse the repository at this point in the history
tested, works on both mac and ubuntu 16.04
  • Loading branch information
junjun-zhang authored May 14, 2017
2 parents 2b017a9 + 1d80216 commit 60f2f42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jtracker/jtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ def _init_host_id(self):

def _init_host_ip(self):
try:
self._host_ip = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0]
self._host_ip = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1][0]
except:
self._host_ip = '127.0.0.1'
try:
self._host_ip = [(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]
except:
self._host_ip = '127.0.0.1'

@staticmethod
def _find_file(name, path):
Expand Down

0 comments on commit 60f2f42

Please sign in to comment.