pastefile1
import logging
import time
import urllib.request
import gi
gi.require_version('Geoclue', '2.0')
from gi.repository import Geoclue
def get_location():
#relevant context https://howtotrainyourrobot.com/building-a-mobile-app-for-linux-part-4-gps-mobile-tracking/
precision = Geoclue.AccuracyLevel.EXACT # NEIGHBORHOOD
clue = Geoclue.Simple.new_sync(USERAGENT, precision, None)
location = clue.get_location()
return (location.get_property('latitude'), location.get_property('longitude'))
def post_location(lat,lon):
base_url = "https://cloud.sspaeth.de"
name = "mobian"
timestamp = time.time()
url = URL.format(base_url, name, lat, lon, timestamp)
logging.warning(url)
urllib.request.urlopen(url)
if __name__ == '__main__':
lat, lon = get_location()
post_location(lat, lon)