aboutsummaryrefslogtreecommitdiff
path: root/tools/test-map.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/test-map.py')
-rwxr-xr-xtools/test-map.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/test-map.py b/tools/test-map.py
index c289df605..362c95878 100755
--- a/tools/test-map.py
+++ b/tools/test-map.py
@@ -1,8 +1,8 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
import urllib
import urllib2
-import httplib
+import http.client as httplib
import time
import random
import json
@@ -14,7 +14,7 @@ devices = 500
def login():
request = urllib2.Request(baseUrl + '/api/session')
- response = urllib2.urlopen(request, urllib.urlencode(user))
+ response = urllib2.urlopen(request, urllib.parse.urlencode(user))
return response.headers.get('Set-Cookie')
def add_device(cookie, unique_id):
@@ -29,7 +29,7 @@ def add_device(cookie, unique_id):
def send_message(conn, device_id):
params = (('id', device_id), ('lat', random.uniform(59, 61)), ('lon', random.uniform(29, 31)))
- conn.request('GET', '?' + urllib.urlencode(params))
+ conn.request('GET', '?' + urllib.parse.urlencode(params))
conn.getresponse().read()
cookie = login()
@@ -38,6 +38,7 @@ conn = httplib.HTTPConnection(server)
for i in range(devices):
device_id = "{0:0>6}".format(i)
add_device(cookie, device_id)
+ send_message(conn, device_id)
while True:
device_id = "{0:0>6}".format(random.randint(0, devices))