Ejemplo n.º 1
0
Archivo: mad.py Proyecto: mfiers/Kea
def get_madapp():
    global MADAPP

    if MADAPP is None:
        app = leip.app('mad2')
        MADAPP = app
    return MADAPP
Ejemplo n.º 2
0
def get_madapp():
    global MADAPP

    if MADAPP is None:
        app = leip.app('mad2')
        MADAPP = app
    return MADAPP
Ejemplo n.º 3
0
    def madapp(self):
        if not self._madapp is None:
            return self._madapp

        self._madapp = leip.app('mad2', disable_commands=True)
        return self._madapp
Ejemplo n.º 4
0
Archivo: cli.py Proyecto: mfiers/Kea
import leip

from kea import Kea

def dispatch():
    """
    Run the MadMax app
    """
    app.run()


kea_conf = leip.get_config('kea')
prefix = kea_conf['arg_prefix']
thisapp = os.path.basename(sys.argv[0])

if thisapp == 'kea':
    #calling the kea tool directly:
    app = leip.app(name='kea')
else:
    #calling a tool that links to kea - Kea wrapper mode:
    # if prefix = '+', the first argument starts with '++'
    if len(sys.argv) > 1 and sys.argv[1][:2] == prefix + prefix:
        cmd = sys.argv[1][2:]
        #replace sys.argv &
        sys.argv = ['kea', cmd, '-a', thisapp] + sys.argv[2:]
        app = leip.app(name='kea')
    else:
        app = Kea()

Ejemplo n.º 5
0
Archivo: cli.py Proyecto: mfiers/kea3
import sys

import leip


def dispatch():
    """
    Run the Kea3 app
    """

    # if len(sys.argv) > 1:

    #     k3commands = set([x for x in app.leip_commands.keys() if '.' not in x])
    #     k3commands |= set(app.leip_subparsers.keys())
    #     command = sys.argv[1]
    #     if command not in k3commands:
    #         sys.argv = sys.argv[:1] + ['run'] + sys.argv[1:]

    app.run()


app = leip.app(name='kea3')
app.discover(globals())
Ejemplo n.º 6
0
def test_k3_job_instantiate():
    app = leip.app(name='kea3')
    job = K3Job(app, [])
    assert isinstance(job, K3Job)
Ejemplo n.º 7
0
Archivo: main.py Proyecto: mfiers/mad2

@leip.arg('section', help='section to print', default='', nargs='?')
@leip.command
def sysconf(app, args):
    c = app.conf[args.section]
    print(c.pretty())


@leip.arg('comm', metavar='command', help='command to check')
@leip.command
def has_command(app, args):
    comm = args.comm
    lg.debug("checking if we know command %s" % comm)
    if comm in app.leip_commands:
        sys.exit(0)
    else:
        sys.exit(-1)


#
# Instantiate the app and discover hooks & commands
#
#logging.getLogger('leip').setLevel(logging.DEBUG)

app = leip.app('mad2')

# app.parser.add_argument('--trust', action='store_true', help='trust sha1sum')
# discover hooks in this module!
app.discover(globals())
Ejemplo n.º 8
0
def get_mad_app():
    global MADAPP
    if not isinstance(MADAPP, leip.app):
        MADAPP = leip.app(name='mad2', disable_commands=True)
    return MADAPP
Ejemplo n.º 9
0
Archivo: cli.py Proyecto: mfiers/kea3
import sys

import leip


def dispatch():
    """
    Run the Kea3 app
    """

    # if len(sys.argv) > 1:
        
    #     k3commands = set([x for x in app.leip_commands.keys() if '.' not in x])
    #     k3commands |= set(app.leip_subparsers.keys())
    #     command = sys.argv[1]
    #     if command not in k3commands:
    #         sys.argv = sys.argv[:1] + ['run'] + sys.argv[1:]
            
    app.run()


app = leip.app(name='kea3')
app.discover(globals())
Ejemplo n.º 10
0
Archivo: cli.py Proyecto: pombreda/Tui
import leip

def dispatch():
    """
    Run the Tui app
    """
    app.run()


app = leip.app(name='tui')
app.discover(globals())
Ejemplo n.º 11
0
tmpdir = tempfile.mkdtemp()
conf_drie = os.path.join(tmpdir, 'conf.drie.yaml')

test_drie = """
plugin:
  test:
    module: 'leip_test_3'
    
"""

lg.info("saving dummy configuration files") 

with open(conf_drie, 'w') as F:
    F.write(test_drie)

lg.debug('instantiating app')
app = leip.app(
    config_files = (('drie', conf_drie),))

@app.command
def test(app, args):
    """
    Run a few tests
    """

    print 'run test'

app.run()
shutil.rmtree(tmpdir)
Ejemplo n.º 12
0
def kea3_leip_app():
    return leip.app(name='kea3')
Ejemplo n.º 13
0
def test_k3_job_instantiate():
    app = leip.app(name='kea3')
    job = K3Job(app, [])
    assert isinstance(job, K3Job)
Ejemplo n.º 14
0
def test_leip_app_instantiate():
    # see if the leip app loads properly
    app = leip.app(name='kea3')
    assert isinstance(app, leip.app)
    assert 'run' in app.leip_commands
    assert 'conf.show' in app.leip_commands
Ejemplo n.º 15
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test 1
"""

import leip


@leip.arg('name', help='Name to say hello to', default='world')
@leip.command
def hello(app, args):
    """
    Run the proverbial hello world test

    Help for the command is provided in the docstring. The first line
    is used for the command overview (test_1.py -h), the rest is used
    for a more extensive help per command (test_1.py hello -h).
    """
    print("Hello %s" % args.name)

if __name__ == '__main__':
    app = leip.app()
    app.discover(locals())
    app.run()
Ejemplo n.º 16
0
    """
    Run a few tests
    """

    global conf_een
    global conf_twee

    app.conf.animal = 'rabbit'
    #app.conf.save()

    x = app.conf.simple()

    with open(os.path.join(conf_een)) as F:
        c1 = F.read()
    with open(os.path.join(conf_twee)) as F:
        c2 = F.read()

    assert(app.conf.test_1 == 'b')
    assert(app.conf.test_3.sub_1.sub_2 == 'subsubval')
    lg.setLevel(logging.DEBUG)
    lg.debug("combined %s" % str(x))
    lg.debug("one:\n%s\n####" % str(c1))
    lg.debug("two:\n%s\n####" % str(c2))

if __name__ == '__main__':
    app = leip.app(
        config_files = [conf_een, conf_twee])
    app.discover(locals())
    app.run()

Ejemplo n.º 17
0
from collections import Counter
import sys
import socket

import leip
from mad3 import ui
from mad3 import madfile

# add communication functions
ui.init_app(leip.app)

# bulk operation
leip.app.bulk_init = madfile.bulk_init
leip.app.bulk_execute = madfile.bulk_execute

app = leip.app(name='mad3')
app.counter = Counter()

app.discover(globals())

# add a hook for bulk operations

# ensure hostname is defined
if not 'hostname' in app.conf:
    if not 'conf set hostname' in ' '.join(sys.argv):
        app.warning("Hostname is not defined")
        app.message("Try: m3 conf set hostname '{hostname}'",
                    hostname=socket.gethostname())
        exit(-1)

Ejemplo n.º 18
0
def get_mad_app():
    global MADAPP
    if not isinstance(MADAPP, leip.app):
        MADAPP = leip.app(name='mad2', disable_commands=True)
    return MADAPP
Ejemplo n.º 19
0
Archivo: cli.py Proyecto: mfiers/nfj
import leip
import logging

def dispatch():
    """
    Run the nfj app
    """
    app.run()

logging.getLogger('nfj').setLevel(logging.INFO)

app = leip.app(name='nfj')
app.discover(globals())
Ejemplo n.º 20
0
def test_leip_app_instantiate():
    # see if the leip app loads properly
    app = leip.app(name='kea3')
    assert isinstance(app, leip.app)
    assert 'run' in app.leip_commands
    assert 'conf.show' in app.leip_commands
Ejemplo n.º 21
0
Archivo: cli.py Proyecto: mfiers/Leip
    create_file(conf, CONF_TEMPLATE)

    p_conf = os.path.join(src, 'etc', 'plugin.config'.format(name))
    create_file(p_conf, PLUGIN_CONF_TEMPLATE.format(**tdata))

    setup_py = os.path.join(project, 'setup.py')
    create_file(setup_py, SETUP_PY_TEMPLATE.format(**tdata))

    cli_py = os.path.join(src, 'cli.py')
    create_file(cli_py, CLI_TEMPLATE.format(**tdata))

    hw_py = os.path.join(src, 'plugin', 'hello_world.py')
    create_file(hw_py, HELLO_WORLD_PLUGIN_TEMPLATE.format(**tdata))

    hwi_py = os.path.join(src, 'plugin', '__init__.py')
    create_file(hwi_py, "")

    create_file(os.path.join(project, 'MANIFEST.in'),
        "recursive-include {name}/etc *.config\n".format(**tdata))

    create_file(os.path.join(project, 'DESCRIPTION'),
        "One line description of {project}".format(**tdata))

    create_file(os.path.join(project, 'VERSION'),
        "0.0.1")

#    os.makedirs(os.path.join(name))

app = leip.app(name='leip', set_name=None)
app.discover(globals())
Ejemplo n.º 22
0
def kea3_leip_app():
    return leip.app(name='kea3')
Ejemplo n.º 23
0
import leip

from kea import Kea


def dispatch():
    """
    Run the MadMax app
    """
    app.run()


kea_conf = leip.get_config('kea')
prefix = kea_conf['arg_prefix']
thisapp = os.path.basename(sys.argv[0])

if thisapp == 'kea':
    #calling the kea tool directly:
    app = leip.app(name='kea')
else:
    #calling a tool that links to kea - Kea wrapper mode:
    # if prefix = '+', the first argument starts with '++'
    if len(sys.argv) > 1 and sys.argv[1][:2] == prefix + prefix:
        cmd = sys.argv[1][2:]
        #replace sys.argv &
        sys.argv = ['kea', cmd, '-a', thisapp] + sys.argv[2:]
        app = leip.app(name='kea')
    else:
        app = Kea()
Ejemplo n.º 24
0
Archivo: cli.py Proyecto: mfiers/rat
def dispatch():
    app = leip.app('rat')
    app.run()
Ejemplo n.º 25
0
def m3app():
    """Instantiate an m3 app."""
    yield leip.app(name='mad3')