def onResponse(element):
    if (element.getAttribute('type') == 'error'):
        d.errback(error.exceptionFromStanza(element))
    else:
        d.callback(UserPresence.fromElement(element))
def onResponse(element):
    if (element.getAttribute('type') == 'error'):
        d.errback(error.exceptionFromStanza(element))
    else:
        d.callback(UserPresence.fromElement(element))