예제 #1
0
파일: o2s.py 프로젝트: padelt/pista
    if g is not None:
        item['ghash'] = g.get('ghash')
        item['cc']    = g.get('cc', None)
        if 'addr' in g:
            event_desc = g.get('addr')
            item['addr'] = g.get('addr')
            addr = g.get('addr')
        print "%s %s %-2s %5d %s [%s] %s,%s" % (p_tstamp, g.get('cached', -1), tid, vel, addr, item.get('ghash'), item.get('lat'), item.get('lon'))
    else:
        print "  %-2s" % tid


    if storage:
        try:
            loca = Location(**item)
            loca.save()
        except Exception, e:
            log.error("Cannot INSERT location for {0} into DB: {1}".format(topic, str(e)))

        # Upsert last vehicle location into Lastloc
        try:
            ll = Lastloc.get(Lastloc.topic == topic)
            ll.tid     = item.get('tid')
            ll.lat     = item.get('lat')
            ll.lon     = item.get('lon')
            ll.tst     = item.get('tst')
            ll.vel     = item.get('vel')
            ll.alt     = item.get('alt')
            ll.cog     = item.get('cog')
            ll.trip    = item.get('trip')
            ll.dist    = item.get('dist')
예제 #2
0
        item['ghash'] = g.get('ghash')
        item['cc'] = g.get('cc', None)
        if 'addr' in g:
            event_desc = g.get('addr')
            item['addr'] = g.get('addr')
            addr = g.get('addr')
        print "%s %s %-2s %5d %s [%s] %s,%s" % (p_tstamp, g.get(
            'cached', -1), tid, vel, addr, item.get('ghash'), item.get('lat'),
                                                item.get('lon'))
    else:
        print "  %-2s" % tid

    if storage:
        try:
            loca = Location(**item)
            loca.save()
        except Exception, e:
            log.error("Cannot INSERT location for {0} into DB: {1}".format(
                topic, str(e)))

        # Upsert last vehicle location into Lastloc
        try:
            ll = Lastloc.get(Lastloc.topic == topic)
            ll.tid = item.get('tid')
            ll.lat = item.get('lat')
            ll.lon = item.get('lon')
            ll.tst = item.get('tst')
            ll.vel = item.get('vel')
            ll.alt = item.get('alt')
            ll.cog = item.get('cog')
            ll.trip = item.get('trip')