Tracking large metallic objects using App Engine and Latitude Kelvin Nicholson
Jul 09, 2015
Tracking large metallic objects using App Engine and Latitude
Kelvin Nicholson
Creative Opportunities Abound
Python
An idea is born
+ +
General Workflow
HTTP Post over 3G
Parse POST Data (XML)
Verify Location in NSW
Get OAuth Credentials for “user”
Post Location to Latitude API
General Workflow 2
class RawXml(db.Model): # storage model for raw GPS data
content = db.TextProperty()
class MainHandler(webapp.RequestHandler): # do stuff
def get(self):
self.response.out.write('OK')
def post(self):
content = self.request.body
rawXmlObject = RawXml(content = str(content))
rawXmlObject.put()
General Workflow 2
<gpsid=“metalObject"><coordinates><coordinate><fix>3D</fix><time>0</time><latitude>-33.867275</latitude><longitude>151.206964</longitude><altitude>80.000000</altitude><climb>0.000000</climb><speed>25.000000</speed><separation>0.000000</separation><track>0.000000</track><satellites>8</satellites></coordinate></coordinates></gps>
General Workflow 3
OAuth Issues
• Most issues occurred after adding 2nd “object”
• Like forgetting to create the OAuth token
• Or incorrectly storing credentials (one StorageByKeyName name, two credentials, doesn’t work)
• And forgetting to enable the Latitude API
• And this: Failed to retrieve access token: { "error" : "invalid_grant" }
Metallic Object Map
Lessons Learned
• OAuth is sometimes like a nightmare
– Understand the different OAuth scenarios
• Always use the latest library
• AppEngine Quota limit - small writes to datastore are a killer
• Adding a second Object feed broke everything
• This little hack actually came in useful
• But… Python was always fun!
Thank You
• Questions?