Пример #1
0
    "OS": "Python",
    "OSLanguage": "en-us",
    "PhoneNumber": "NA",
    "MobileOperator": "NA",
    "UserAgent": "pyAS"
}

#create wbxml_parser test
cp, cp_sh = as_code_pages.build_as_code_pages()
parser = wbxml_parser(cp, cp_sh)

#create activesync connector
as_conn = ASHTTPConnector(as_server)  #e.g. "as.myserver.com"
as_conn.set_credential(as_user, as_pass)
as_conn.options()
policykey = storage.get_keyvalue("X-MS-PolicyKey")
if policykey:
    as_conn.set_policykey(policykey)


def as_request(cmd, wapxml_req):
    print "\r\n%s Request:" % cmd
    print wapxml_req
    res = as_conn.post(cmd, parser.encode(wapxml_req))
    wapxml_res = parser.decode(res)
    print "\r\n%s Response:" % cmd
    print wapxml_res
    return wapxml_res


#Provision functions
Пример #2
0
pyver = sys.version_info

storage.create_db_if_none()
conn, curs = storage.get_conn_curs()
device_info = {"Model":"%d.%d.%d" % (pyver[0], pyver[1], pyver[2]), "IMEI":"123456", "FriendlyName":"My pyAS Client", "OS":"Python", "OSLanguage":"en-us", "PhoneNumber": "NA", "MobileOperator":"NA", "UserAgent": "pyAS"}

#create wbxml_parser test
cp, cp_sh = as_code_pages.build_as_code_pages()
parser = wbxml_parser(cp, cp_sh)

#create activesync connector
as_conn = ASHTTPConnector(as_server) #e.g. "as.myserver.com"
as_conn.set_credential(as_user, as_pass)
as_conn.options()
policykey = storage.get_keyvalue("X-MS-PolicyKey")
if policykey:
    as_conn.set_policykey(policykey)

def as_request(cmd, wapxml_req):
    print "\r\n%s Request:" % cmd
    print wapxml_req
    res = as_conn.post(cmd, parser.encode(wapxml_req))
    wapxml_res = parser.decode(res)
    print "\r\n%s Response:" % cmd
    print wapxml_res
    return wapxml_res

#Provision functions
def do_apply_eas_policies(policies):
    for policy in policies.keys():