@responder(pattern='^auth request$', form='auth request', auth_required=False,
 help='Request authorization from environment administrator')
@defer.deferredGenerator
def auth_request(conversation):
    result = None
    try:
        if conversation.authorized:
            conversation.say("You are already authorized to use this droned.")
            raise AssertionError('Already authorized to use this droned')

        conversation.say("Ok, I will pass your request along to the environment administrator. I will let you know what they decide.")
        deputy = Conversation(jabber_config.DEPUTY)
        try:
            question = "%s has requested authorization, do you wish to <b>grant</b> or <b>deny</b> this request?" % conversation.buddy
            answers = ('grant','deny')
            d = deputy.ask(question, answers)
            wfd = defer.waitForDeferred(d)
            yield wfd
            answer = wfd.getResult()
        except AlreadyAskingQuestion:
            err = "Sorry, the environment administrator is busy dealing with something else right now. "
            err += "You should wait and try again later, or if it is urgent contact them directly. "
            err += "The environment administrator is %s" % jabber_config.DEPUTY
            conversation.say(err)
            raise AssertionError('Administrator is busy')

        if answer == 'grant':
            conversation.grantAuthorization()
            deputy.say("%s has been granted authorization." % conversation.buddy)
        else:
            err = "Your request for authorization has been denied. If you wish to discuss this further you "
            err += "should contact the environment administrator directly. "
            err += "The environment administrator is %s" % jabber_config.DEPUTY
            conversation.say(err)
            deputy.say("%s has been denied authorization." % conversation.buddy)
    except AssertionError: pass
    except:
        result = Failure()
    yield result
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/lib/droned/responders/core.py/auth_request/original