def check_server(ctx): try: from autopwn2.commands.util import get url = '%s/ping' % ctx.obj['URL'] get(url, {}, debug=False) except: click.echo('Server not running, exiting') exit(1)
def show(ctx, id): if id == -1: response = get(ctx.parent.base_url, debug=ctx.obj['DEBUG']) # click.echo('Response: %s' % (response['data'])) for s in response['data']: show_setting(s) else: response = get("%s%d" % (ctx.parent.base_url, id), debug=ctx.obj['DEBUG']) # click.echo('Response: %s' % (response)) show_setting(response)
def show( ctx, id, ): if id == -1: response = get(ctx.parent.base_url, debug=ctx.obj['DEBUG']) for s in response['data']: show_setting(s) else: response = get("%s%d" % (ctx.parent.base_url, id), debug=ctx.obj['DEBUG']) show_setting(response)
def ping(ctx, message): url = '%s/ping' % ctx.obj['URL'] payload = {} if not message == '': payload['message'] = message response = get(url, payload, debug=ctx.obj['DEBUG']) click.echo('Response: %s' % (response['message']))
def edit(ctx, id, name, value, example): url = "%s%d" % (ctx.parent.base_url, id) new = {k: v for k, v in ctx.params.items() if v} response = get(url, debug=ctx.obj['DEBUG']) response.update(new) del response['id'] response = put(url, response, debug=ctx.obj['DEBUG']) if ctx.obj['DEBUG']: click.echo('Response: %s' % (response)) click.echo('Setting updated.')
def add( ctx, tool, ): # response = get('%s/tools/?search=%s' % (ctx.obj['URL'], tool), debug=ctx.obj['DEBUG']) _tool = response['data'][0] params = {k: v for k, v in ctx.params.items() if v} params['tools_id'] = _tool['id'] params['command'] = _tool['command'] response = post(ctx.parent.base_url, params, debug=ctx.obj['DEBUG']) if ctx.obj['DEBUG']: click.echo('Response: %s' % (response)) click.echo('Job added.')