Skip to content

Commit 87a34f4

Browse files
committed
Get "hostname.local" if "hostname" ip not found
1 parent fb87f25 commit 87a34f4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
238 Bytes
Binary file not shown.

main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class MainScreen(Screen):
3232
def __init__(self, **kwargs):
3333
super(MainScreen, self).__init__(**kwargs)
3434

35-
ip = socket.gethostbyname(socket.gethostname())
35+
try:
36+
ip = socket.gethostbyname(socket.gethostname())
37+
except socket.gaierror:
38+
ip = socket.gethostbyname(socket.gethostname() + '.local')
39+
3640
if ip.startswith('127.'):
3741
interfaces = ['eth0', 'eth1', 'eth2', 'wlan0', 'wlan1', 'wifi0',
3842
'tiwlan0', 'tiwlan1', 'ath0', 'ath1', 'ppp0']

0 commit comments

Comments
 (0)