本文整理匯總了Python中enroll.models.Course.list_for_backup_check方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.list_for_backup_check方法的具體用法?Python Course.list_for_backup_check怎麽用?Python Course.list_for_backup_check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enroll.models.Course
的用法示例。
在下文中一共展示了Course.list_for_backup_check方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_for_course_backup
# 需要導入模塊: from enroll.models import Course [as 別名]
# 或者: from enroll.models.Course import list_for_backup_check [as 別名]
def check_for_course_backup(request):
if not cfg.getConfigBool('BACKUP_ON',False):
logging.info('BACKUP_ON is OFF!')
return HttpResponse('ok')
now = datetime.datetime.utcnow()
exp_min = cfg.getConfigInt('BACKUP_CHECK_MINUTES',180)
td = datetime.timedelta(minutes=exp_min)
lim = now-td
course_list = Course.list_for_backup_check(lim).fetch(100)
for c in course_list:
logging.info('course: %s'%c)
if c.backup_datetime is None:
c.backup_flag = True
c.save()
logging.info('marked for backup')
elif c.backup_datetime < c.modify_datetime:
c.backup_flag = True
c.save()
logging.info('marked for backup')
return HttpResponse('ok')