MCPcopy
hub / github.com/jipegit/OSXAuditor / GeomenaApiLocation

Function GeomenaApiLocation

osxauditor.py:899–926  ·  view source on GitHub ↗

Perform a geolocation query on Geomena

(Ssid)

Source from the content-addressed store, hash-verified

897 PrintAndLog(u'Log files aggregation FAILED ' + str(e.args).decode('utf-8'), 'ERROR')
898
899def GeomenaApiLocation(Ssid):
900 ''' Perform a geolocation query on Geomena'''
901
902 NormalizedSsid = ''
903 Latitude = 'Not found'
904 Longitude = 'Not found'
905
906 Ssid = Ssid.split(':')
907
908 for i in Ssid:
909 if len(i) == 1:
910 i = '0'+i
911 NormalizedSsid += i
912
913 PrintAndLog(u'Geomena query for ' + ''.join(NormalizedSsid), 'DEBUG')
914
915 try:
916 F = urllib2.urlopen(GEOMENA_API_HOST + NormalizedSsid)
917 Data = F.read()
918 except urllib2.HTTPError as e:
919 PrintAndLog(u'Geomena API error ' + str(e.code) + ' ' + str(e.reason).decode('utf-8'), 'ERROR')
920
921 M = re.match('.+\sLatitude:\s([-\d\.]{1,19})\s.+\sLongitude:\s([-\d\.]{1,19})\s.+', Data, re.DOTALL)
922 if M:
923 Latitude = M.group(1)
924 Longitude = M.group(2)
925
926 return u'Latitude: ' + Latitude + u' Longitude: ' + Longitude
927
928def ParseAirportPrefs():
929 ''' Parse Airport preferences and try to extract geolocation information '''

Callers 1

ParseAirportPrefsFunction · 0.85

Calls 1

PrintAndLogFunction · 0.85

Tested by

no test coverage detected