summaryrefslogtreecommitdiff
path: root/django/bin
diff options
context:
space:
mode:
authorChristopher Long <indirecthit@gmail.com>2007-06-17 22:18:54 +0000
committerChristopher Long <indirecthit@gmail.com>2007-06-17 22:18:54 +0000
commitae22b6d403dcf25098c77f0dfcf59ae58b186461 (patch)
treec37fc631e99a7e4d909d6b6d236f495003731ea7 /django/bin
parent0cf7bc439129c66df8d64601e885f83b256b4f25 (diff)
per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@5488 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/bin')
-rwxr-xr-xdjango/bin/compile-messages.py21
-rw-r--r--django/bin/daily_cleanup.py12
-rwxr-xr-xdjango/bin/make-messages.py4
-rw-r--r--django/bin/profiling/gather_profile_stats.py2
4 files changed, 27 insertions, 12 deletions
diff --git a/django/bin/compile-messages.py b/django/bin/compile-messages.py
index 0137ec8dd4..2e1e908bbf 100755
--- a/django/bin/compile-messages.py
+++ b/django/bin/compile-messages.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python
+import optparse
import os
import sys
-def compile_messages():
+def compile_messages(locale=None):
basedir = None
if os.path.isdir(os.path.join('conf', 'locale')):
@@ -14,6 +15,9 @@ def compile_messages():
print "This script should be run from the Django SVN tree or your project or app tree."
sys.exit(1)
+ if locale is not None:
+ basedir = os.path.join(basedir, locale, 'LC_MESSAGES')
+
for dirpath, dirnames, filenames in os.walk(basedir):
for f in filenames:
if f.endswith('.po'):
@@ -27,10 +31,19 @@ def compile_messages():
os.environ['djangocompilemo'] = pf + '.mo'
os.environ['djangocompilepo'] = pf + '.po'
if sys.platform == 'win32': # Different shell-variable syntax
- cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"'
+ cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"'
else:
- cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'
+ cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"'
os.system(cmd)
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('-l', '--locale', dest='locale',
+ help="The locale to process. Default is to process all.")
+ options, args = parser.parse_args()
+ if len(args):
+ parser.error("This program takes no arguments")
+ compile_messages(options.locale)
+
if __name__ == "__main__":
- compile_messages()
+ main()
diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py
index 667e0f16c6..c87be1e4c3 100644
--- a/django/bin/daily_cleanup.py
+++ b/django/bin/daily_cleanup.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
"""
Daily cleanup job.
@@ -5,13 +7,13 @@ Can be run as a cronjob to clean out old data from the database (only expired
sessions at the moment).
"""
-from django.db import backend, connection, transaction
+import datetime
+from django.db import transaction
+from django.contrib.sessions.models import Session
def clean_up():
- # Clean up old database records
- cursor = connection.cursor()
- cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
- (backend.quote_name('django_session'), backend.quote_name('expire_date')))
+ """Clean up expired sessions."""
+ Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
transaction.commit_unless_managed()
if __name__ == "__main__":
diff --git a/django/bin/make-messages.py b/django/bin/make-messages.py
index 557cb5eeec..bf9e7a1962 100755
--- a/django/bin/make-messages.py
+++ b/django/bin/make-messages.py
@@ -81,7 +81,7 @@ def make_messages():
src = pythonize_re.sub('\n#', src)
open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
thefile = '%s.py' % file
- cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
+ cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
msgs = stdout.read()
@@ -103,7 +103,7 @@ def make_messages():
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
thefile = '%s.py' % file
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
- cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
+ cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
msgs = stdout.read()
diff --git a/django/bin/profiling/gather_profile_stats.py b/django/bin/profiling/gather_profile_stats.py
index 852f16229d..c0844930e9 100644
--- a/django/bin/profiling/gather_profile_stats.py
+++ b/django/bin/profiling/gather_profile_stats.py
@@ -22,7 +22,7 @@ def gather_stats(p):
else:
continue
print "Processing %s" % f
- if profiles.has_key(path):
+ if path in profiles:
profiles[path].add(prof)
else:
profiles[path] = prof