No project description provided
Project description
django-commands
Table of Contents
Installation
pip install django-commands2
add django_commands to INSTALLED_APPS, and logging
INSTALLED_APPS = [
...
'django_commands',
]
LOGGING = {
"loggers": {
"django_commands": {
...your custom level, handles config...
}
}
}
Usage
AutoLogCommands
any exception will be logged in the autologcommand
<yourapp/management/commands/command_name.py>
from django_commands import AutoLogCommand
class Command(AutoLogCommand):
def handle(self):
<write your code, any exception will be logged>
MultiTimesCommand
MultiTimesCommand will run multi times according to INTERVAL
and MAX_TIMES
. You can easily use this command to realize a crontab job every 1 second.
class Command(MultiTimesCommand):
INTERVAL = 1 # default 1
MAX_TIMES = 60 # default 60
def handle(self):
<this handle function will run 60 times>
This command does not consider the running time of your code. It will just run 60 times, and during each execute, wait 1 second
DurationCommand(AutoLogCommand):
DurationCommand will run your commands over and over again until the running time exceed the configuration
import datetime
class Commmand(DurationCommand):
INTERVAL = 1
DURATION = datetime.timedelta(minutes=1)
def handle(self, *args, **kwargs):
<your code>
License
django-commands
is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_commands2-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0656c9a4f5f6040c93427d0f3bcf32ef54d16e8b53a22a2c41435e00f0a11c4e |
|
MD5 | 3f12d01b7a81b65c12ff74d97be726bf |
|
BLAKE2b-256 | fdfd86c946302c7b18865077fb2b6ceab758e92a4a8914c24a5b40c8dbc38728 |