Skip to content

Commit

Permalink
Merge pull request #94 from Tivix/optparse_deprecated_fix
Browse files Browse the repository at this point in the history
Django 1.10 Compatibility
  • Loading branch information
maxim-kht authored Sep 14, 2016
2 parents 225f362 + 518965a commit 57bd912
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ python:
- "2.7"
- "3.4"
env:
- DJANGO=1.7.11 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.7.11 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.7.11 DJANGO_SETTINGS_MODULE='settings_mysql'
- DJANGO=1.8.7 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.8.7 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.8.7 DJANGO_SETTINGS_MODULE='settings_mysql'
- DJANGO=1.9 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.9 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.9 DJANGO_SETTINGS_MODULE='settings_mysql'
- DJANGO=1.10.1 DJANGO_SETTINGS_MODULE='settings_sqllite'
- DJANGO=1.10.1 DJANGO_SETTINGS_MODULE='settings_postgres'
- DJANGO=1.10.1 DJANGO_SETTINGS_MODULE='settings_mysql'
addons:
- postgresql: "9.3"
install:
Expand Down
25 changes: 18 additions & 7 deletions django_cron/management/commands/runcrons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from optparse import make_option
import traceback
from datetime import timedelta

Expand All @@ -16,18 +15,30 @@


class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--force', action='store_true', help='Force cron runs'),
make_option('--silent', action='store_true', help='Do not push any message on console'),
)
def add_arguments(self, parser):
parser.add_argument(
'cron_classes',
nargs='*'
)
parser.add_argument(
'--force',
action='store_true',
help='Force cron runs'
)
parser.add_argument(
'--silent',
action='store_true',
help='Do not push any message on console'
)

def handle(self, *args, **options):
"""
Iterates over all the CRON_CLASSES (or if passed in as a commandline argument)
and runs them.
"""
if args:
cron_class_names = args
cron_classes = options['cron_classes']
if cron_classes:
cron_class_names = cron_classes
else:
cron_class_names = getattr(settings, 'CRON_CLASSES', [])

Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changelog
=========
0.5.0
------

- Added support for Django 1.10

- Minimum Django version required is 1.8

- Use parser.add_argument() instead of optparse.make_option() in runcrons command


0.4.6
------

Expand Down
9 changes: 9 additions & 0 deletions settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
}
}

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {},
},
]

ROOT_URLCONF = 'test_urls'
SITE_ID = 1
STATIC_URL = '/static/'
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='django-cron',
version='0.4.6',
version='0.5.0',
author='Sumit Chachra',
author_email='[email protected]',
url='http://github.com/tivix/django-cron',
Expand All @@ -29,7 +29,7 @@
keywords='django cron',
zip_safe=False,
install_requires=[
'Django>=1.7.0',
'Django>=1.8.0',
'django-common-helpers>=0.6.4'
],
test_suite='runtests.runtests',
Expand Down
9 changes: 4 additions & 5 deletions test_urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# urls.py
from django.conf.urls import patterns, include
from django.conf.urls import include, url
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns(
'',
(r'^admin/', include(admin.site.urls)),
)
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]

0 comments on commit 57bd912

Please sign in to comment.