本文整理汇总了Python中XmlManager类的典型用法代码示例。如果您正苦于以下问题:Python XmlManager类的具体用法?Python XmlManager怎么用?Python XmlManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_role
def build_role(account, role, key, add=True):
'''build a request to add account to the role if add is True, if False
build the request to remove account from the role'''
if add:
action = 'http://www.msn.com/webservices/AddressBook/AddMember'
body = XmlManager.get('addmember', key, role, account)
else:
action = 'http://www.msn.com/webservices/AddressBook/DeleteMember'
body = XmlManager.get('deletemember', key, role, account)
return Request(action, 'omega.contacts.msn.com', 443,
'/abservice/SharingService.asmx', body)
示例2: __init__
def __init__(self, session, msg_queue, contact, message,
lockkey='', seq=1, first=True):
'''command_queue is a reference to a queue that is used
by the worker to get commands that other threads need to
send'''
me = session.contacts.me
passport_id = session.extras['messengersecure.live.com']['security']
nick = '=?%s?%s?=%s?=' % (
'utf-8','B', me.display_name.encode('base64').strip())
run_id = str(uuid4())
content = message.encode('base64').strip()
send_xml = XmlManager.get('sendoim', me.account, nick, common.MSNP_VER,
common.BUILD_VER, contact, passport_id,
challenge._PRODUCT_ID, str(lockkey),
str(seq), run_id, str(seq), content)
send_xml = send_xml.replace('\\r\\n', '\r\n')
Requester.__init__(self, session,
'http://messenger.live.com/ws/2006/09/oim/Store2',
'ows.messenger.msn.com',443,'/OimWS/oim.asmx',
send_xml.strip())
self.contact = contact
self.message = message
self.oid = ''
self.seq = seq
self.first = first
self.msg_queue = msg_queue
log.debug('FROM:%s TO:%s' % (me.display_name, contact))
示例3: do_passport_identification
def do_passport_identification(self):
'''do the passport identification and get our passport id'''
hash_ = self.session.extras['hash'].split()[-1]
template = XmlManager.get('passport',
self.session.account.account, self.session.account.password)
if '@msn.com' not in self.session.account.account:
server = "login.live.com"
url = "/RST.srf"
else:
server = "msnia.login.live.com"
url = "/pp550/RST.srf"
#create the headers
headers = { \
'Accept' : 'text/*',
'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
'Host' : server,
'Content-Length' : str(len(template)),
'Connection' : 'Keep-Alive',
'Cache-Control' : 'no-cache'
}
succeeded = False
for i in range(5):
response = None
# send the SOAP request
for i in range(3):
try:
conn = httplib.HTTPSConnection(server, 443)
conn.request('POST', url, template, headers)
response = conn.getresponse()
break
except Exception, exception:
pass
if response:
data = response.read()
dbg(data, 'worker', 3)
else:
self.session.add_event(e3.Event.EVENT_LOGIN_FAILED,
'Can\'t connect to HTTPS server: ' + str(exception))
self._on_login_failed()
if data.find('<faultcode>psf:Redirect</faultcode>') > 0:
url = urlparse.urlparse(data.split('<psf:redirectUrl>')\
[1].split('</psf:redirectUrl>')[0])
server = url[1]
url = url[2]
else:
succeeded = True
break