| 1140 | def runjobs(which=None): |
| 1141 | "Runs scheduled maintenance operations defined by the installed applications" |
| 1142 | from django.core import signals |
| 1143 | from django.db import models |
| 1144 | from django.dispatch import dispatcher |
| 1145 | from django.conf import settings |
| 1146 | |
| 1147 | if which is None or which == 'help': |
| 1148 | print "run scheduled maintenance operations. Please specify 'hourly', 'daily', 'weekly' or 'monthly' " |
| 1149 | else: |
| 1150 | for app_name in settings.INSTALLED_APPS: |
| 1151 | try: |
| 1152 | __import__(app_name + '.management', '', '', ['']) |
| 1153 | except ImportError: |
| 1154 | pass |
| 1155 | |
| 1156 | for app in models.get_apps(): |
| 1157 | |
| 1158 | if which == 'hourly': |
| 1159 | dispatcher.send(signal=signals.run_hourly_jobs, sender=app, app=app) |
| 1160 | elif which == 'daily': |
| 1161 | dispatcher.send(signal=signals.run_daily_jobs, sender=app, app=app) |
| 1162 | elif which == 'weekly': |
| 1163 | dispatcher.send(signal=signals.run_weekly_jobs, sender=app, app=app) |
| 1164 | elif which == 'monthly': |
| 1165 | dispatcher.send(signal=signals.run_monthly_jobs, sender=app, app=app) |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | runjobs.args="[hourly daily weekly monthly]" |
| 1171 | runjobs.help_doc = "Runs scheduled maintenance operations defined by the installed applications" |
| 1172 | |
| 1173 | |