コード例 #1
0
ファイル: core_lib.py プロジェクト: ndebuhr/yay
# Printing
#


def print_text(data, variables):
    print(data)


def print_json(data, variables):
    print_as_json(data)


def print_yaml(data, variables):
    print_as_yaml(data)


register('Join', join)
register('Merge into variable', join)
register('Merge', merge, list_processor=True)

register('Print JSON', print_json)
register('Print as JSON', print_json)
register('Print YAML', print_yaml)
register('Print as YAML', print_yaml)
register('Name', noop)
register('Task', noop)
register('Test case', noop)
register('Print', print_text)
register('Replace', replace_text)
register('Wait', wait)
コード例 #2
0
from yay import core

from yay.util import *


def write_file(data, variables):
    name = get_parameter(data, 'name')
    content = get_parameter(
        data, 'contents'
    )  # See https://english.stackexchange.com/questions/56831/file-content-vs-file-contents

    with open(name, 'w') as file:
        file.write(format_yaml(content))


def read_file(data, variables):
    contents = read_yaml_file(data)
    if len(contents) == 1:
        return contents[0]
    return contents


# Register tasks
core.register('Write file', write_file)
core.register('Read file', read_file)
コード例 #3
0
from yay import core
from yay.util import *
from subprocess import call
import os
import tempfile


def xl_apply(data, variables):

    file, path = tempfile.mkstemp()
    try:
        with os.fdopen(file, 'w') as tmp:
            tmp.write(format_yaml(data))
        command = "xl apply -f {}".format(path)
        call(command, shell=True)
    finally:
        os.remove(path)


# Register tasks
core.register('XL apply', xl_apply)
コード例 #4
0
ファイル: http.py プロジェクト: angel-git/yay
        r = requests.get(url + path, headers = jsonHeaders)
    if method == 'POST':
        r = requests.post(url + path, data = json.dumps(body), headers = jsonHeaders)
    if method == 'PUT':
        r = requests.put(url + path, data = json.dumps(body), headers = jsonHeaders)
    if method == 'DELETE':
        r = requests.delete(url + path, headers = jsonHeaders)

    if r.status_code >= 300:
        print(r.status_code)
        print(r.text)
        return

    if r.status_code > 200:
        return

    try:
        result = json.loads(r.text)
    except ValueError:
        result = r.text

    return result

# Register tasks
core.register('Http GET', http_get)
core.register('Http POST', http_post)
core.register('Http PUT', http_put)
core.register('Http DELETE', http_delete)
core.register('Http', process_request)
core.register('Http endpoint', http_set_url)
コード例 #5
0
from yay import core

from yay.util import *


def execute_python_script(data, variables):
    exec(data, variables)


# Register tasks
core.register('Python', execute_python_script)
コード例 #6
0
ファイル: input.py プロジェクト: angel-git/yay
from yay import core
from yay.util import *
from PyInquirer import prompt


def ask_user(data, variables):
    if 'name' not in data:
        data['name'] = core.RESULT_VARIABLE

    answers = prompt([data])
    variables.update(answers)


# Register tasks
core.register('User Input', ask_user)
コード例 #7
0
from yay import core
from .arango import *

# Register command handlers
core.register('Arango endpoint', set_endpoint)
core.register('Arango database', set_database)
core.register('Arango query', run_aql_query)
core.register('Arango insert', insert)
コード例 #8
0
from yay import core
from yay.util import *
from PyInquirer import prompt


def ask_user(data, variables):
    if 'name' not in data:
        data['name'] = core.OUTPUT_VARIABLE

    answers = prompt([data])
    variables.update(answers)


def check_input(data, variables):

    for variable in data:
        if variable in variables:
            continue

        query = {
            'type': 'input',
            'message': data[variable] + f' (${{{variable}}}):',
            'name': variable
        }
        answers = prompt([query])
        variables.update(answers)


# Register command handlers
core.register('User Input', ask_user)
core.register('Check Input', check_input)