import sys import urllib import md5 import json def run(client, session, server, args): if len(args) == 0: print "invitekey required" return userid = args[0] password = args[1] firstname = None lastname = None if len(args) >= 3: firstname = args[2] if len(args) >= 4: lastname = args[3] data = {"password": password} if firstname is not None: data['firstname'] = firstname if lastname is not None: data['lastname'] = lastname print "D: data = " + str(data) headers = {"Content-type": "application/json", "Accept": "text/plain", "Cookie": "RS_API=" + str(session)} client.request("PUT", "/api/user/" + userid, json.dumps(data), headers) response = client.getresponse() print "HTTP Status/Reason: " + str(response.status) + " / " + response.reason print "Response header: " + str(response.getheaders()) print "Response:" print response.read()