Advertisement
lukibeni

Untitled

Oct 28th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import android
  2. import datetime
  3. import time
  4.  
  5. droid = android.Android()
  6.  
  7. def saveLastScan():
  8. date = int(time.time())
  9. droid.prefPutValue("smsLastScan", date, "datestamp")
  10. return date
  11.  
  12. def getLastScan():
  13. date = droid.prefGetValue("smsLastScan", "datestamp")
  14. if (date.result == None):
  15. date2 = int(time.mktime(datetime.datetime(2000, 1, 1).timetuple()))
  16. return date2
  17. else:
  18. return date.result
  19.  
  20. def warehouseStringToDict(b):
  21. a = b.split(";")
  22. if len(a) != 5 :
  23. return None
  24. if a[0] != "WarehouseData":
  25. return None
  26. if (a[1].isdigit() == False):
  27. return None
  28. try:
  29. float(a[3])
  30. float(a[4])
  31. except ValueError:
  32. return None
  33. asd = {"id" : a[1]}
  34. asd["name"] = a[2]
  35. asd["lat"] = a[3]
  36. asd["lon"] = a[4]
  37. return asd
  38.  
  39. def scanMessages(lastScanInteger):
  40. sms = droid.smsGetMessages(False)
  41. print sms
  42. for i in sms.result:
  43. if (int(i["date"]) < lastScanInteger):
  44. malls.append(warehouseStringToDict(i["body"]))
  45.  
  46. malls = [{"id":"1","name":"Helyi ABC", "lat":47.680507, "long":18.769890000000032},
  47. {"id":"2","name":"Metro", "lat":47.68005300000001, "long":18.76808099999994},
  48. {"id":"3","name":"Kocsma", "lat":47.681642, "long":18.769948500000055}]
  49.  
  50. scanMessages(123)
  51. #last = getLastScan()
  52. #scanMessages(saveLastScan())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement