@responder(pattern="^@(?P<command>.+)", context_key='server', form="@<command>", help="Run a droned command on the current server")
@defer.deferredGenerator
def droneblast(conversation, command):
    server = conversation.context.get('server')
    response = None
    d = None
    try:
        if not isinstance(server, Server):
            conversation.say('On what <b>server</b>?')
            raise AssertionError('incomplete converation context')

        options = {}
        if 'timeout' in conversation.context:
            options['timeout'] = conversation.context['timeout']

        try:
            conversation.say("Running droned command...")
            d = server.manager.run(command, **options)
            deferreds = conversation.context.get('deferreds', [])
            deferreds.append(d)
            conversation.context.update({'deferreds': deferreds})
            wfd = defer.waitForDeferred(d)
            yield wfd
            result = wfd.getResult()
        except:
            failure = Failure()
            if failure.check(DroneCommandFailed):
                rc = failure.value.resultContext
                conversation.say(rc.get('description') or str(rc), useHTML=False)
            else:
                conversation.say(failure.getTraceback(), useHTML=False)
        else:
            if isinstance(result, dict):
                output = result.values()[0].get('description', str(result))
            else:
                output = str(result)
            deferreds = conversation.context.get('deferreds', [])
            try: deferreds.remove(d)
            except: pass
            conversation.context.update({'deferreds': deferreds})
            conversation.say("Command completed\n%s" % output, useHTML=False)
    except AssertionError: pass
    except:
        result = Failure()
    yield result
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/lib/droned/responders/core.py/droneblast/original