diff options
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)) |