mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Updated cronjobs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
ROOT=$HOME/auth/auth/
|
||||
ROOT=/home/matalok/auth/auth
|
||||
|
||||
@daily $ROOT/run-cron.py reddit.cron UpdateAPIs
|
||||
@daily $ROOT/run-cron.py eve_api.cron UpdateAPIs
|
||||
*/10 * * * * $ROOT/run-cron.py sso.cron RemoveInvalidUsers
|
||||
*/10 * * * * $ROOT/run-cron.py sso.cron RemoveInvalidUsers > $ROOT/auth-update.log 2>&1
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from reddit.models import RedditAccount
|
||||
@@ -13,12 +14,25 @@ class UpdateAPIs():
|
||||
if not hasattr(self, '__logger'):
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
return self.__logger
|
||||
|
||||
last_update_delay = 604800
|
||||
|
||||
def job(self):
|
||||
for acc in RedditAccount.objects.all():
|
||||
acc.api_update()
|
||||
acc.save()
|
||||
time.sleep(2)
|
||||
delta = datetime.timedelta(seconds=self.last_update_delay)
|
||||
|
||||
print delta
|
||||
self._logger.debug("Updating accounts older than %s" % (datetime.datetime.now() - delta))
|
||||
|
||||
for acc in RedditAccount.objects.filter(last_update__lt=(datetime.datetime.now() - delta)):
|
||||
self._logger.info("Updating %s" % acc.username)
|
||||
|
||||
try:
|
||||
acc.api_update()
|
||||
except RedditAccount.DoesNotExist:
|
||||
acc.delete()
|
||||
else:
|
||||
acc.save()
|
||||
time.sleep(.5)
|
||||
|
||||
|
||||
class APIKeyParser:
|
||||
@@ -38,7 +52,7 @@ class APIKeyParser:
|
||||
def __str__(self):
|
||||
return "%s:%s" % (self.user_id, self.api_key)
|
||||
|
||||
class ProcessInbox(Job):
|
||||
class ProcessInbox():
|
||||
"""
|
||||
Grabs all Reddit Mail and processes any new applications
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user