]>
code.delx.au - pymsnt/blob - src/utils.py
1 # Copyright 2004-2005 James Bunton <james@delx.cjb.net>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
7 return el
.getAttribute((u
'http://www.w3.org/XML/1998/namespace', u
'lang'))
11 def socks5Hash(sid
, initiator
, target
):
12 return sha
.new("%s%s%s" % (sid
, initiator
, target
)).hexdigest()
17 def getURLBits(url
, assumedType
=None):
18 type, rest
= urllib
.splittype(url
)
19 if assumedType
and type != assumedType
:
21 hostport
, path
= urllib
.splithost(rest
)
22 host
, port
= urllib
.splitnport(hostport
, 80)
23 filename
= os
.path
.basename(path
)
24 return host
, port
, path
, filename
31 def convertToPNG(imageData
):
32 inbuff
= StringIO
.StringIO(imageData
)
33 outbuff
= StringIO
.StringIO()
34 Image
.open(inbuff
).save(outbuff
, "PNG")
36 imageData
= outbuff
.read()
39 print "WARNING! Only PNG avatars will be understood by this transport. Please install the Python Imaging Library."
41 def convertToPNG(imageData
):
48 "feature-not-implemented" : 501,
51 "internal-server-error" : 500,
52 "item-not-found" : 404,
53 "jid-malformed" : 400,
54 "not-acceptable" : 406,
56 "not-authorized" : 401,
57 "payment-required" : 402,
58 "recipient-unavailable" : 404,
60 "registration-required" : 407,
61 "remote-server-not-found" : 404,
62 "remote-server-timeout" : 504,
63 "resource-constraint" : 500,
64 "service-unavailable" : 503,
65 "subscription-required" : 407,
66 "undefined-condition" : 500,
67 "unexpected-request" : 400