django-command-stat

Django management command statistics


License
Unlicense
Install
pip install django-command-stat==2021.6.21

Documentation

Installation

$ pip install django-command-stat

How it works

collected statistics:

  • calls count
  • errors count
  • cpu time
  • memory
  • started, finished time

implementations:

  • StatCommand management command class
  • @command_stat decorator

settings.py

INSTALLED_APPS+=['django_command_stat']

migrate

$ python manage.py migrate

Examples

StatCommand

from django_command_stat.management.base import StatCommand

class Command(StatCommand):
    def handle(self,*args,**options):
        # your code

@command_stat decorator

from django_command_stat.decorators import command_stat

class Command(BaseCommand):
    @command_stat
    def handle(self,*args,**kwargs):
        ...
class BaseCommand(BaseCommand):
    def execute(self,*args,**kwargs):
        return command_stat(self.handle)(self,*args,**kwargs)
from django.core.management import call_command

command_stat(call_command)(name,*args,**options)