Fix display of offline devices

This commit is contained in:
Kumi 2019-03-08 15:33:20 +00:00
parent 745fa3aa02
commit 8123042305

View file

@ -110,8 +110,9 @@ def ping(request, device_id):
ajax += "-3"
else:
try:
ajax += str(1 if (device.curip and not os.WEXITSTATUS(os.system("ping -c1 -w1 " + device.curip + " > /dev/null 2>&1"))) else 2 if (True if not device.lasttime else (timezone.now() - device.lasttime).total_seconds() > 120) and (timezone.now() - device.lastbeat).total_seconds() < 60 else 0)
except:
ajax += str(1 if (device.curip and (timezone.now() - device.lasttime).total_seconds() < 300 and not os.WEXITSTATUS(os.system("ping -c1 -w1 " + device.curip + " > /dev/null 2>&1"))) else 2 if (True if not device.lasttime else (timezone.now() - device.lasttime).total_seconds() > 120) and (timezone.now() - device.lastbeat).total_seconds() < 60 else 0)
except Exception as e:
ajax += str(e)
ajax += "-4"
else:
ajax += ',\n "serial": "%s"' % device.serial