Skip to content

Commit

Permalink
chore: Apply Django's recommended app packaging guidelines.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcass77 committed Jul 16, 2020
1 parent 4da7795 commit 8ad28ed
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 59 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2016-2020

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.md
recursive-include docs *
91 changes: 38 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Django APScheduler
================================

** HELP NEEDED WITH MAINTENANCE **

If anyone feels up to helping maintain this package, please PM me and we can get you some privileges.

==================

[![Build status](http://travis-ci.org/jarekwg/django-apscheduler.svg?branch=master)](http://travis-ci.org/jarekwg/django-apscheduler)
[![codecov](https://codecov.io/gh/jarekwg/django-apscheduler/branch/master/graph/badge.svg)](https://codecov.io/gh/jarekwg/django-apscheduler)
Expand All @@ -13,13 +8,12 @@ If anyone feels up to helping maintain this package, please PM me and we can get

[APScheduler](https://github.com/agronholm/apscheduler) for [Django](https://github.com/django/django).

This little wrapper around APScheduler enables storing persistent jobs in the database using Django's ORM rather than requiring SQLAlchemy or some other bloatware.
This is a Django app that adds a lightweight wrapper around APScheduler. It enables storing persistent jobs in the database using Django's ORM.

Features in this project:
Features of this package includes:

* Work on both python2.* and python3+
* Manage jobs from Django admin interface
* Monitor your job execution status: duration, exception, traceback, input parameters.
* Get an overview of the jobs that have been scheduled via the Django admin interface.
* Monitor job execution and status via the Django admin interface

Installation
------------
Expand All @@ -28,82 +22,74 @@ Installation
pip install django-apscheduler
```

Usage
-----

* Add ``django_apscheduler`` to ``INSTALLED_APPS`` in your Django project settings, You can also specify a different
format for displaying runtime timestamps in the Django admin site using ``APSCHEDULER_DATETIME_FORMAT``:
```python
Quick start
-----------

* Add ``django_apscheduler`` to your ``INSTALLED_APPS`` setting like this:
```python
INSTALLED_APPS = (
...
"django_apscheduler",
)
```

* You can also specify a different format for displaying runtime timestamps in the Django admin site using ``APSCHEDULER_DATETIME_FORMAT``:
```python
APSCHEDULER_DATETIME_FORMAT = "N j, Y, f:s a" # Default
```

```
* Run `python manage.py migrate` to create the django_apscheduler models.

* Run migrations:
```python
./manage.py migrate
```
* Instantiate a new scheduler as you would with APScheduler. For example:
```python
```python
from apscheduler.schedulers.background import BackgroundScheduler

scheduler = BackgroundScheduler()
```
* Instruct the scheduler to use ``DjangoJobStore``:
```python
```

* Instruct the scheduler to use `DjangoJobStore`:
```python
from django_apscheduler.jobstores import DjangoJobStore

# If you want all scheduled jobs to use this store by default,
# use the name 'default' instead of 'djangojobstore'.
# If you want all scheduled jobs to use this store by default, # use the name 'default' instead of 'djangojobstore'.
scheduler.add_jobstore(DjangoJobStore(), 'djangojobstore')
```

* If you want per-execution monitoring, call register_events on your scheduler:
```python
```

* If you want per-execution monitoring, call `register_events` on your scheduler:
```python
from django_apscheduler.jobstores import register_events
register_events(scheduler)
```

It provides the following interface:
![](http://dl3.joxi.net/drive/2017/05/19/0003/0636/258684/84/bebc279ecd.png)
```

* Old job executions can be deleted with:
```python
```python
DjangoJobExecution.objects.delete_old_job_executions(604_800) # Delete job executions older than 7 days
```

* Register any jobs as you would normally. Note that if you haven't set ``DjangoJobStore`` as the ``'default'`` job store,
you'll need to include ``jobstore='djangojobstore'`` in your ``scheduler.add_job`` calls.
```

* **Don't forget to give each job a unique id. For example:**
```python
* Register any jobs as you would normally. Note that if you haven't set `DjangoJobStore` as the `'default'` job store,
then you will need to include `jobstore='djangojobstore'` in your `scheduler.add_job` calls.

* **Don't forget to give each job a unique id using the `id` parameter. For example:**
```python
@scheduler.scheduled_job("interval", seconds=60, id="job")
def job():
...
```
or use custom decorator for job registration. It will give id automatically:
```python
pass
```
or use the custom `register_job` decorator for job registration. This will assign a unique id automatically:
```python
from django_apscheduler.jobstores import register_job

@register_job("interval", seconds=60)
def job():
...
```
pass
```

* Start the scheduler:
```python
```python
scheduler.start()
```
```

A full example project can be found in the example dir. Code snippet:
A full example project can be found in the 'examples' folder. Code snippet:
```python
import time

Expand All @@ -123,5 +109,4 @@ register_events(scheduler)

scheduler.start()
print("Scheduler started!")

```
19 changes: 19 additions & 0 deletions django_apscheduler/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

This changelog is used to track all major changes to django_apscheduler.

## v0.4.0 (UNRELEASED)

**Enhancements**

- CI: drop coverage for Python 2.7 and Django <= 2.1, which are no longer maintained upstream.
- CI: add coverage for Python 3.7 and 3.8, as well as Django long term support (LTS) and the latest released versions.
- CI: un-pin dependency on agronholm/apscheduler#149, which has since been merged and released upstream.
- Rename Django `test_settings.py` file to prevent collision with actual test scripts.
- Clean up unused dependencies / update dependencies to latest available versions.
- Switch to Black code formatting.
- Align package layout with official [Django recommendations](https://docs.djangoproject.com/en/dev/intro/reusable-apps/#packaging-your-app)

**Fixes**

- Fix PEP8 code formatting violations.
27 changes: 27 additions & 0 deletions django_apscheduler/docs/releasing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Release procedures

Here we try to keep an up to date record of how new releases are made. This
documentation serves both as a checklist, to reduce the project's dependency on
key individuals, and as a stepping stone to more automation.

## Creating releases

1. Update changelog and commit it.

2. Merge the release branch (``develop`` in the example) into master:

git checkout master
git merge --no-ff -m "Release v0.3.0" develop

3. Tag the release:

git tag -a -m "Release v0.3.0" v0.3.0

4. Push to GitHub:

git push --follow-tags

5. Merge ``master`` back into ``develop`` and push the branch to GitHub.

6. Document the release on GitHub by clicking on the 'Releases' link on the landing page,
and editing the tag that was just created.
25 changes: 19 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
from setuptools import find_packages, setup
from os import path

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()

setup(
name="django-apscheduler",
version="0.4.0",
description="APScheduler for Django",
long_description=long_description,
long_description_content_type="text/markdown",
url="http://github.com/jarekwg/django-apscheduler",
author="Jarek Glowacki, Stas Kaledin",
author_email="[email protected], [email protected]",
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries :: Python Modules",
"Framework :: Django",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
],
keywords="django apscheduler django-apscheduler",
url="http://github.com/jarekwg/django-apscheduler",
author="Jarek Glowacki, Stas Kaledin",
author_email="[email protected], [email protected]",
license="MIT",
packages=find_packages(exclude=("tests",)),
install_requires=["django>=2.2", "apscheduler>=3.2",],
zip_safe=False,
Expand Down

0 comments on commit 8ad28ed

Please sign in to comment.