Advertisement
Guest User

Untitled

a guest
May 18th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import requests
  2. from time import gmtime, strftime, sleep
  3. import random
  4.  
  5. def main():
  6. i = 0
  7. while i < 10000:
  8. r = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
  9. data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  10. "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  11. "result": random.uniform(0.0, 50.0),
  12. "Datastream": {"@iot.id": 1},
  13. "FeatureOfInterest": {"@iot.id": 1 } })
  14.  
  15. r2 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
  16. data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  17. "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  18. "result": random.uniform(1000, 1000000),
  19. "Datastream": {"@iot.id": 2},
  20. "FeatureOfInterest": {"@iot.id": 1 } })
  21.  
  22. r3 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
  23. data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  24. "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  25. "result": random.uniform(1000, 100000),
  26. "Datastream": {"@iot.id": 3},
  27. "FeatureOfInterest": {"@iot.id": 1 } })
  28.  
  29. r4 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
  30. data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  31. "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  32. "result": random.uniform(800, 1050),
  33. "Datastream": {"@iot.id": 4},
  34. "FeatureOfInterest": {"@iot.id": 1 } })
  35.  
  36. r5 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
  37. data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  38. "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
  39. "result": random.uniform(30, 100),
  40. "Datastream": {"@iot.id": 5},
  41. "FeatureOfInterest": {"@iot.id": 1 } })
  42.  
  43. print(r.status_code)
  44. print(r2.status_code)
  45. print(r3.status_code)
  46. print(r4.status_code)
  47. print(r5.status_code)
  48.  
  49. sleep(2)
  50.  
  51. i += 1
  52.  
  53. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement