From c3ae124268559b6f8820bd37cc520c19160b96e6 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 16 Jul 2019 14:42:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BE=D1=82=D1=8B=20=D0=B7=D0=B0=20=D1=80=D0=B8=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BB=D0=B0=D0=B3?= =?UTF-8?q?=D0=B5=D1=80=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/animail_logs.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/notification/management/commands/animail_logs.py b/apps/notification/management/commands/animail_logs.py index 57bac50f..a783dbaf 100644 --- a/apps/notification/management/commands/animail_logs.py +++ b/apps/notification/management/commands/animail_logs.py @@ -1,6 +1,6 @@ from email.utils import format_datetime import requests -from datetime import datetime +from datetime import datetime, timedelta from django.core.management.base import BaseCommand from django.conf import settings @@ -45,7 +45,13 @@ class Command(BaseCommand): parser.add_argument( '--date', dest='date', - help='Date', + help='Date in format 22-1-2019', + ) + parser.add_argument( + '--days', + type=int, + dest='days', + help='Days after date', ) parser.add_argument( '--subject', @@ -55,11 +61,14 @@ class Command(BaseCommand): def handle(self, *args, **options): emails = [] - end_dt = datetime(2019, 7, 11) - current_dt = options.get('date') + current_dt = datetime.strptime(options.get('date'), '%d-%m-%Y') + end_dt = current_dt + timedelta(options.get('days') or 1) while current_dt <= end_dt: - e, current_dt = get_logs(options.get('limit'), current_dt, options.get('subject')) + e, dt = get_logs(options.get('limit') or 300, current_dt, options.get('subject')) emails += e + if current_dt == dt: + break + current_dt = dt print(set(emails)) print(current_dt)