Thank you both! This was more like a pre-app planning and testing ideas thing
I didn't know if there is a whoami type of command to location. So I checked the Utrack and quickly writed my own whereami-script.
Here is the code if someone needs it.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
def whereami():
print('Searching...')
latitude = ''
longitude = ''
for line in get_data():
if 'latitude' in line.decode("utf-8").lower():
latitude = line.decode("utf-8")
if 'longtide' in line.decode("utf-8").lower():
longitude = line.decode("utf-8")
if latitude and longitude:
print('Location:\n {}\n {}'.format(latitude, longitude))
break
def get_data():
cmd = "sudo test_gps"
gps_data = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
while True:
line = gps_data.stdout.readline().rstrip()
if not line:
break
yield line
if __name__=='__main__':
whereami()