Giter VIP home page Giter VIP logo

django-chroniker's People

Contributors

andy-r avatar asottile avatar avoine avatar billyquith avatar broxeph avatar chrisspen avatar christianbundy avatar darkwizz avatar diegofcoelho avatar fort-healper avatar jamesoutterside avatar jayvdb avatar junejie avatar laurensbosscher avatar mhlut avatar nocarryr avatar noisy avatar oleg-efrontier avatar pratyushmittal avatar pyup-bot avatar raistlin7447 avatar timini avatar yamaomaoen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-chroniker's Issues

Timezone Support

I have noticed that chroniker if following UTC time for both scheduling and recalculating dates and I was wondering if you could add support to provide a standard timezone or get it from django when convenient.

My settings.py are properly configured:

TIME_ZONE = 'America/Fortaleza'
USE_I18N = True
USE_L10N = True
USE_TZ = True

But I believe chroniker itself is responsible for calculating the time shift between zones. At least is what I believe this StackOverFlow user has shown when explaining about a related problem (not to chroniker) in this answer.

Did I miss something during chroniker installation?

Freezing entire chroniker

Got an issue where a job seems to stall and then freezes entire django-chroniker so no jobs will run untill it it times out after ~8 hours.

Jobs will just be listed as "Due" but are unable to run untill the job that is stuck with is_fresh =False gets removed.

Error : select_for_update cannot be used outside of a transaction.

Hello,

I have this error with the last chroniker version :

Django Version: 1.6.5
Exception Type: TransactionManagementError
Exception Value:

select_for_update cannot be used outside of a transaction.

/usr/local/venv/lib/python2.7/site-packages/chroniker/models.py in is_due

        return q.exists()
...

▼ Local vars
Variable Value
q

Error in formatting: select_for_update cannot be used outside of a transaction.

BR

Matt

Missing migration

Just in case #56 doesn't get merged, I wanted to document the problem: it looks like there's a missing chroniker migration, so this is what happens when we install django-chroniker on the system for the first time.

$ ./manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: django_extensions, rest_framework, debug_toolbar, staticfiles, solo, messages
  Apply all migrations: foobar, chroniker, auth, downtime, admin, contenttypes, sites, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
$ ./manage.py makemigrations
Migrations for 'chroniker':
  0002_auto_20160520_1104.py:
    - Alter field frequency on job
    - Alter field hostname on job
    - Alter field maximum_log_entries on job
    - Alter field monitor_error_template on job
    - Alter field dependee on jobdependency
    - Alter field dependent on jobdependency
    - Alter field wait_for_completion on jobdependency
    - Alter field wait_for_next_run on jobdependency
    - Alter field wait_for_success on jobdependency
    - Alter field duration_seconds on log
$ ./manage.py migrate       
Operations to perform:
  Synchronize unmigrated apps: debug_toolbar, messages, django_extensions, solo, rest_framework, staticfiles
  Apply all migrations: downtime, chroniker, auth, sessions, admin, foobar, contenttypes, sites
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying chroniker.0002_auto_20160520_1104... OK

Instead of having just being able to use the migrations bundled with this package, we need to run manage.py makemigrations to create the django-chroniker migrations, and then run `manage.py migrate to get them to work.

debugging stalled jobs?

Suddenly I started getting some issues with a lot ofor jobs stalling all the time even though they have been running fine for months. Jobs also get stuck on "due" even though cron gets called as it should. It is impossible to debug as I have no idea where to start looking, is there anyway we cold improve stalled jobs to print some log of what happened before the stall or alike? Or what is the best way to debug a stall?

Initial Update

Hi 👊

This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.

Once you have closed this issue, I'll create seperate pull requests for every update as soon as I find one.

That's it for now!

Happy merging! 🤖

Viewing Jobs in Admin causes ValueError

I'm using the 0.6.7 version of the library and Django 1.6.5.

As you can see from the output below the obj.next_run returns a native datetime which raises "ValueError: astimezone() cannot be applied to a naive datetime".

Here is an image of this output: https://www.evernote.com/shard/s27/sh/a5470979-8bde-438a-9379-25abd2d83006/b305f3fd01372915a68cbc40b2f75a5d

File "/Users/scott/.virtualenvs/gmp/lib/python2.7/site-packages/chroniker/admin.py", line 279, in get_timeuntil
value = capfirst(dateformat.format(timezone.localtime(obj.next_run), format))
[console ready]

obj.next_run
datetime.datetime(2014, 8, 12, 2, 33, 34)

File "/Users/scott/.virtualenvs/gmp/lib/python2.7/site-packages/django/utils/timezone.py", line 261, in localtime
value = value.astimezone(timezone)
[console ready]

timezone
<DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD>

ValueError: astimezone() cannot be applied to a naive datetime

django 1.11 import Problem

Problem on load:

File "/app/.heroku/python/lib/python3.5/site-packages/chroniker/admin.py", line 34, in <module> from chroniker.widgets import ImproveRawIdFieldsFormTabularInline File "/app/.heroku/python/lib/python3.5/site-packages/chroniker/widgets.py", line 5, in <module> from django.forms.widgets import Select, TextInput, flatatt ImportError: cannot import name 'flatatt'

Discussed and fixed as:
carltongibson/django-filter#673

Stdout and sdterr are shown as bytes instead of strings in emails

This is an output of ls -la:

selection_069

For sure this is a matter of encoding. When I found that problem, I applied a solution founded here.

https://github.com/noisy/django-chroniker/commit/b55a08750a2ef4011e0e1ad06d0bb37b57f4b179

It works as expected:

selection_070

However later I tried to find why those outputs are bytes in the first place.

I found that this commit https://github.com/noisy/django-chroniker/commit/5b21abbe4ea5f67e91143ed538284a8d0a1bfc8a also solve this issue.

I am not sure, why that code was added in the first place, so I need your suggestion @chrisspen which fix is better.

Job doesn't recover when no longer fresh

What should happen when a job is running and is no longer fresh? It seems that the job just never runs again. Using Force Stop doesn't resolve the issue as the thread has already terminated for some unknown reason. Once a job is in this state, it seems the only option is to modify the database. Am I missing something?

Custom Email System

We are using a custom system for sending emails. We would therefore also like to use that with Chroniker to get the notifications about failed runs. The idea is to add a further setting that allows the user to define a send_mail method that accepts the same parameters as send_mail from Django. If it is set that one is used instead of the one from Django.

I'm willing to implement this functionality. Are you interested in merging that functionality into chroniker?

I'm looking forward to feedback as well as different approaches to the problem.

bin/chroniker does not get settings from os.environ even though it checks for them

bin/chroniker does not get settings from os.environ even though it checks for them

 settings = args.settings
    if not settings and not os.environ.has_key('DJANGO_SETTINGS_MODULE'):
        if not project_dir:
            # Well, we can't do anything...
            logger.error("Error: You must either set the environmental "
                         "variable DJANGO_SETTINGS_MODULE or pass it as "
                         "an argument")
            sys.exit(0)

        # We'll assume the settings file is in the project directory
        settings = "%s.settings" % os.path.basename(project_dir)

  # Now assign the settings
  os.environ['DJANGO_SETTINGS_MODULE'] = settings

Datetime naive and aware

After making datetime timezone aware in my system, chroniker seem to fail when i try to update one of my cron jobs.

TypeError at /admin/chroniker/job/2/
can't compare offset-naive and offset-aware datetimes
Request Method: POST
Request URL: http://localhost:8080/admin/chroniker/job/2/
Django Version: 1.6.5
Exception Type: TypeError
Exception Value:
can't compare offset-naive and offset-aware datetimes
Exception Location: C:\Python27\lib\site-packages\dateutil\rrule.py in after, line 199
Python Executable: C:\Python27\python.exe
Python Version: 2.7.6

Exception:

C:\Python27\lib\site-packages\chroniker\models.py in save
next_run = self.next_run or timezone.now()
tz = timezone.get_default_timezone()
    try:
        self.next_run = self.rrule.after(timezone.make_aware(next_run, tz))
    except ValueError:
        self.next_run = timezone.make_aware(
        **self.rrule.after(timezone.make_naive(next_run, tz)), tz)**
    except TypeError:
        self.next_run = timezone.make_aware(

Local Vars:
next_run = datetime.datetime(2014, 6, 27, 14, 31, 4, tzinfo=<DstTzInfo 'Europe/Copenhagen' CEST+2:00:00 DST>)
j = Job: 2 - 1 - localhost - grab - disabled
tz = DstTzInfo 'Europe/Copenhagen' CET+1:00:00 STD
self = Job: 2 - 1 - localhost - grab - due
args = ()
kwargs = {}

C:\Python27\lib\site-packages\dateutil\rrule.py in after
gen = self
if inc:
    for i in gen:
if i >= dt:
    return i
else:
    for i in gen:
        **if i > dt:**
            return i
    return None
def between(self, after, before, inc=False):
    if self._cache_complete:
        gen = self._cache

Local Vars:
i = datetime.datetime(2014, 6, 27, 14, 31, 4, tzinfo=<DstTzInfo 'Europe/Copenhagen' CEST+2:00:00 DST>)
dt = datetime.datetime(2014, 6, 27, 14, 31, 4)
inc = False
gen = dateutil.rrule.rrule object at 0x0000000007AE6320
self = dateutil.rrule.rrule object at 0x0000000007AE6320

Syntax Error chroniker_tags.py line 34: python 3.4.2

Raised syntax error on line 34: chroniker_tags.py. On a clean install with python 3.4.2.

I edited the line as follows:

  try:
        # Splitting by None == splitting by spaces.
        tag_name, object_id = token.contents.split(None, 1)
    except ValueError:
       # line below causing syntax error python 3.4.2
       # raise template.TemplateSyntaxError, "%r tag requires one argument" % token.contents.split()[0]
       raise template.TemplateSyntaxError
    return RunJobURLNode(object_id)

Capturing job exceptions with e.g. Sentry

I use Sentry ( https://getsentry.com/welcome/ ) to track exceptions, but chroniker handles exceptions from jobs itself before they reach the Sentry/raven code that sends them

I'm wondering how best to fix this:

  1. Wrap the code of every management command in try/except and explicitly call Sentry in except - ugly!
  2. Monkey patch Job.handle_run - also ugly!
  3. Have an option to not handle the exceptions, probably per job - ugly, if not impossible due to the clean up code needed if the job fails
  4. Have chroniker run the job through the shell - that way the exception would be in it's own process and not effect the chroniker process, but probably ugly and creates more problems
  5. Have chroniker detect if sentry is installed, and pass the exception to it - I think this is the best solution, and could be extended to support other systems

Do you agree, and if so, how would you prefer it be implemented? Create a handle_exception() function in utils to pass errors to, with a function for each exception handling software to check if it's installed and pass exceptions to it?

Max Log Entries not respected

All logs are kept until task entry is opened and saved. Otherwise, log entries will increase indefinitively.
No warning or error is triggered by Django.

1

Error when calling change_form to add a job

I use the custom admin skin django-suit.
There the view button is not hidden when adding a job. So this method is called anyway:

admin.py: lines 225-230:

def view_logs_button(self, obj):
    q = obj.logs.all()
    url = get_admin_changelist_url(Log)
    return ('<a href="%s?job=%d" target="_blank">'
        '<input type="button" value="View %i" /></a>') % \
        (url, obj.id, q.count())

That causes the error

%d format: a number is required, not NoneType

because obj.id is not set yet.
Is it possible to change it to

def view_logs_button(self, obj):
    if obj.id:
        q = obj.logs.all()
        url = get_admin_changelist_url(Log)
        return ('<a href="%s?job=%d" target="_blank">'
            '<input type="button" value="View %i" /></a>') % \
            (url, obj.id, q.count())
    else:
            return ''

?

Error downloading stdout/stderr logs in Django 1.7

Admin receives error: init() got an unexpected keyword argument 'mimetype'

when attempting to download stdout/stderr log files when running Django 1.7

Quick fix is to change the named argument 'mimetype' on line 583 and 592 in chroniker/admin.py to 'content_type'

BTW, Nice work on chroniker - very useful!

Thanks,
Matt

Django 1.6 compatibility

Hi,

You need to modify in admin.py this line :
from django.conf.urls.defaults import patterns, url

by this one :
from django.conf.urls import patterns, url

It is also compatible with django 1.5

Matt

On Adding new Job: 1235, "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'"

Hi,

I just tried django-chroniker for the first time and I like the possibility to manage cronjobs via the admin interface. Sadly I am getting the following error whenever I want to add a job via admin.
Can't seem to pin the problem here. Is django-chroniker compatible with MySQL?

Traceback

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/chroniker/job/add/

Django Version: 1.10.2
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django_comments',
 'django_comments_xtd',
 'rosetta',
 'compressor',
 'Bildungsprojekt',
 'easy_pdf',
 'widget_tweaks',
 'haystack',
 'robots',
 'CustomerService',
 'chroniker']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'projectaxel.middleware.MyMiddleware']



Traceback:

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py" in execute
  110.             return self.cursor.execute(query, args)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  250.             self.errorhandler(self, exc, value)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  42.         raise errorvalue

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  247.             res = self._query(query)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _query
  411.         rowcount = self._do_query(q)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _do_query
  374.         db.query(q)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/connections.py" in query
  270.             _mysql.connection.query(self, query)

The above exception ((1235, "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'")) was the direct cause of the following exception:

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper
  544.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner
  211.             return view(request, *args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in add_view
  1509.         return self.changeform_view(request, None, form_url, extra_context)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/lib/python3.5/contextlib.py" in inner
  30.                 return func(*args, **kwds)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in changeform_view
  1449.                 self.save_model(request, new_object, form, not add)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in save_model
  1007.         obj.save()

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/chroniker/models.py" in save
  854.             for o in qs:

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
  256.         self._fetch_all()

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all
  1087.             self._result_cache = list(self.iterator())

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
  54.         results = compiler.execute_sql()

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
  835.             cursor.execute(sql, params)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/django/db/backends/mysql/base.py" in execute
  110.             return self.cursor.execute(query, args)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  250.             self.errorhandler(self, exc, value)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  42.         raise errorvalue

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in execute
  247.             res = self._query(query)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _query
  411.         rowcount = self._do_query(q)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/cursors.py" in _do_query
  374.         db.query(q)

File "/home/devcarl/PycharmProjects/newest_projectaxel/projectaxel/myvenv/lib/python3.5/site-packages/MySQLdb/connections.py" in query
  270.             _mysql.connection.query(self, query)

Exception Type: NotSupportedError at /admin/chroniker/job/add/
Exception Value: (1235, "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'")

What about wiki, mm?

I'm sorry, if it's not the right place to write about it, but:

I'd really like to use your extension, but, unfortunately, I didn't manage to find django admin parameters guide yet (in particular, I can't understand how to make jobs be performed not in every minute, but in different periods of time and what are "options" in admin job creation page?..)

If I'm mistaken and what I need lays somewhere next to me, please, tell me about it)

bin/chroniker: ImportError: cannot import name setup_environ

Traceback (most recent call last):
  File "/home/esldj/.pyenv/versions/esldj/bin/chroniker", line 8, in <module>
    execfile(__file__)
  File "/home/esldj/.pyenv/versions/esldj/src/django-chroniker/bin/chroniker", line 81, in <module>
    from django.core.management import call_command, setup_environ
ImportError: cannot import name setup_environ

setup_environ was deprecated in django 1.4, https://docs.djangoproject.com/en/dev/releases/1.4/#django-core-management-setup-environ

Monitor status pic url incorrect

The url to the status icon in the monitor change_list is incorrect, because it points to '/media/admin...' but the admin static file are in STATIC_URL+'admin/...'

problem with migrate

After a fresh install of django-chroniker using pip install django-chroniker, and adding it to INSTALLED_APPS. when i run python manage.py migrate, i get the following error:

@transaction.commit_manually
AttributeError: 'module' object has no attribute 'commit_manually'

pip install will automatically install django 1.8.

What version of Django would you recommend installing django-chroniker with ?

Release schedule

Hey Chris! I noticed that the latest version in PyPi is still 0.8.5, but the version in GitHub is 0.9.2. Do you do regular package updates, or should we be building from source? Thanks!

Extrange error

Hi.
I got an error in a minimal 1.9 or 1.10 django project with a simple 'ls' command and a python 2.7
It works without jobs but when I add one...
TypeError: 'Queue' object is not callable
Did I forgot anything in the installation process?, seems really easy
I had to change line 69, but i dont know side-effects
...force_run = None #stderr_queue('force_run', False)

Thanks in advance.

Commands out of sync

I seem to get a commands out of sync error pretty often, been debugging my code and cant really see it being located there

The job failed to run. The exception was :

(2014, "Commands out of sync; you can't run this command now")

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/chroniker/models.py", line 1083, in handle_run
lock_file = heartbeat.lock_file.name if heartbeat and heartbeat.lock_file else '',

File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 493, in update
rows = query.get_compiler(self.db).execute_sql(None)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 980, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)

File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)

File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)

File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue

ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

Task which Triggers Multiprocessing

Is it possible to trigger a multiprocessing task? I tried but run it as a django management command makes it finish with no fail (and also no task performed) after a few seconds.

m2m problem with User class

chroniker.job: Accessor for m2m field 'subscribers' clashes with related m2m field 'User.job_set'. Add a related_name argument to the definition for 'subscribers'.

Issue with Python 3

Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/home/administrator/workspace/fan/adops/eggs/django_chroniker-0.8.1-py3.4.egg/chroniker/models.py", line 168, in run
    self.lock_file.write(str(time.time()))
  File "/usr/lib/python3.4/tempfile.py", line 538, in func_wrapper
    return func(*args, **kwargs)
TypeError: 'str' does not support the buffer interface

You can fix with replacing models.py:168 with self.lock_file.write(str(time.time()).encode('utf-8'))

Fail with BaseCommand.options_list in django 1.10

Hello, I have a problem with chroniker in django 1.10. When I try to run job I get error:
"type object 'BaseCommand' has no attribute 'option_list'" in
chroniker/management/commands/cron.py", line 258, in Command
option_list = BaseCommand.option_list + (

Can somebody help?

Thanks

Database lock

If the database is very busy with other stuff while saving, i have often experienced that chroniker is unable to release lock on the database, leaving the module in a state where no cron's can be run, untill the database releases the lock due to timeout.

Is there any workaround this?

Keep getting a psutil NoSuchProcess

Hi,

Been trying to use chroniker in our system, however after a command has been run i get the following:
Recording log...
Job done.

Process <JobProcess(16 - 2 - id: 4 Footstore - 11 minutes, stopped)> ended.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
All jobs complete!
[2014-06-10 13:59:15] Running due jobs...
Exception in thread Thread-10:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 810, in bootstrap_inner
self.run()
File "C:\Python27\lib\site-packages\chroniker\management\commands\cronserver.py", line 21, in run
call_command('cron')
File "C:\Python27\lib\site-packages\django\core\management__init
.py", line 159, in call_command
return klass.execute(_args, *defaults)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 285, in execute
output = self.handle(args, *options)
File "C:\Python27\lib\site-packages\chroniker\management\commands\cron.py", line 279, in handle
kill_stalled_processes(dryrun=False)
File "C:\Python27\lib\site-packages\chroniker\management\commands\cron.py", line 40, in kill_stalled_processes
p = psutil.Process(pid)
File "C:\Python27\lib\site-packages\psutil__init
.py", line 296, in init
self.init(pid)
File "C:\Python27\lib\site-packages\psutil__init
.py", line 331, in _init
raise NoSuchProcess(pid, None, msg)
NoSuchProcess: no process found with pid 5824

For some reason it is unable to find the process after it has been run, should i be doing something special in the command to avoid this ? It keeps trying to do something with this process and i will have to manually close the terminal to stop it

Tried reinstalling and re-migrating several times without a solution.

Not naive datetime (tzinfo is already set)

On adding a job with simply an interval of every minute

ValueError at /admin/chroniker/job/add/
Not naive datetime (tzinfo is already set)
Request Method: POST
Request URL:    http://devvm-ase.dev:8000/admin/chroniker/job/add/
Django Version: 1.6.1
Exception Type: ValueError
Exception Value:    
Not naive datetime (tzinfo is already set)
Exception Location: /home/tech/.pyenv/versions/esldj-all-in-one-2.7.6/lib/python2.7/site-packages/pytz/tzinfo.py in localize, line 304
/home/tech/.pyenv/versions/esldj-all-in-one-2.7.6/lib/python2.7/site-packages/chroniker/models.py in save
                    self.next_run = self.rrule.after(timezone.make_aware(next_run, tz)) 
/home/tech/.pyenv/versions/esldj-all-in-one-2.7.6/lib/python2.7/site-packages/django/utils/timezone.py in make_aware
        return timezone.localize(value, is_dst=None) 

python3 support

Hello,

when running the chroniker -e ... cli command with python3 we can see a message like this:

Traceback (most recent call last):
  File "/usr/bin/chroniker", line 61, in <module>
    execfile(virtualenv, dict(__file__=virtualenv))
NameError: name 'execfile' is not defined

To make it works with python3 I just replaced the execfile function with exec function according to this: http://stackoverflow.com/a/6357418/1732775

Have some troubles in Windows on cron launch

(myenv) C:\Users\l.a.byakov\PycharmProjects\admin_prod>python manage.py cron --s
ettings=tcbadmin.settings_prod
System check identified some issues:

WARNINGS:
tcb.Agent.created: (fields.W161) Fixed default value provided.
        HINT: It seems you set a fixed date / time / datetime value as default f
or this field. This may not be what you want. If you want to have the current da
te as default, use `django.utils.timezone.now`
1 total stale jobs.
Checking stale job 1: 1 - Update Training status - running
Process with PID None is not elligible for killing.
b'Running job 1 1 - Update Training status - due.'
Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\django\core\managemen
t\__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\django\core\managemen
t\__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\django\core\managemen
t\base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\django\core\managemen
t\base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\chroniker\management\
commands\cron.py", line 363, in handle
    sync=options['sync'],
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\chroniker\management\
commands\cron.py", line 216, in run_cron
    proc.start()
  File "D:\PythonProjects\TCBAdmin\myenv\lib\site-packages\chroniker\utils.py",
line 403, in start
    super(TimedProcess, self).start(*args, **kwargs)
  File "D:\Python35\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "D:\Python35\lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Python35\lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)
  File "D:\Python35\lib\multiprocessing\popen_spawn_win32.py", line 66, in __ini
t__
    reduction.dump(process_obj, to_child)
  File "D:\Python35\lib\multiprocessing\reduction.py", line 59, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot serialize '_io.TextIOWrapper' object

(myenv) C:\Users\l.a.byakov\PycharmProjects\admin_prod>Traceback (most recent ca
ll last):
  File "<string>", line 1, in <module>
  File "D:\Python35\lib\multiprocessing\spawn.py", line 100, in spawn_main
    new_handle = steal_handle(parent_pid, pipe_handle)
  File "D:\Python35\lib\multiprocessing\reduction.py", line 86, in steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Отказано в доступе

Can you help me with such kind of error?
I tried the same thing on mac and linux but everything is ok. I blame Windows. Hope you can help me. thanks.

Cron Every other day

Is it possible to set an alternated day cron task?
I didnt find how to save a */2 daily entry..

Error jobs getting stuck

Is it correct that jobs that error get stuck?

e.g. I have a job at the moment that errors every evening, which gets stuck and does not continue to run

When the job is stuck it has:

  • a pid that no longer exists
  • due: false
  • fresh: false
  • success: true (even though it triggered a job failed to run mail)

raw_command raise io.UnsupportedOperation: fileno

using raw_command always cause this problem:

The job failed to run.  The exception was :

fileno


Traceback (most recent call last):

  File "/usr/local/lib/python3.5/site-packages/chroniker/models.py", line 1151, in handle_run
    stderr=sys.stderr)

  File "/usr/local/lib/python3.5/subprocess.py", line 560, in call
    with Popen(*popenargs, **kwargs) as p:

  File "/usr/local/lib/python3.5/subprocess.py", line 914, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)

  File "/usr/local/lib/python3.5/subprocess.py", line 1400, in _get_handles
    c2pwrite = stdout.fileno()

io.UnsupportedOperation: fileno

Environment:

Python 3.5.1
Django==1.9.4

The Jobs are always due unless I force them with cron.

Hi There,

Congratulations for the work.

I am having some issues understanding how the app works:

I have created a Job I want to be executed every 5 minutes. So I set a custom manage command, I set the next run to today and now (if I don't put this I got an error).

The first strange behaviour is that the the hour is set correctly according to my local time (Spain), but the server is in Amsterdam and I think it uses UTC. So when I set my current local time on the widget and save, the time left appears to be 2 hours in the future. I also set the params to 'interval:5' and frequency to Minutely. After that 2 hours the job will appear as due.

If I force the job with the command management cron, the job will be executed, but it will appear as due anyway.

I think there are three causes that this is failing:

1- Timezones are not correctly configured?
2- I did not understand how to fill a Job correctly ;)
3- Other.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.