Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored May 11, 2022
1 parent 6f8aea5 commit 86d0034
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
}
},
"short_name": "Network pres",
"version": "1.3.9"
"version": "1.3.10"
}
23 changes: 14 additions & 9 deletions pkg/presence_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def __init__(self, verbose=False):
if not self.DEBUG:
time.sleep(5) # give it a few more seconds to make sure the network is up

self.selected_interface = "wlan0"
self.select_interface() # checks if the preference is possible.

if self.DEBUG:
Expand Down Expand Up @@ -1273,15 +1274,19 @@ def arpa(self):


def select_interface(self):
eth0_output = subprocess.check_output(['ifconfig', 'eth0']).decode('utf-8')
#print("eth0_output = " + str(eth0_output))
wlan0_output = subprocess.check_output(['ifconfig', 'wlan0']).decode('utf-8')
#print("wlan0_output = " + str(wlan0_output))
if "inet " in eth0_output and self.prefered_interface == "eth0":
self.selected_interface = "eth0"
if not "inet " in eth0_output and self.prefered_interface == "eth0":
self.selected_interface = "wlan0"
if "inet " in wlan0_output and self.prefered_interface == "wlan0":
try:
eth0_output = subprocess.check_output(['ifconfig', 'eth0']).decode('utf-8')
#print("eth0_output = " + str(eth0_output))
wlan0_output = subprocess.check_output(['ifconfig', 'wlan0']).decode('utf-8')
#print("wlan0_output = " + str(wlan0_output))
if "inet " in eth0_output and self.prefered_interface == "eth0":
self.selected_interface = "eth0"
if not "inet " in eth0_output and self.prefered_interface == "eth0":
self.selected_interface = "wlan0"
if "inet " in wlan0_output and self.prefered_interface == "wlan0":
self.selected_interface = "wlan0"
except Exception as ex:
print("Error in select_interface: " + str(ex))
self.selected_interface = "wlan0"


Expand Down

0 comments on commit 86d0034

Please sign in to comment.