forked from vmware-archive/retail-demo-xd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_data.py
executable file
·37 lines (30 loc) · 1.01 KB
/
send_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
import re
import shutil
import commands
import random
import json
import urllib2
def main():
for x in xrange(5000):
cust_id = str(x)
order_id = str(random.randrange(2000,10000))
order_amount = str('{:20.2f}'.format(random.uniform(100,10000))).strip()
state_id = str(random.randrange(1,52)).zfill(2)
city_id = str(random.randrange(1,99)).zfill(2)
if x % 101 == 0:
cust_id = "BAD_DATA"
#make california every x records
#if x % 3 == 0:
# state_id = "05"
store_id = state_id + city_id
num_items = str(random.randrange(1,50))
data = json.dumps({"customerId":cust_id,"orderId":order_id,"orderAmount":order_amount,"storeId":store_id,"numItems":num_items})
req = urllib2.Request("http://localhost:8000", data, {'Content-Type': 'application/json'})
print "POST URL:" + req.get_full_url()
print "POST DATA:" + req.data
f = urllib2.urlopen(req)
response = f.read()
f.close()
if __name__ == "__main__":
main()