How to use the puppetboard.forms.QueryForm function in puppetboard

To help you get started, we’ve selected a few puppetboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voxpupuli / puppetboard / test / test_form.py View on Github external
def test_form_valid(capsys):
    for form in [forms.QueryForm]:
        with app.app.test_request_context():
            qf = form()
            out, err = capsys.readouterr()
            assert qf is not None
            assert err == ""
            assert out == ""
github voxpupuli / puppetboard / puppetboard / app.py View on Github external
of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned.

    :param env: Serves no purpose for the query data but is required for the
        select field in the environment block
    :type env: :obj:`string`
    """
    if not app.config['ENABLE_QUERY']:
        log.warn('Access to query interface disabled by administrator.')
        abort(403)

    envs = environments()
    check_env(env, envs)

    form = QueryForm(meta={
        'csrf_secret': app.config['SECRET_KEY'],
        'csrf_context': session})
    if form.validate_on_submit():
        if form.endpoints.data not in ENABLED_QUERY_ENDPOINTS:
            log.warn('Access to query endpoint %s disabled by administrator.',
                     form.endpoints.data)
            abort(403)

        if form.endpoints.data == 'pql':
            query = form.query.data
        elif form.query.data[0] == '[':
            query = form.query.data
        else:
            query = '[{0}]'.format(form.query.data)

        result = get_or_abort(