Permalink
Browse files

Merge branch 'master' of https://github.com/django-extensions/django-…

  • Loading branch information...
2 parents 0cddae7 + e9b5e14 commit 2ac5b7365d82cb8e822d9984e10176bcc39b9c4a x committed Mar 20, 2012
@@ -9,13 +9,13 @@ class Command(LabelCommand):
help="List all jobs with their description"),
)
help = "Runs scheduled maintenance jobs."
- args = "[minutely hourly daily weekly monthly yearly]"
+ args = "[minutely quarter_hourly hourly daily weekly monthly yearly]"
label = ""
requires_model_validation = True
def usage_msg(self):
- print "Run scheduled jobs. Please specify 'minutely', 'hourly', 'daily', 'weekly', 'monthly' or 'yearly'"
+ print "Run scheduled jobs. Please specify 'minutely', 'quarter_hourly', 'hourly', 'daily', 'weekly', 'monthly' or 'yearly'"
def runjobs(self, when, options):
verbosity = int(options.get('verbosity', 1))
@@ -55,6 +55,8 @@ def runjobs_by_signals(self, when, options):
print "Sending %s job signal for: %s" % (when, app_name)
if when == 'minutely':
signals.run_minutely_jobs.send(sender=app, app=app)
+ elif when == 'quarter_hourly':
+ signals.run_quarter_hourly_jobs.send(sender=app, app=app)
elif when == 'hourly':
signals.run_hourly_jobs.send(sender=app, app=app)
elif when == 'daily':
@@ -72,7 +74,7 @@ def handle(self, *args, **options):
self.usage_msg()
return
elif len(args) == 1:
- if not args[0] in ['minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly']:
+ if not args[0] in ['minutely', 'quarter_hourly', 'hourly', 'daily', 'weekly', 'monthly', 'yearly']:
self.usage_msg()
return
else:
@@ -218,8 +218,14 @@ def handler(environ, start_response):
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Development server is running at http://%s:%s/" % (addr, port)
print "Quit the server with %s." % quit_command
+ path = admin_media_path
+ if not path:
+ admin_media_path = os.path.join(django.__path__[0], 'contrib/admin/static/admin')
+ if os.path.isdir(admin_media_path):
+ path = admin_media_path
+ else:
+ path = os.path.join(django.__path__[0], 'contrib/admin/media')
try:
- path = admin_media_path or django.__path__[0] + '/contrib/admin/media'
handler = make_profiler_handler(AdminMediaHandler(WSGIHandler(), path))
run(addr, int(port), handler)
except WSGIServerException, e:
@@ -81,7 +81,13 @@ def inner_run():
print "Development server is running at http://%s:%s/" % (addr, port)
print "Using the Werkzeug debugger (http://werkzeug.pocoo.org/)"
print "Quit the server with %s." % quit_command
- path = admin_media_path or django.__path__[0] + '/contrib/admin/media'
+ path = admin_media_path
+ if not path:
+ admin_media_path = os.path.join(django.__path__[0], 'contrib/admin/static/admin')
+ if os.path.isdir(admin_media_path):
+ path = admin_media_path
+ else:
+ path = os.path.join(django.__path__[0], 'contrib/admin/media')
handler = AdminMediaHandler(WSGIHandler(), path)
if USE_STATICFILES:
use_static_handler = options.get('use_static_handler', True)
@@ -1,6 +1,7 @@
import os
from django.core.management.base import NoArgsCommand
from optparse import make_option
+from datetime import datetime
class Command(NoArgsCommand):
@@ -41,15 +42,19 @@ def handle_noargs(self, **options):
class PrintQueryWrapper(util.CursorDebugWrapper):
def execute(self, sql, params=()):
+ starttime = datetime.now()
try:
return self.cursor.execute(sql, params)
finally:
raw_sql = self.db.ops.last_executed_query(self.cursor, sql, params)
+ execution_time = datetime.now() - starttime
if sqlparse:
print sqlparse.format(raw_sql, reindent=True)
else:
print raw_sql
print
+ print 'Execution time: %fs' % execution_time.total_seconds()
+ print
util.CursorDebugWrapper = PrintQueryWrapper
@@ -27,6 +27,10 @@
files.
--filter-list Override default directory and file exclusion
filters. (enter as comma seperated line)
+ --renamegzip Enables renaming of gzipped files by appending '.gz.
+ to the original file name. This way your original assets
+ will not be replaced by the gzipped ones if you don't want
+ them to be.
TODO:
* Use fnmatch (or regex) to allow more complex FILTER_LIST rules.
@@ -79,6 +83,9 @@ class Command(BaseCommand):
optparse.make_option('--gzip',
action='store_true', dest='gzip', default=False,
help="Enables gzipping CSS and Javascript files."),
+ optparse.make_option('--renamegzip',
+ action='store_true', dest='renamegzip', default=False,
+ help="Enables renaming of gzipped assets to have '.gz' appended to the filename."),
optparse.make_option('--expires',
action='store_true', dest='expires', default=False,
help="Enables setting a far future expires header."),
@@ -123,6 +130,7 @@ def handle(self, *args, **options):
self.verbosity = int(options.get('verbosity'))
self.prefix = options.get('prefix')
self.do_gzip = options.get('gzip')
+ self.rename_gzip = options.get('renamegzip')
self.do_expires = options.get('expires')
self.do_force = options.get('force')
self.DIRECTORY = options.get('dir')
@@ -233,6 +241,9 @@ def upload_s3(self, arg, dirname, names):
# and only if file is a common text type (not a binary file)
if file_size > 1024 and content_type in self.GZIP_CONTENT_TYPES:
filedata = self.compress_string(filedata)
+ if self.rename_gzip:
+ #If rename_gzip is True, then rename the file by appending '.gz' to original filename
+ file_key = '%s.gz' % (file_key)
headers['Content-Encoding'] = 'gzip'
if self.verbosity > 1:
print "\tgzipped: %dk to %dk" % \
@@ -28,6 +28,10 @@ class MinutelyJob(BaseJob):
when = "minutely"
+class QuarterHourlyJob(BaseJob):
+ when = "quarter_hourly"
+
+
class HourlyJob(BaseJob):
when = "hourly"
@@ -109,7 +113,7 @@ def get_jobs(when=None, only_scheduled=False):
if True:
from django.conf import settings
for app_name in settings.INSTALLED_APPS:
- scandirs = (None, 'minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly')
+ scandirs = (None, 'minutely', 'quarter_hourly', 'hourly', 'daily', 'weekly', 'monthly', 'yearly')
if when:
scandirs = None, when
for subdir in scandirs:
@@ -4,6 +4,7 @@
from django.dispatch import Signal
run_minutely_jobs = Signal()
+run_quarter_hourly_jobs = Signal()
run_hourly_jobs = Signal()
run_daily_jobs = Signal()
run_weekly_jobs = Signal()
View
@@ -43,13 +43,13 @@ Using
Whenever we hit an exception in our code, instead of the normal Django
traceback page appearing, we see the Werkzeug traceback page instead.
-http://blog.michaeltrier.com/assets/2008/6/22/werkzeug-traceback.png
+http://blog.michaeltrier.com/media/assets/2008/6/22/werkzeug-traceback.png
Along with the typical traceback information we have a couple of options. These
options appear when you hover over a particular traceback line. Notice that
two buttons appear to the right:
-http://blog.michaeltrier.com/assets/2008/6/22/werkzeug-options.png
+http://blog.michaeltrier.com/media/assets/2008/6/22/werkzeug-options.png
The options are:
@@ -59,7 +59,7 @@ View Source
This displays the source below the traceback:
-http://blog.michaeltrier.com/assets/2008/6/22/werkzeug-source.png
+http://blog.michaeltrier.com/media/assets/2008/6/22/werkzeug-source.png
Being able to view the source file is handy because you are able to get more
context information around where the error occurred. The actual traceback
@@ -75,7 +75,7 @@ Interactive Debugging Console
When you click on this button a new pane will open up below the traceback line
you're on. This is the money shot:
-http://blog.michaeltrier.com/assets/2008/6/22/werkzeug-debugger.png
+http://blog.michaeltrier.com/media/assets/2008/6/22/werkzeug-debugger.png
An ajax based console appears in the pane and you can begin debugging away.
Notice in the screenshot above I did a `print environ` to see what was in the
@@ -86,4 +86,4 @@ Not even for a quick check into a problem. I cannot emphasize this enough. The
interactive debugger allows you to evaluate python code right against the
server. You've been warned.
-.. _`Werkzeug WSGI utilities`: http://werkzeug.pocoo.org/
+.. _`Werkzeug WSGI utilities`: http://werkzeug.pocoo.org/

0 comments on commit 2ac5b73

Please sign in to comment.