fixed flaky wifi check
This commit is contained in:
parent
dcee009f80
commit
589ff3417f
|
|
@ -29,29 +29,31 @@ def get_api_db():
|
||||||
# Request data from travelynx
|
# Request data from travelynx
|
||||||
def get_api_tl():
|
def get_api_tl():
|
||||||
global tripDataTl
|
global tripDataTl
|
||||||
tripDataTl_response = requests.get("https://travelynx.de/api/v1/status/[YOUR API TOKEN", timeout=5)
|
tripDataTl_response = requests.get("https://travelynx.de/api/v1/status/[YOUR API TOKEN]", timeout=5)
|
||||||
tripDataTl = tripDataTl_response.json()
|
tripDataTl = tripDataTl_response.json()
|
||||||
|
|
||||||
|
|
||||||
# Look for the current SSID. Replace wlp2s0 with the real name of your wifi interface and check, that the path to iwlist is correct (just type 'which iwlist' in the terminal)
|
# Look for the current SSID. Replace wlp2s0 with the real name of your wifi interface and check, that the path to iwlist is correct (just type 'which iwlist' in the terminal)
|
||||||
def get_ssid():
|
def get_ssid():
|
||||||
|
try:
|
||||||
|
output = check_output(['/usr/sbin/iwgetid']).decode('utf-8')
|
||||||
|
ssid=output.split('"')[1]
|
||||||
|
return ssid
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
scanoutput = check_output(["/usr/sbin/iwlist", "wlp2s0", "scan"])
|
|
||||||
|
|
||||||
for line in scanoutput.split():
|
|
||||||
line = line.decode("utf-8")
|
|
||||||
if line[:5] == "ESSID":
|
|
||||||
ssid = line.split('"')[1]
|
|
||||||
return ssid
|
|
||||||
|
|
||||||
# Get Speed from ICE-Portal
|
# Get Speed from ICE-Portal
|
||||||
def get_speed_db():
|
def get_speed_db():
|
||||||
if statusData["speed"]==None:
|
try:
|
||||||
return "No Speed"
|
|
||||||
else:
|
|
||||||
speed= str(statusData["speed"])
|
speed= str(statusData["speed"])
|
||||||
|
if speed==None:
|
||||||
|
speed="No Speed"
|
||||||
return speed
|
return speed
|
||||||
|
|
||||||
|
except:
|
||||||
|
return "No Speed"
|
||||||
|
|
||||||
# Figure out, whats the next station and filter the output for this.
|
# Figure out, whats the next station and filter the output for this.
|
||||||
def get_next_db():
|
def get_next_db():
|
||||||
if tripData["trip"]["stopInfo"] == None :
|
if tripData["trip"]["stopInfo"] == None :
|
||||||
|
|
@ -78,6 +80,11 @@ def get_next_tl():
|
||||||
arrivalDelay="{:+.0f}".format(((uActualTime-uScheduledTime)/60))
|
arrivalDelay="{:+.0f}".format(((uActualTime-uScheduledTime)/60))
|
||||||
arrivalTime = datetime.fromtimestamp(uActualTime, tz=timezone).strftime('%H:%M')
|
arrivalTime = datetime.fromtimestamp(uActualTime, tz=timezone).strftime('%H:%M')
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
nextStationName=tripDataTl['toStation']['name']
|
||||||
|
arrivalTime=None
|
||||||
|
arrivalDelay=None
|
||||||
|
break
|
||||||
tripinfo = nextStationName+" "+arrivalTime+" ("+arrivalDelay+")"
|
tripinfo = nextStationName+" "+arrivalTime+" ("+arrivalDelay+")"
|
||||||
#tripinfo = nextStationName+" "+ arrivalTime+" ("+ arrivalDelay+") @ "+ nextStationTrack
|
#tripinfo = nextStationName+" "+ arrivalTime+" ("+ arrivalDelay+") @ "+ nextStationTrack
|
||||||
return tripinfo
|
return tripinfo
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue