Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. def notifyLure(id,lat,lng,exptime):
  2.         timeLeft = exptime-datetime.utcnow()
  3.         cet = timezone('Europe/Budapest')
  4.         cet_time = datetime.now(cet)
  5.         currentTime = cet_time.strftime('%Y.%m.%d. %H:%M:%S')
  6.         latLon = '{},{}'.format(repr(lat), repr(lng))
  7.         gMapsUrl = 'http://maps.google.com/maps/place/{}/@{},{}z'.format(latLon, latLon, 18)
  8.         floatLat = float(lat)
  9.         floatLong = float(lng)
  10.         g = geocoder.google([floatLat, floatLong], method='reverse')
  11.         print("NOTIFYLURE: ID: %s\nCoord: (%f,%f)\n TimeLeft: %s" % (
  12.                 id,lat,lng,str(timeLeft)))
  13.         if id in lures:
  14.             print("ALREADY SEEN LURE")
  15.             return
  16.         else:
  17.             lures.append(id)
  18.         doPrint = True
  19.         if doPrint:
  20.             p = PushBullet(apiKey)
  21.             # Get a list of devices
  22.             devices = p.getDevices()
  23.             # Get a list of contacts
  24.             contacts = p.getContacts()
  25.             # Send a note
  26.             #p.pushNote(devices[0]["iden"],"Found Lure: Coord: (%f,%f)" % (
  27.             #    lat,lng), "Coord: (%f,%f)\n TimeLeft: %s" % (
  28.             #    lat,lng,str(timeLeft)))
  29.             p.pushNote(devices[0]["iden"],"Lure - %s, %s %s" % (
  30.                 g.city,g.street,g.housenumber), "CurrentTime: %s\nTimeLeft: %s\nGoogleMaps: %s" % (
  31.                 currentTime,str(timeLeft).split('.')[0],gMapsUrl))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement