diff options
author | Teddy <[email protected]> | 2013-08-31 12:43:44 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-31 12:43:44 +0800 |
commit | 325eea0b19a5f9cd4e54947d2ad9cb5e9d2169b3 (patch) | |
tree | 65d51e15b073b49197e71a778d60662e4bea6ff1 /server | |
parent | da9358f654ffd5bc5598d61853982631c9bdbd99 (diff) |
...
Diffstat (limited to 'server')
-rw-r--r-- | server/piztor/gen_users.py | 3 | ||||
-rw-r--r-- | server/piztor/prober.py | 16 | ||||
-rw-r--r-- | server/piztor/ptp_send.py | 16 | ||||
-rw-r--r-- | server/piztor/server.py | 2 |
4 files changed, 18 insertions, 19 deletions
diff --git a/server/piztor/gen_users.py b/server/piztor/gen_users.py index 2d4d67b..2fd57b5 100644 --- a/server/piztor/gen_users.py +++ b/server/piztor/gen_users.py @@ -7,4 +7,5 @@ def get_rand_sex(): return randint(0, 1) for i in xrange(100): - print i, i, get_rand_gid(), get_rand_sex() + print i, i, i, 23, 15, get_rand_sex(), 0 + print "23 15" diff --git a/server/piztor/prober.py b/server/piztor/prober.py index 5f57a94..cd952ef 100644 --- a/server/piztor/prober.py +++ b/server/piztor/prober.py @@ -18,13 +18,9 @@ if len(argv) == 3: token = user_auth(username, password) - -update_sub(token, username, - [ - (23, 15), (23, 15), (23, 255), (23, 255), - (23, 15), (23, 15), (23, 255), (23, 255), - (23, 15), (23, 15), (23, 255), (23, 255), - (23, 15), (23, 15), (23, 255), (23, 255), - (23, 15), (23, 15), - ]) -user_info(token, username, 23, 15) +print "Client: " + username + "logged in" +#open_push_tunnel(token, username) +for i in xrange(10): + print "Client: " + username + " updateing" + update_location(token, username, 123.456, 123.456) + sleep(10) diff --git a/server/piztor/ptp_send.py b/server/piztor/ptp_send.py index 22f9842..e910701 100644 --- a/server/piztor/ptp_send.py +++ b/server/piztor/ptp_send.py @@ -24,8 +24,8 @@ class _SectionSize: LOCATION_ENTRY = USER_ID + LATITUDE + LONGITUDE PADDING = 1 -host = "localhost" #"localhost" -port = 2223 +host = "202.120.7.4" #"localhost" +port = 2224 def pack_data(optcode, data): return pack("!LB", _SectionSize.LENGTH + \ @@ -88,12 +88,14 @@ def gen_set_marker(token, username, lat, lng, deadline): def send(data): received = bytes() + from time import time + begin = time() try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) sock.sendall(data) while True: - rd, wr, err = select([sock], [], [], 10) + rd, wr, err = select([sock], [], []) if rd: buff = sock.recv(4096) if len(buff) == 0: @@ -102,7 +104,10 @@ def send(data): else: break finally: + print "closing" + sock.shutdown(1) sock.close() + print "Waited for {} seconds".format(str(time() - begin)) return received def user_auth(username, password): @@ -112,16 +117,15 @@ def user_auth(username, password): if pl != len(resp): logger.error("User authentication: incorrect packet length") print "status: " + str(status) - print "token: " + get_hex(token) - print get_hex(resp[38:]) +# print "token: " + get_hex(token) except error: logger.error("User authentication: can not parse the response") + print get_hex(resp) return token def update_location(token, username, lat, lng): resp = send(gen_update_location(token, username, lat, lng)) - print get_hex(resp) try: pl, optcode, status = unpack("!LBB", resp[:6]) if pl != len(resp): diff --git a/server/piztor/server.py b/server/piztor/server.py index 26ccc4b..3f953a7 100644 --- a/server/piztor/server.py +++ b/server/piztor/server.py @@ -718,8 +718,6 @@ class PTP(Protocol, TimeoutMixin): except DBCorruptionError: logger.error("*** Database corruption ***") self.transport.loseConnection() - if self.tunnel is None: - self.transport.loseConnection() def connectionLost(self, reason): if self.tunnel: |