Skip to content

Commit 9812624

Browse files
committed
This commit fixes a new error that was introduced for the case when your
computer was not connected to the internet.
1 parent 685f6f3 commit 9812624

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

mkchromecast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
checkmktmp()
2323
writePidFile()
2424

25-
if cc.ip == '127.0.0.1' or None: # We verify the local IP.
25+
if cc.ip == '127.0.0.1': # We verify the local IP.
2626
print(colors.error('Your computer is not connected to any network'))
2727
terminate()
2828

mkchromecast/cast.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ def __init__(self): ## __init__ to call the self.ip
3636

3737
if self.platform == 'Linux':
3838
self.netifaces_ip()
39+
try:
40+
self.ip = self.discovered_ip
41+
except AttributeError:
42+
self.ip = '127.0.0.1'
3943
else:
4044
try:
4145
self.ip = socket.gethostbyname(socket.gethostname())
4246
if self.debug == True:
4347
print(':::cast::: sockets method', self.ip)
4448
except socket.gaierror:
4549
self.netifaces_ip()
50+
try:
51+
self.ip = self.discovered_ip
52+
except AttributeError:
53+
self.ip = '127.0.0.1'
4654

4755
def netifaces_ip(self):
4856
import netifaces
@@ -53,9 +61,9 @@ def netifaces_ip(self):
5361
iface = netifaces.ifaddresses(interface).get(netifaces.AF_INET)
5462
if iface != None and iface[0]['addr'] != '127.0.0.1':
5563
for e in iface:
56-
self.ip = str(e['addr'])
64+
self.discovered_ip = str(e['addr'])
5765
if self.debug == True:
58-
print(':::cast::: netifaces method', self.ip)
66+
print(':::cast::: netifaces method', self.discovered_ip)
5967

6068
def initialize_cast(self):
6169
import mkchromecast.__init__ # This is to verify against some needed variables

0 commit comments

Comments
 (0)