From d7d7327d2b162fa3b0701735a5bde6ad974d384d Mon Sep 17 00:00:00 2001 From: Chris Rossi Date: Thu, 19 Dec 2013 11:04:35 -0500 Subject: [PATCH] Allow force checking, disregarding LinkedIn's rules. --- .../linkedin/management/commands/findusers.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/linkedin/management/commands/findusers.py b/lms/djangoapps/linkedin/management/commands/findusers.py index 0e4cb87e2c..2f2a14ffee 100644 --- a/lms/djangoapps/linkedin/management/commands/findusers.py +++ b/lms/djangoapps/linkedin/management/commands/findusers.py @@ -34,7 +34,6 @@ def get_call_limits(): Use 80 emails per API call and 1 call per second. """ - return -1, 80, 1 now = timezone.now().astimezone(pytz.timezone('US/Pacific')) lastfriday = now while lastfriday.weekday() != FRIDAY: @@ -63,7 +62,14 @@ class Command(BaseCommand): dest='recheck', default=False, help='Check users that have been checked in the past to see if ' - 'they have joined or left LinkedIn since the last check'),) + 'they have joined or left LinkedIn since the last check'), + make_option( + '--force', + action='store_true', + dest='force', + default=False, + help='Disregard the parameters provided by LinkedIn about when it ' + 'is appropriate to make API calls.')) def handle(self, *args, **options): """ @@ -71,9 +77,13 @@ class Command(BaseCommand): """ api = LinkedinAPI() recheck = options.pop('recheck', False) - max_checks, checks_per_call, time_between_calls = get_call_limits() - if not max_checks: - raise CommandError("No checks allowed during this time.") + force = options.pop('force', False) + if force: + max_checks, checks_per_call, time_between_calls = -1, 80, 1 + else: + max_checks, checks_per_call, time_between_calls = get_call_limits() + if not max_checks: + raise CommandError("No checks allowed during this time.") def batch_users(): "Generator to lazily generate batches of users to query."