diff --git a/employ/__init__.py b/employ/__init__.py index 3dc1f76..1f9c728 100644 --- a/employ/__init__.py +++ b/employ/__init__.py @@ -1 +1,6 @@ __version__ = "0.1.0" +from straight.plugin import load + +from employ.commands import Command + +commands = load("employ.commands", subclasses=Command) diff --git a/employ/commands/__init__.py b/employ/commands/__init__.py index 877df82..cde1840 100644 --- a/employ/commands/__init__.py +++ b/employ/commands/__init__.py @@ -1,3 +1,22 @@ -__all__ = ["ABCommand", "Command"] -from employ.commands.base import Command -from employ.commands.ab import ABCommand +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) + + +class Command(object): + name = "command" + + def run(self): + raise NotImplementedError() + + def aggregate(self): + raise NotImplementedError() + + def command(self): + raise NotImplementedError() + + @classmethod + def from_config(cls, config): + settings = {} + if config.has_section(cls.name): + settings = dict(config.items(cls.name)) + return cls(**settings) diff --git a/employ/commands/base.py b/employ/commands/base.py deleted file mode 100644 index d0ce91f..0000000 --- a/employ/commands/base.py +++ /dev/null @@ -1,5 +0,0 @@ -class Command(object): - name = "command" - - def run(self): - raise NotImplementedError() diff --git a/requirements.txt b/requirements.txt index 53de545..76862c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ boto>=2.13.0 docopt>=0.6.0 +straight.plugin>=1.4.0 diff --git a/setup.py b/setup.py index 6826d5a..4cb3458 100644 --- a/setup.py +++ b/setup.py @@ -10,9 +10,16 @@ setup( author="Brett Langdon", author_email="brett@blangdon.com", packages=find_packages(), + namespace_packages=[ + "employ.commands", + ], install_requires=[ "docopt>=0.6.0", "boto>=2.13.0", + "straight.plugin>=1.4.0", + ], + scripts=[ + "bin/employ", ], setup_requires=[], description="Distributed one time command execution and aggregation tool",