コード例 #1
0
def test_define_duplicate_namespace():  
    bogus = CementNamespace(
        label='root', 
        controller='RootController',
        version='1.0', 
        required_api='xxxx', 
        provider='cement_test')
    define_namespace('root', bogus)
コード例 #2
0
import re
from time import sleep
from pkg_resources import get_distribution
from launchpadlib.launchpad import Launchpad

from cement.core.namespace import CementNamespace, register_namespace
from cement.core.hook import register_hook

from iustools.lib.bitly import shorten_url

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

# Setup the 'launchpad' namespace object
launchpad = CementNamespace(label='launchpad',
                            description='LaunchPad Plugin for Iustools',
                            version=VERSION,
                            controller='LaunchPadController',
                            provider='iustools')

# Add a config option to the launchpad namespace.  This is effectively the
# default setting for the config option.  Overridden by config files, and then
# cli options.
launchpad.config['foo'] = 'bar'

# Add a cli option to the launchpad namespace.  This overrides the
# coresponding config option if passed
launchpad.options.add_option('-F',
                             '--foo',
                             action='store',
                             dest='foo',
                             help='example launchpad option')
コード例 #3
0
ファイル: example3.py プロジェクト: derks/cement
from cement.core.hook import register_hook, define_hook
from cement.core.namespace import CementNamespace, register_namespace

# Setup the 'example' namespace object
example = CementNamespace(
            label='example3', 
            controller='Example3Controller',
            description='Example Plugin for Cement Test',
            required_api='0.7-0.8:20100210',
            provider='cement_test'
            )
example.config['foo'] = 'bar'
example.options.add_option('-F', '--foo', action='store',
    dest='foo', default=None, help='Example Foo Option'
    )

register_namespace(example)

@register_hook(weight=99)
def my_example_hook():
    return 99

@register_hook(name='my_example_hook')
def some_other_hook_name():
    return 0

@register_hook(weight=-100)
def my_example_hook():
    return -100
コード例 #4
0
ファイル: ircbot.py プロジェクト: dev-ace/ius-tools
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'
ircbot.config['ping_cycle'] = 60
ircbot.config['recv_bytes'] = 2048 
ircbot.config['process_user'] = '******'
ircbot.config['pid_file'] = '/var/run/ius-tools/ircbot.pid'

# command line options
コード例 #5
0
ファイル: version_tracker.py プロジェクト: dev-ace/ius-tools
This bootstrap module should be used to setup parts of the version_tracker plugin
that need to exist before all controllers are loaded.  It is best used to 
define/register hooks, setup namespaces, and the like.  

"""

from pkg_resources import get_distribution
from cement.core.namespace import CementNamespace, register_namespace

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

# Setup the 'version_tracker' namespace object
version_tracker = CementNamespace(
    label='version_tracker', 
    description='Version Tracker Plugin for IUS Tools',
    version=VERSION,
    controller='VersionTrackerController',
    provider='iustools'
    )

# Directory where Package Configuration is kept
version_tracker.config['pkg_dir'] = '/usr/share/ius-tools/version_tracker/pkgs/'
version_tracker.config['ius_baseurl'] = 'http://dl.iuscommunity.org/pub/ius'

# Layout for output
version_tracker.config['layout'] = '%-30s %-15s %-15s %s'
version_tracker.config['layout_titles'] = ('name', 'ius ver', 'upstream ver', 'status')
    
# Officialize and register the namespace
register_namespace(version_tracker)
コード例 #6
0
from cement.core.hook import register_hook, define_hook
from cement.core.namespace import CementNamespace, register_namespace

# Setup the 'example' namespace object
example = CementNamespace(label='example3',
                          controller='Example3Controller',
                          description='Example Plugin for Cement Test',
                          required_api='0.7-0.8:20100210',
                          provider='cement_test')
example.config['foo'] = 'bar'
example.options.add_option('-F',
                           '--foo',
                           action='store',
                           dest='foo',
                           default=None,
                           help='Example Foo Option')

register_namespace(example)


@register_hook(weight=99)
def my_example_hook():
    return 99


@register_hook(name='my_example_hook')
def some_other_hook_name():
    return 0


@register_hook(weight=-100)
コード例 #7
0
ファイル: admin.py プロジェクト: jness/ius-tools
This bootstrap module should be used to setup parts of the admin plugin
that need to exist before all controllers are loaded.  It is best used to 
define/register hooks, setup namespaces, and the like.  

"""

from pkg_resources import get_distribution
from cement.core.namespace import CementNamespace, register_namespace

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

# Setup the 'admin' namespace object
admin = CementNamespace(
    label='admin', 
    description='Admin Plugin for Iustools',
    version=VERSION,
    controller='AdminController',
    provider='iustools'
    )

# Add a config option to the admin namespace.  This is effectively the
# default setting for the config option.  Overridden by config files, and then
# cli options.
admin.config['managed_tags'] = ['testing', 'stable', 'dev']
admin.config['managed_releases'] = ['el4', 'el5', 'el6']
admin.config['managed_archs'] = ['i386', 'x86_64']
admin.config['repo_base_path'] = '~/ius-repo'
admin.config['remote_rsync_path'] = '~/ius-repo'
admin.config['remote_exclude'] = "[0-9]\.[0-9]"
admin.config['internal_remote_rsync_path'] = False
admin.config['internal_remote_exclude'] = False
コード例 #8
0
ファイル: example.py プロジェクト: pombredanne/ius-tools
This bootstrap module should be used to setup parts of the example plugin
that need to exist before all controllers are loaded.  It is best used to 
define/register hooks, setup namespaces, and the like.  

"""

from pkg_resources import get_distribution
from cement.core.namespace import CementNamespace, register_namespace

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

# Setup the 'example' namespace object
example = CementNamespace(
    label='example', 
    description='Example Plugin for IUS Community Project Tools',
    version=VERSION,
    controller='ExampleController',
    provider='iustools'
    )

# Add a config option to the example namespace.  This is effectively the
# default setting for the config option.  Overridden by config files, and then
# cli options.
example.config['foo'] = 'bar'

# Add a cli option to the example namespace.  This overrides the 
# coresponding config option if passed
example.options.add_option('-F', '--foo', action='store', dest='foo',
    help='example example option')

# Officialize and register the namespace
コード例 #9
0
ファイル: example_five.py プロジェクト: YangXinNewlife/cement
from cement.core.hook import register_hook, define_hook
from cement.core.namespace import CementNamespace, register_namespace

# Setup the 'example' namespace object
example = CementNamespace(label='example_five',
                          controller='ExampleFiveController',
                          description='Example Plugin for Cement Test',
                          provider='cement_test')
example.config['foo'] = 'bar'
example.options.add_option('-F',
                           '--foo',
                           action='store',
                           dest='foo',
                           default=None,
                           help='Example Foo Option')

register_namespace(example)


@register_hook(weight=99)
def my_example_hook():
    return 99


@register_hook(name='my_example_hook')
def some_other_hook_name():
    return 0


@register_hook(weight=-100)
def my_example_hook():
コード例 #10
0
def test_define_broken_namespace():  
    bogus = CementNamespace(
        label='root', 
        controller='RootController')
コード例 #11
0
ファイル: launchpad.py プロジェクト: dev-ace/ius-tools
from pkg_resources import get_distribution
from launchpadlib.launchpad import Launchpad

from cement.core.namespace import CementNamespace, register_namespace
from cement.core.hook import register_hook

from iustools.lib.bitly import shorten_url


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

# Setup the 'launchpad' namespace object
launchpad = CementNamespace(
    label='launchpad', 
    description='LaunchPad Plugin for Iustools',
    version=VERSION,
    controller='LaunchPadController',
    provider='iustools'
    )

# Add a config option to the launchpad namespace.  This is effectively the
# default setting for the config option.  Overridden by config files, and then
# cli options.
launchpad.config['foo'] = 'bar'

# Add a cli option to the launchpad namespace.  This overrides the 
# coresponding config option if passed
launchpad.options.add_option('-F', '--foo', action='store', dest='foo',
    help='example launchpad option')

# Officialize and register the namespace
コード例 #12
0
ファイル: ircbot.py プロジェクト: pombredanne/ius-tools
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'
ircbot.config['ping_cycle'] = 60
ircbot.config['recv_bytes'] = 2048
ircbot.config['process_user'] = '******'
ircbot.config['pid_file'] = '/var/run/ius-tools/ircbot.pid'

# command line options
ircbot.options.add_option('--irc-channel',
コード例 #13
0
ファイル: app_setup.py プロジェクト: YangXinNewlife/cement
        sys.argv = args
        
    try:
        assert config, "default config required!"
    except AssertionError, error:
        raise CementConfigError, error.message
     
    if not banner:
        banner = "%s version %s" % (
            config['app_name'],
            version)
        
    namespace = CementNamespace(
        label='root',
        version=version,
        config=get_default_config(),
        banner=banner,
        provider=config['app_module']
        )
    define_namespace('root', namespace)
    namespaces['root'].config.update(config)
    
    root_mod = __import__("%s.controllers.root" % \
                          namespaces['root'].config['app_module'], 
                          globals(), locals(), ['root'])
    namespaces['root'].controller = getattr(root_mod, 'RootController')
        
    for config_file in namespaces['root'].config['config_files']:
        set_config_opts_per_file('root', 'root', config_file)

    validate_config(namespaces['root'].config)
コード例 #14
0
ファイル: admin.py プロジェクト: pombredanne/ius-tools
"""
This bootstrap module should be used to setup parts of the admin plugin
that need to exist before all controllers are loaded.  It is best used to 
define/register hooks, setup namespaces, and the like.  

"""

from pkg_resources import get_distribution
from cement.core.namespace import CementNamespace, register_namespace

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

# Setup the 'admin' namespace object
admin = CementNamespace(label='admin',
                        description='Admin Plugin for Iustools',
                        version=VERSION,
                        controller='AdminController',
                        provider='iustools')

# Add a config option to the admin namespace.  This is effectively the
# default setting for the config option.  Overridden by config files, and then
# cli options.
admin.config['managed_tags'] = ['testing', 'stable', 'dev']
admin.config['managed_releases'] = [
    'el5', 'el5.6.z', 'el6', 'el6.0.z', 'el6.1.z', 'el6.2.z'
]
admin.config['managed_archs'] = ['i386', 'x86_64']
admin.config['repo_base_path'] = '~/ius-repo'
admin.config['remote_rsync_path'] = '~/ius-repo'
admin.config['remote_exclude'] = "[0-9]\.[0-9]"
admin.config['internal_remote_rsync_path'] = False
コード例 #15
0
"""
This bootstrap module should be used to setup parts of the version_tracker plugin
that need to exist before all controllers are loaded.  It is best used to 
define/register hooks, setup namespaces, and the like.  

"""

from pkg_resources import get_distribution
from cement.core.namespace import CementNamespace, register_namespace

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

# Setup the 'version_tracker' namespace object
version_tracker = CementNamespace(
    label='version_tracker',
    description='Version Tracker Plugin for IUS Tools',
    version=VERSION,
    controller='VersionTrackerController',
    provider='iustools')

# Directory where Package Configuration is kept
version_tracker.config[
    'pkg_dir'] = '/usr/share/ius-tools/version_tracker/pkgs/'
version_tracker.config['ius_baseurl'] = 'http://dl.iuscommunity.org/pub/ius'

# Layout for output
version_tracker.config['layout'] = '%-30s %-15s %-15s %s'
version_tracker.config['layout_titles'] = ('name', 'ius ver', 'upstream ver',
                                           'status')

# Officialize and register the namespace
register_namespace(version_tracker)
コード例 #16
0
ファイル: mirror.py プロジェクト: nixar/satcli
import os

from cement.core.opt import init_parser
from cement.core.hook import register_hook
from cement.core.namespace import CementNamespace, register_namespace, \
                                  get_config
                                  

config = get_config()
mirror = CementNamespace(
    label='mirror', 
    controller='MirrorController'
    )

mirror.config['verify'] = False
mirror.config['mirror_dir'] = os.path.join(config['datadir'], 'mirror')
mirror.options.add_option('-V', '--verify', action='store_true',
    dest='verify', default=None, help='Verify MD5 of files (costly)')
mirror.options.add_option('--channel', action='store',
    dest='channel', default=None, help='channel to sync/mirror')    
register_namespace(mirror)
    
@register_hook()
def validate_config_hook(*args, **kwargs):
    config = get_config('mirror')
    required_settings = ['mirror_dir']
    for s in required_settings:
        if not config.has_key(s):
            raise CementConfigError, "config['mirror']['%s'] value missing!" % s