Skip to main content
command_manager
===================


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.

Installation
-------------
Install using `pip`...

pip install command_manager

Using
-------------------
Create a Python package anywhere in your application.

For example, the package `commands` and the entry point `manager.py`

.
├── commands
│ ├── __init__.py
│ └── my_first_command.py
├── src
└── manager.py

In `manage.py` 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"])
manager.run()

In `my_first_command.py` 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):
self.logger.info("START")
print "Hello Word: arg1={arg1} arg2={arg2}".format(**kwargs)
self.logger.info("END")

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

Now call `manage.py` from the console.
![python manage.py](/asserts/manage.png)

Call our command `my_first_command.py`
![python manage.py my_first_command](/asserts/command_call.png)

Metadata

Release files for command_manager 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for command_manager 1.2.0
File Size Uploaded Provenance Actions
command_manager-1.2.0.tar.gz 4.5 kB Without provenance Details for command_manager-1.2.0.tar.gz

Release files / command_manager-1.2.0.tar.gz

Download URL command_manager-1.2.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a73df3b5bc81a50269354847bd59f7ba046335e5d30f4d1eabd629a67aa02db3
BLAKE2b-256 checksum
How to use checksums
f981df3eace50a657ccf0e407632dc90ef810eea4a6b62d964819f1ef769bd47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for command_manager 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page