Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get iPhone Location
#1
Hello everybody,

I'm trying to write a script that first checks some ips of mine (phone, pc, etc.) which are stored in a json file to "confirm" that I'm home. If one ip is online (indicating that I'm home) it should do something (#DoSomething1). If no ip is online it should check for my iphone location (#CheckiPhoneLocation) and this is the point where i struggle. Does someone know a way to check an iPhone location? Maybe there is an FindMyiPhone-API or one by a third party?

#!/usr/bin/env python3

#Imports
from subprocess import call, DEVNULL
import platform
import json
import sys

#Host Configuration
with open("/home/pi/system/index/alphaClients.json") as f1:
    data1 = json.load(f1)

with open("/home/pi/system/index/externClients.json") as f2:
    data2 = json.load(f2)

#IP Configuration
responding_alphaHosts = 0
responding_externalHosts = 0

#Pinp Configuration
def ping(host_or_ip: str) -> bool :
    if platform.system().lower() == "windows":
        countoption = "/n"
    else:
        countoption = "-c"
    return not call(["ping", countoption, "1", host_or_ip],
                    stdout=DEVNULL, stderr=DEVNULL)

#Host Check
for i in data1:
    if ping(i["ip"]):
        responding_alphaHosts += 1

for i in data2:
    if ping(i["ip"]):
        responding_externalHosts += 1

#ToDo
if responding_alphaHosts > 0 :
    if responding_externalHosts == 0:
        #DoSomething1
else:
    #CheckForiPhoneLocation
        if iPhoneLocation is xyz:
            #DoSomething1
        else:
            #DoSomething2
#End
sys.exit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ODBC iPhone to PC KipCarter 0 1,512 Feb-19-2020, 11:53 AM
Last Post: KipCarter
  game not working on safari browser on iphone/ipad marcush929 1 1,888 Jan-01-2020, 02:39 PM
Last Post: ichabod801
  Pythonista script with iPhone's native Clock app Sharkman157 0 2,605 Sep-27-2018, 05:23 PM
Last Post: Sharkman157

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020