Beispiel #1
0
from pkg_resources import get_distribution

from cement import namespaces
from cement.core.namespace import CementNamespace, register_namespace
from cement.core.namespace import get_config
from cement.core.testing import simulate
from cement.core.controller import run_controller_command
from cement.core.hook import define_hook, register_hook, run_hooks

from iustools.core import irc_commands
from iustools.core.exc import IUSToolsArgumentError
from iustools.lib.bitly import shorten_url

VERSION = get_distribution('iustools.ircbot').version

define_hook('ircbot_process_hook')
define_hook('ircbot_parsemsg_hook')

# Setup the 'ircbot' namespace object
ircbot = CementNamespace(
    label='ircbot', 
    description='IRC Bot Plugin for IUS Community Project Tools',
    version=VERSION,
    controller='IRCBotController',
    provider='iustools'
    )

# default config options
ircbot.config['server'] = 'irc.freenode.net'
ircbot.config['port'] = 6667
ircbot.config['channel'] = 'iuscommunity'
Beispiel #2
0
from pkg_resources import get_distribution

from cement import namespaces
from cement.core.namespace import CementNamespace, register_namespace
from cement.core.namespace import get_config
from cement.core.testing import simulate
from cement.core.controller import run_controller_command
from cement.core.hook import define_hook, register_hook, run_hooks

from iustools.core import irc_commands
from iustools.core.exc import IUSToolsArgumentError
from iustools.lib.bitly import shorten_url

VERSION = get_distribution('iustools.ircbot').version

define_hook('ircbot_process_hook')
define_hook('ircbot_parsemsg_hook')

# Setup the 'ircbot' namespace object
ircbot = CementNamespace(
    label='ircbot',
    description='IRC Bot Plugin for IUS Community Project Tools',
    version=VERSION,
    controller='IRCBotController',
    provider='iustools')

# default config options
ircbot.config['server'] = 'irc.freenode.net'
ircbot.config['port'] = 6667
ircbot.config['channel'] = 'iuscommunity'
ircbot.config['nick'] = 'iusbot'
Beispiel #3
0
def test_define_duplicate_hook():
    define_hook('my_example_hook')
Beispiel #4
0
def test_define_duplicate_hook():
    define_hook("my_example_hook")
Beispiel #5
0
def define_default_hooks():
    """
    Defines Cement framework hooks.
    
    Hook definitions:
    
        options_hook
            Used to add options to a namespaces options object
        
        post_options_hook
            Run after all options have been setup and merged
        
        validate_config_hook
            Run after config options are setup

        pre_plugins_hook
            Run just before all plugins are loaded (run once)

        post_plugins_hook
            Run just after all plugins are loaded (run once)
        
        post_bootstrap_hook
            Run just after the root bootstrap is loaded.
    
    """
    define_hook('options_hook')
    define_hook('post_options_hook')
    define_hook('validate_config_hook')
    define_hook('pre_plugins_hook')
    define_hook('post_plugins_hook')
    define_hook('post_bootstrap_hook')
Beispiel #6
0
"""
The bootstrap module should be used to setup parts of your application
that need to exist before all controllers are loaded.  It is best used to 
define hooks, setup namespaces, and the like.  The root namespace is 
already bootstrapped by Cement, however you can extend that functionality
by importing additional bootstrap files here.
"""

from cement.core.opt import init_parser
from cement.core.hook import register_hook, define_hook

define_hook("my_example_hook")

# Register root options
@register_hook()
def options_hook(*args, **kwargs):
    # This hook allows us to append options to the root namespace
    root_options = init_parser()
    root_options.add_option(
        "-R", "--root-option", action="store_true", dest="root_option", default=None, help="Example root option"
    )
    root_options.add_option(
        "--json", action="store_true", dest="enable_json", default=None, help="render output as json (CLI-API)"
    )
    root_options.add_option("--debug", action="store_true", dest="debug", default=None, help="toggle debug output")
    root_options.add_option("--quiet", action="store_true", dest="quiet", default=None, help="disable console logging")
    root_options.add_option("--test-option", action="store", dest="test_option", default=None, help="test option")
    return ("root", root_options)


@register_hook()
Beispiel #7
0
from cement.core.hook import define_hook
from cement.core.namespace import CementNamespace, register_namespace

define_hook('my_example_hook')

# Setup the 'example' namespace object
example = CementNamespace(
    label='example', 
    controller='ExampleController',
    description='Example Plugin for Satellite CLI',
    )

# Example namespace default configurations, overwritten by the [example] 
# section of the applications config file(s).  Once registered, this dict is
# accessible as:
#
#   namespaces['example'].config
#
example.config['foo'] = 'bar'

# Example namespace options.  These options show up under:
#
#   $ satcli example --help
#
example.options.add_option('-F', '--foo', action='store',
    dest='foo', default=None, help='Example Foo Option'
    )

# Officialize and register the namespace
register_namespace(example)
Beispiel #8
0
"""
The bootstrap module should be used to setup parts of your application
that need to exist before all controllers are loaded.  It is best used to 
define hooks, setup namespaces, and the like.  The root namespace is 
already bootstrapped by Cement, however you can extend that functionality
by importing additional bootstrap files here.
"""

from cement.core.opt import init_parser
from cement.core.hook import register_hook, define_hook

define_hook('my_example_hook')


# Register root options
@register_hook()
def options_hook(*args, **kwargs):
    # This hook allows us to append options to the root namespace
    root_options = init_parser()
    root_options.add_option('-R',
                            '--root-option',
                            action='store_true',
                            dest='root_option',
                            default=None,
                            help='Example root option')
    root_options.add_option('--json',
                            action='store_true',
                            dest='enable_json',
                            default=None,
                            help='render output as json (CLI-API)')
    root_options.add_option('--debug',