Discussion:
Working with kronos
Joel Mathew
2018-11-22 07:48:22 UTC
Permalink
I was trying the basic django-kronos command to test:
I did pip3 install django-kronos,

myproject/myapp/cron.py:
import kronos
import random

@kronos.register('* * * * *')
def complain():
complaints = [
"I forgot to migrate our applications's cron jobs to our new server! Darn!",
"I'm out of complaints! Damnit!"
]

print random.choice(complaints)

In my myproject/myproject/settings.py:

INSTALLED_APPS = [
'appointments.apps.AppointmentsConfig',
'clinic.apps.ClinicConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'bootstrap4',
'widget_tweaks',
'parsley',
'session_security',
'kronos'
]

Ran:
./manage.py runserver
I expected the dev server to throw up a message every minute. Nothing seems
to be happening.

Sincerely yours,

Joel G Mathew
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_9TOrybmhDJhG%2BB%3DsmScROAA1s4vJn2xmqaYbDtBNeerQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-22 13:11:35 UTC
Permalink
https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron

sounds like you need to run a register management command first.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bc4a5948-8e8d-45c8-8a7c-522e482680bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joel Mathew
2018-11-22 14:04:22 UTC
Permalink
I understood the documentation to mean that either we can create management
commands and register with cronos, or create cron.py.
Sincerely yours,

Joel G Mathew
Post by Jason
https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron
sounds like you need to run a register management command first.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/bc4a5948-8e8d-45c8-8a7c-522e482680bc%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/bc4a5948-8e8d-45c8-8a7c-522e482680bc%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_9XHEiRgkzG_16jz-CXB%2BE5fQ_PjYOMn6F1evbDEGEXaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-23 03:36:08 UTC
Permalink
the documentation is ambiguous in that regard. that said, I feel it says
you can register the cron tasks either way, but it doesn't do anything to
actually install the commands. you can see the code of the installtasks
management command:

https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py

which then runs the functions in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154

as you can see there, it uses the python crontab package to install the
crontab task.

Furthermore, in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
you can see what exactly the decorator consists of. It just adds the task
to a task registry set and doesn't do anything about actual installation.

as an aside, one of the things I've found to be pretty valuable is to look
at the project repository when it comes to questions like this. this is
not meant to be mean, and I'm sorry if it comes across that way. I didn't
know about this project before your question, but a brief look in the repo
revealed those links and functions above, which are the most likely answers
to your question above. you're asking good questions here and giving good
help in return, so if you internalize a method of investigating problems
like this, or have more specific and focused questions that your
investigations have unearthed.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joel
2018-11-23 03:41:05 UTC
Permalink
Yes, the language of the documentation certainly needs tweaking. I had done
the installtasks and it did work. Thank you very much for your help.
Now, I can have my app check for upcoming appointments and send reminders.
It was a much needed functionality.
Post by Jason
the documentation is ambiguous in that regard. that said, I feel it says
you can register the cron tasks either way, but it doesn't do anything to
actually install the commands. you can see the code of the installtasks
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py
which then runs the functions in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154
as you can see there, it uses the python crontab package to install the
crontab task.
Furthermore, in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
you can see what exactly the decorator consists of. It just adds the task
to a task registry set and doesn't do anything about actual installation.
as an aside, one of the things I've found to be pretty valuable is to look
at the project repository when it comes to questions like this. this is
not meant to be mean, and I'm sorry if it comes across that way. I didn't
know about this project before your question, but a brief look in the repo
revealed those links and functions above, which are the most likely answers
to your question above. you're asking good questions here and giving good
help in return, so if you internalize a method of investigating problems
like this, or have more specific and focused questions that your
investigations have unearthed.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_8W%3Dwk5PZv2MJbrcrbBokD7JwMCO3sfJq0V5CkDEzFLjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Joel
2018-11-23 03:45:59 UTC
Permalink
Thanks for the advise regarding understanding the issue in depth. My
initiation to python has been all of three months, and to django since two.
So far, I'd been scared to look under the hood, and any further than the
documentation. But I realize that it's not as daunting now add it used to
be. And coming from perl, I'm impressed at how cleaner it is.

Now I'm feeling power packed to examine the innards of django and python.
Thank you!
Post by Jason
the documentation is ambiguous in that regard. that said, I feel it says
you can register the cron tasks either way, but it doesn't do anything to
actually install the commands. you can see the code of the installtasks
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py
which then runs the functions in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154
as you can see there, it uses the python crontab package to install the
crontab task.
Furthermore, in
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
you can see what exactly the decorator consists of. It just adds the task
to a task registry set and doesn't do anything about actual installation.
as an aside, one of the things I've found to be pretty valuable is to look
at the project repository when it comes to questions like this. this is
not meant to be mean, and I'm sorry if it comes across that way. I didn't
know about this project before your question, but a brief look in the repo
revealed those links and functions above, which are the most likely answers
to your question above. you're asking good questions here and giving good
help in return, so if you internalize a method of investigating problems
like this, or have more specific and focused questions that your
investigations have unearthed.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_9zVznFM3pp3rG1%3DrGepULA6TmzmaefDSMsRfWEv-M25w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-23 13:50:21 UTC
Permalink
:-) Good! I know it can be intimidating, have been there a few times
before. But it gets easier the more you do it!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cc000c15-ad6d-4ca8-8f55-f3cbbb96dd7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...