#! /usr/bin/python
# coding:utf-8
# curl "http://localhost:8080/wisemapping/service/admin/users/email/{使用者帳號信箱}.json" --get --basic -u "admin@wisemapping.org:admin"
import sys
import urllib2
import base64
import yaml
import datetime
username = 'admin@wisemapping.org'
password = 'admin'
if len(sys.argv) == 2:
request = urllib2.Request("http://localhost:8080/wisemapping/service/admin/users/email/%s.json" % sys.argv[1])
base64string = base64.encodestring('%s:%s' % (username, password)).replace('n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request).read()
#print result
print "ID:tt" + str(yaml.load(result).get('id'))
print "Firstname:t" + yaml.load(result).get('firstname')
print "Lastname:t" + yaml.load(result).get('lastname')
print "E-Mail:tt" + yaml.load(result).get('email')
print "Create Date:t" + datetime.datetime.fromtimestamp(yaml.load(result).get('creationDate') / 1000.0 ).strftime("%Y-%m-%d")
else:
print "使用方法: python finduser.py {使用者email}"