From 0bf4a7587a1e6a681053de43d03a6632b5a09278 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Wed, 10 Aug 2016 22:51:55 +0000 Subject: [PATCH] cleanup_snippets: use self.stdout rather than sys.stdout The point of using these handles rather than sys.* is to support things like this: https://docs.djangoproject.com/ja/1.9/ref/django-admin/#output-redirection It also makes unit testing the output simpler. --- dpaste/management/commands/cleanup_snippets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpaste/management/commands/cleanup_snippets.py b/dpaste/management/commands/cleanup_snippets.py index c24e6ec..cec58e4 100644 --- a/dpaste/management/commands/cleanup_snippets.py +++ b/dpaste/management/commands/cleanup_snippets.py @@ -20,10 +20,10 @@ class Command(LabelCommand): expire_type=Snippet.EXPIRE_TIME, expires__lte=timezone.now() ) - sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) + self.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) for d in deleteable_snippets: - sys.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires)) + self.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires)) if options.get('dry_run'): - sys.stdout.write(u'Dry run - Not actually deleting snippets!\n') + self.stdout.write(u'Dry run - Not actually deleting snippets!\n') else: deleteable_snippets.delete()