import sys import os import re import traceback import gevent import gevent.pool import time import ipaddr import lib.SPF2IP as SPF2IP import lib.spf as spf from lib import common from lib.resource import Checklist, SenderChecklist, RegexChecklist common.init_django_enev() # from redis_cache import get_redis_connection from lib.django_redis import get_redis from django.conf import settings as django_settings from django.db import DatabaseError, InterfaceError, connection from django.core.exceptions import ObjectDoesNotExist from lib.common import outinfo, outerror, strip_tags from lib.report_spam import spamc, dspamc, esets, savscan_attach, dspamc2 from lib.parse_email import ParseEmail from lib.ctasd import Ctasd from lib.validators import check_email_format from apps.collect_mail.models import get_mail_model from apps.mail.models import KeywordBlacklist, CheckSettings, SubjectKeywordBlacklist, SenderBlacklist, \ AttachmentBlacklist, SenderWhitelist, AttachmentTypeBlacklist, CustomerSenderBlacklist, CollectRecipientWhitelist, \ SpfChecklist, CollectRecipientChecklist, SpfIpWhitelist
# coding=utf-8 """ 根据mail model 同步数据库 """ import datetime import lib.common as Common Common.init_django_enev() from django.db import connection def add_is_study(): """ 2015-11-19 增加字段is_study 是否提交dspam学习 :return: """ sql = 'ALTER TABLE "public"."{}" ADD COLUMN "is_study" boolean' today = datetime.date.today() cursor = connection.cursor() for i in range(0, 30): date = (today - datetime.timedelta(days=i)).strftime('%Y%m%d') print date try: cursor.execute(sql.format('mail_{}'.format(date))) except BaseException, e: print e try: cursor.execute(sql.format('cmail_{}'.format(date))) except BaseException, e: print e