Skip to main content

Entry point for Python scripts

Project description


Entry point for Python scripts. Helps you structure additional scripts
of your application within one or more Python packages and call them
from one place.


Install using ``pip``...


pip install command_manager


Create a Python package anywhere in your application.

For example, the package ``commands`` and the entry point ````


├── commands
│ ├──
│ └──
├── src

In ```` add the following:


if __name__ == '__main__':
import logging.config # Optional for logging
from command_manager import Manager

LOGGING = { # Optional for logging
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s | %(asctime)s | %(module)s | %(message)s'
'handlers': {
'commands_handler': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'filename': os.path.join("logs", 'commands.log'),
'maxBytes': 100000,
'backupCount': 10,
'loggers': {
'commands.my_first_command': {
'handlers': ['commands_handler'],
'level': 'INFO',
'propagate': False

logging.config.dictConfig(LOGGING) # Optional for logging
manager = Manager(["commands"])

In ```` add the following:


from command_manager.commands import BaseCommand

class Command(BaseCommand):

description = "Simple command"

def add_arguments(self, parser):
parser.add_argument("--arg1", help="argument arg1")
parser.add_argument("--arg2", help="argument arg2")

def handle(self, *args, **kwargs):
print "Hello Word: arg1={arg1} arg2={arg2}".format(**kwargs)

**Warning:** The class must be called the ``Command`` and inherited
from ``BaseCommand``

Now call ```` from the console. |python|

Call our command ```` |python

.. |python| image:: /asserts/manage.png
.. |python my\_first\_command| image:: /asserts/command_call.png

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
command_manager-1.0.6.tar.gz (4.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page