diff --git a/README b/README index 2c7b2de3..05b9386c 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ NAME: Cement -CREATOR/MAINTAINER: BJ Dierkes DESCRIPTION: diff --git a/cement/core/app_setup.py b/cement/core/app_setup.py index eaa5bb2d..5e1f9a18 100644 --- a/cement/core/app_setup.py +++ b/cement/core/app_setup.py @@ -143,10 +143,12 @@ def run_command(command_name): raise CementArgumentError, \ "'%s' is a *namespace, not a command. See '%s --help' instead." % \ (namespace, namespace) - + (cli_opts, cli_args) = parse_options(namespace=namespace) set_config_opts_per_cli_opts(namespace, cli_opts) + # FIX ME: need a global_pre_command_hook here so that clibasic can + # look for -C and if so, parse the passed config files into the dict. for res in run_hooks('global_post_options_hook'): pass @@ -237,6 +239,7 @@ def lay_cement(default_app_config=None, version_banner=None): log = get_logger(__name__) load_all_plugins() + setup_logging('cement', clear_loggers=True) setup_logging(namespaces['global'].config['app_module']) @@ -260,13 +263,17 @@ def load_plugin(plugin): except ImportError, e: raise CementConfigError, e - plugin_module = __import__('cement.plugins', globals(), locals(), - [plugin], -1) - try: + plugin_module = __import__('%s.plugins' % config['app_module'], globals(), locals(), + [plugin], -1) getattr(plugin_module, plugin) - except AttributeError: - raise CementRuntimeError, "Failed loading plugin '%s', possibly syntax errors?" % plugin + except AttributeError, e: + try: + plugin_module = __import__('cement.plugins', globals(), locals(), + [plugin], -1) + getattr(plugin_module, plugin) + except AttributeError, e: + raise CementRuntimeError, "Failed loading plugin '%s', possibly syntax errors?" % plugin plugin_config_file = os.path.join( namespaces['global'].config['plugin_config_dir'], '%s.plugin' % plugin @@ -334,7 +341,7 @@ def parse_options(namespace='global'): if namespace == 'global': for nam in namespaces: - if nam != 'global': + if nam != 'global' and namespaces[nam].commands: if line == ' ': line += '*%s' % nam elif len(line) + len(nam) < 55: diff --git a/cement/paste/commands.py b/cement/paste/commands.py index abdd8139..ca643912 100644 --- a/cement/paste/commands.py +++ b/cement/paste/commands.py @@ -173,8 +173,11 @@ Example usage:: self.__dict__.update(self.options.__dict__) if self.args: - self.project = self.args[0].lower() - self.plugin = self.args[1].lower() + try: + self.project = self.args[0].lower() + self.plugin = self.args[1].lower() + except IndexError: + pass while not self.project: self.project = raw_input("Enter project name: ").lower() diff --git a/cement/paste/templates/cementapp/setup.py_tmpl b/cement/paste/templates/cementapp/setup.py_tmpl index 7f0d7596..3a6337f5 100644 --- a/cement/paste/templates/cementapp/setup.py_tmpl +++ b/cement/paste/templates/cementapp/setup.py_tmpl @@ -15,6 +15,8 @@ setup(name='{{project}}', zip_safe=False, install_requires=[ "ConfigObj", + "cement == {{cement_version}}", + "cement.plugins.clibasic", ], setup_requires=[ "PasteScript >= 1.7" diff --git a/cement/paste/templates/cementplugin/setup.py_tmpl b/cement/paste/templates/cementplugin/setup.py_tmpl index 3334a3dd..66bb2978 100644 --- a/cement/paste/templates/cementplugin/setup.py_tmpl +++ b/cement/paste/templates/cementplugin/setup.py_tmpl @@ -16,10 +16,13 @@ setup(name='{{project}}_plugins_{{plugin}}', zip_safe=False, install_requires=[ "ConfigObj", - "Cement", + "cement", + "cement.plugins.clibasic", + "{{project}}", ], setup_requires=[ - "PasteScript >= 1.7" + "PasteScript >= 1.7", + "ConfigObj", ], test_suite='nose.collector', entry_points=""" diff --git a/examples/CementExample/cement_example/core.py b/examples/CementExample/cement_example/core.py index 4af3accf..b7ffbb21 100644 --- a/examples/CementExample/cement_example/core.py +++ b/examples/CementExample/cement_example/core.py @@ -1,7 +1,6 @@ """An example application using the Cement framework.""" import sys, os -import re from cement.core.log import get_logger from cement.core.app_setup import lay_cement, ensure_abi_compat, run_command diff --git a/examples/CementExampleMyPlugin/cement_example/plugins/myplugin.py b/examples/CementExampleMyPlugin/cement_example/plugins/myplugin.py index 876a7b97..19236972 100644 --- a/examples/CementExampleMyPlugin/cement_example/plugins/myplugin.py +++ b/examples/CementExampleMyPlugin/cement_example/plugins/myplugin.py @@ -23,12 +23,12 @@ class ExamplePlugin(CementPlugin): self.required_abi = '20091207' self.description = "Example Plugin for a Cement Application." self.config = { - 'config_source': ['defaults'] + 'config_source': ['defaults'], + 'myplugin_opton' : 'My plugin value' } self.commands = { 'myplugin' : MyPluginCommand, } - self.handlers = {} self.options = init_parser(global_config) # Cement allows you to expose command line options to the @@ -38,7 +38,7 @@ class ExamplePlugin(CementPlugin): help='example option for myplugun plugin', metavar='VAR' ) - + class MyClass(object): def __init__(self, config): pass diff --git a/plugins/cement-plugins-clibasic/setup.py b/plugins/cement-plugins-clibasic/setup.py index f1bb3dc0..6601bbf3 100644 --- a/plugins/cement-plugins-clibasic/setup.py +++ b/plugins/cement-plugins-clibasic/setup.py @@ -1,8 +1,8 @@ from setuptools import setup, find_packages import sys, os -setup(name='CementPluginsCLIBasic', - version='0.1', +setup(name='cement.plugins.clibasic', + version='0.2', description='Basic Commands for Applications Build on Cement', classifiers=[], keywords='', @@ -15,10 +15,11 @@ setup(name='CementPluginsCLIBasic', zip_safe=False, install_requires=[ "ConfigObj", - "cement", + "cement == 0.4", ], setup_requires=[ - "PasteScript >= 1.7" + "PasteScript >= 1.7", + "ConfigObj" ], test_suite='nose.collector', entry_points=""" diff --git a/setup.py b/setup.py index 292967e8..a30be68a 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ using cement. """ -setup(name='Cement', +setup(name='cement', version=version, description="Python CLI Application Framework", long_description=LONG, @@ -42,6 +42,15 @@ setup(name='Cement', "PasteScript", "tempita", ], + setup_requires=[ + "PasteScript >= 1.7", + "ConfigObj" + ], + # FIX ME: This installs, but requiring CementABI == 0.4.20091211 doesn't + # work. + provides=[ + "CementABI (0.4.20091211)", + ], entry_points=""" [paste.global_paster_command] cement-app = cement.paste.commands:CementAppCommand