diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-31 16:27:13 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-31 16:27:13 +0800 |
commit | d8c8ba04baeed4f11003d5483890f6cafbc55fb0 (patch) | |
tree | 7b670954649ca401edd6a3ec6adf0788e1baca38 /server/piztor/ptp_send.py | |
parent | 44048e35ec8d39e748e6658da9bb62899dd3c5d3 (diff) |
ptp v2.0b std-compliant server
Diffstat (limited to 'server/piztor/ptp_send.py')
-rw-r--r-- | server/piztor/ptp_send.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/server/piztor/ptp_send.py b/server/piztor/ptp_send.py index 96f7726..42a566d 100644 --- a/server/piztor/ptp_send.py +++ b/server/piztor/ptp_send.py @@ -24,7 +24,8 @@ class _SectionSize: LOCATION_ENTRY = USER_ID + LATITUDE + LONGITUDE PADDING = 1 -host = "202.120.7.4" #"localhost" +#host = "202.120.7.4" +host = "localhost" port = 2223 def pack_data(optcode, data): @@ -86,6 +87,16 @@ def gen_set_marker(token, username, lat, lng, deadline): data += pack("!ddL", lat, lng, deadline) return pack_data(0x07, data) +def gen_change_password(token, username, old_pass, new_pass): + data = pack("!32s", token) + data += username + data += chr(0) + data += old_pass + data += chr(0) + data += new_pass + data += chr(0) + return pack_data(0x08, data) + def send(data): received = bytes() from time import time @@ -187,6 +198,16 @@ def set_marker(token, username, lat, lng, deadline): except error: logger.error("Set marker: can not parse the response") +def change_password(token, username, old_pass, new_pass): + resp = send(gen_change_password(token, username, old_pass, new_pass)) + try: + pl, optcode, status = unpack("!LBB", resp) + if pl != len(resp): + logger.error("Change password: incorrect packet length") + print "status: " + str(status) + except error: + logger.error("Change password: can not pase the response") + def open_push_tunnel(token, username): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) |