Skip to main content

Ascetic command runner. The most ease way to power your python app with custom management commands

Project description

Ascetic Command Runner

Travis CI status Coveralls status

Not all of our projects are using either django or another God framework. So, once we start our hobby project, would be great to put into the game some commands. For example, maybe we need for our hobby project simple command test which loads custom TestRunner, etc In this case this package maybe handy for you!

Installation

Simply run in your bash:

pip install acmdrunner

Usage

In your django like manage.py command loader, you need to trigger following:

import os
from acmdrunner import Loader

...
make all your preparations, initialize project settings, etc
...

Loader.load_from_directory(os.path.dirname(__file__))
Loader.load_from_package('rit.app')

Loader will search recursively in passed folder for folders with name management. And try to load from folders found file acr_commands.py

An example of the file acr_commands.py:

from acmdrunner.dispatcher import CommandDispatcher
command_dispatcher = CommandDispatcher()


def execute(*args):
    pass

command_dispatcher.register_command('test', execute)

register_command registers specific command and handler for this command. Your commands should implement execute method. Better to inherit from BaseCommand. But as it is ascetic, you can simply pass class with execute method implemented. That’s all!

To run command, please trigger following call:

from your_package_place import command_dispatcher
command_dispatcher.execute_command(command_name, *args, **kwargs)

Real usage example

If you want to load all commands from specific namespace, you can implement following:

packages_to_traverse = ('rit.app', 'rit.core')
for package in packages_to_traverse:
    Loader.load_from_package(package[0])
Loader.load_from_directory(os.path.dirname(os.getcwd()))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acmdrunner-1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file acmdrunner-1.tar.gz.

File metadata

  • Download URL: acmdrunner-1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for acmdrunner-1.tar.gz
Algorithm Hash digest
SHA256 6469c3d3d7b26216d0e565fc7ffdda6aa062e0cac9087041894a85b1d2589e61
MD5 ba7bae6498cd5cf40ac1530147b17cde
BLAKE2b-256 9726df3492ed291831aa749d987d0e58e2500fa6c5cafd2bb4bfba23d34a60bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page