set while loop every 10 minutes
This commit is contained in:
parent
3a10ed38cc
commit
6a9eedb7ba
1 changed files with 31 additions and 20 deletions
17
script.py
17
script.py
|
@ -71,9 +71,11 @@ cursor.execute("""
|
|||
)
|
||||
""")
|
||||
|
||||
# Standortdaten abrufen
|
||||
# Endlosschleife für die Abfrage alle 10 Minuten
|
||||
try:
|
||||
while True:
|
||||
# Standortdaten von Geräten abrufen
|
||||
devices = icloud.devices
|
||||
|
||||
for device in devices:
|
||||
location = device.location()
|
||||
if location:
|
||||
|
@ -91,7 +93,16 @@ for device in devices:
|
|||
VALUES (%s, %s, %s, %s)
|
||||
""", (device_name, latitude, longitude, timestamp))
|
||||
|
||||
# Änderungen speichern und Verbindung schließen
|
||||
# Änderungen speichern
|
||||
db.commit()
|
||||
|
||||
# 10 Minuten warten
|
||||
logging.info("Warten auf die nächste Abfrage in 10 Minuten...")
|
||||
time.sleep(600)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Skript manuell beendet.")
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
db.close()
|
||||
|
|
Loading…
Reference in a new issue