Skip to main content

A Django app to resistrict custom management command execution.

Project description

Cmd Controller

cmd_controller is a Django app to help run the custom management command in a more convenient way, Most of the time during deployment, develpers need to run some django management scripts, some script need to run only once and some need to run again and again. Running some scripts again and again may corrupt the application. The cmd_controller help to mark a script reentrant, while during the creation of the script and skips the scripts which are not reentrant.

Quick start

  1. Add "cmd_controller" to your INSTALLED_APPS setting like this:: INSTALLED_APPS = [ ... 'cmd_controller', ]

  2. Run python manage.py migrate to create the cmd_controller models.

  3. How to use it. import cmd_utils import check_command in your custom django command, and decerate the handle method and pass the script name as first parameter and Boolean value as second parameter. Pass True if the script can run again and again(reentrant), False for scripts run only once.

    @check_command(os.path.basename(file).split(".")[0], ) # need to run scripts multiple times @check_command(os.path.basename(file).split(".")[0], ) # should run only once.

app/management/commands/<custom_command.py>

if the script should run only once.

import os from django.core.management.base import BaseCommand from cmd_controller.cmd_utils import check_command

class Command(BaseCommand): help = 'test custom command'

@check_command(os.path.basename(__file__).split(".")[0], False)
def handle(self, *args, **options):
    # your custom command logic

if the script is reentrant

class Command(BaseCommand): help = 'test custom command'

@check_command(os.path.basename(__file__).split(".")[0], True)
def handle(self, *args, **options):
    # your custom command logic

run the script

python manage.py custom_command.py

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

django-cmd-controller-0.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file django-cmd-controller-0.1.tar.gz.

File metadata

  • Download URL: django-cmd-controller-0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2

File hashes

Hashes for django-cmd-controller-0.1.tar.gz
Algorithm Hash digest
SHA256 2bc0f99ee9c654e06fef255013cbd23d977962caf71bacdf6f95275ea0cf9f9e
MD5 bbf3fe269853eb1a0fd2dda37894adba
BLAKE2b-256 f4f47202c8d46572fd080e2476c38db19a3a6a7c500a3702144c57a1ffec412c

See more details on using hashes here.

Supported by

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