aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-06-28 22:52:08 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-06-28 22:52:08 -0700
commitfb886b6100493019ece6a9c53bd55280525efe2e (patch)
treedb384596ccaca8784ed8730527d4411fb266965c
parentcd2f5a5a65e9f5068995831277c37b45df2a20f4 (diff)
downloadtrackermap-server-fb886b6100493019ece6a9c53bd55280525efe2e.tar.gz
trackermap-server-fb886b6100493019ece6a9c53bd55280525efe2e.tar.bz2
trackermap-server-fb886b6100493019ece6a9c53bd55280525efe2e.zip
Update map testing script
-rwxr-xr-xtools/test-map.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/test-map.py b/tools/test-map.py
index 0568b283e..c289df605 100755
--- a/tools/test-map.py
+++ b/tools/test-map.py
@@ -3,6 +3,7 @@
import urllib
import urllib2
import httplib
+import time
import random
import json
@@ -21,9 +22,10 @@ def add_device(cookie, unique_id):
request.add_header('Cookie', cookie)
request.add_header('Content-Type', 'application/json')
device = { 'name' : unique_id, 'uniqueId' : unique_id }
- response = urllib2.urlopen(request, json.dumps(device))
- data = json.load(response)
- return data['id']
+ try:
+ response = urllib2.urlopen(request, json.dumps(device))
+ except urllib2.HTTPError:
+ pass
def send_message(conn, device_id):
params = (('id', device_id), ('lat', random.uniform(59, 61)), ('lon', random.uniform(29, 31)))
@@ -36,4 +38,8 @@ conn = httplib.HTTPConnection(server)
for i in range(devices):
device_id = "{0:0>6}".format(i)
add_device(cookie, device_id)
+
+while True:
+ device_id = "{0:0>6}".format(random.randint(0, devices))
send_message(conn, device_id)
+ time.sleep(1)