Skip to content

Commit 9bcbedb

Browse files
committed
chore #3168 Clean up old prints in testing
1 parent f18276d commit 9bcbedb

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

src/core/logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ def check_for_bad_login_attempts(request):
868868
time = timezone.now() - timedelta(minutes=10)
869869

870870
attempts = models.LoginAttempt.objects.filter(user_agent=user_agent, ip_address=ip_address, timestamp__gte=time)
871-
print(time, attempts.count())
871+
logger.info(time, attempts.count())
872872
return attempts.count()
873873

874874

src/cron/management/commands/send_publication_notifications.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from journal import models as journal_models
99
from submission import models as submission_models
1010
from utils import notify_helpers, setting_handler, render_template
11+
from utils.logger import get_logger
12+
13+
logger = get_logger(__name__)
1114

1215

1316
def create_fake_request(journal):
@@ -47,12 +50,12 @@ def handle(self, *args, **options):
4750
setting_name='send_reader_notifications',
4851
journal=journal,
4952
).value:
50-
print('Sending notification for {}'.format(journal.name))
53+
logger.info('Sending notification for {}'.format(journal.name))
5154
readers = journal.users_with_role('reader')
5255
bcc_list = [reader.email for reader in readers]
5356

5457
if bcc_list:
55-
print("Sending notifications to {}".format(
58+
logger.info("Sending notifications to {}".format(
5659
", ".join(bcc_list)
5760
))
5861

@@ -98,8 +101,8 @@ def handle(self, *args, **options):
98101
}
99102
)
100103
else:
101-
print("No articles were published today.")
104+
logger.info("No articles were published today.")
102105
else:
103-
print('Reader publication notifications are not enabled for {}'.format(journal.name))
106+
logger.info('Reader publication notifications are not enabled for {}'.format(journal.name))
104107

105108

src/cron/management/commands/send_reminders.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from cron import models
44
from journal import models as journal_models
5+
from utils.logger import get_logger
6+
7+
logger = get_logger(__name__)
58

69

710
class Command(BaseCommand):
@@ -19,12 +22,12 @@ def handle(self, *args, **options):
1922
journals = journal_models.Journal.objects.all()
2023

2124
for journal in journals:
22-
print("Processing reminders for journal {0}: {1}".format(journal.pk, journal.name))
25+
logger.info("Processing reminders for journal {0}: {1}".format(journal.pk, journal.name))
2326

2427
reminders = models.Reminder.objects.filter(journal=journal)
2528

2629
for reminder in reminders:
27-
print("Reminder {0}, target date: {1}".format(reminder, reminder.target_date()))
30+
logger.info("Reminder {0}, target date: {1}".format(reminder, reminder.target_date()))
2831
if action == 'test':
2932
reminder.send_reminder(test=True)
3033
else:

src/utils/install.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
from journal import models
1414
from press import models as press_models
1515
from utils import setting_handler
16+
from utils.logger import get_logger
1617
from submission import models as submission_models
1718
from cms import models as cms_models
1819

20+
logger = get_logger(__name__)
21+
1922

2023
def update_settings(journal_object=None, management_command=False,
2124
overwrite_with_defaults=False,
@@ -83,7 +86,7 @@ def update_settings(journal_object=None, management_command=False,
8386
setting.editable_by.add(*roles)
8487

8588
if management_command:
86-
print('Parsed setting {0}'.format(item['setting'].get('name')))
89+
logger.info('Parsed setting {0}'.format(item['setting'].get('name')))
8790

8891

8992
def load_permissions(file_path='utils/install/journal_defaults.json'):

src/utils/management/commands/install_plugins.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
from django.core.management.base import BaseCommand
44

55
from core import plugin_loader
6+
from utils.logger import get_logger
67

78
from importlib import import_module
89

10+
logger = get_logger(__name__)
11+
912

1013
class Command(BaseCommand):
1114
"""A management command to check for and install new plugins."""
@@ -40,13 +43,13 @@ def handle(self, *args, **options):
4043
)
4144

4245
for plugin in plugin_dirs:
43-
print('Checking plugin {0}'.format(plugin))
46+
logger.debug('Checking plugin {0}'.format(plugin))
4447
plugin_module_name = "plugins.{0}.plugin_settings".format(plugin)
4548
plugin_settings = import_module(plugin_module_name)
4649
plugin_settings.install()
4750

4851
for plugin in homepage_dirs:
49-
print('Checking plugin {0}'.format(plugin))
52+
logger.debug('Checking plugin {0}'.format(plugin))
5053
plugin_module_name = "core.homepage_elements.{0}.plugin_settings".format(plugin)
5154
plugin_settings = import_module(plugin_module_name)
5255
plugin_settings.install()

0 commit comments

Comments
 (0)