# -*- coding: utf-8 -*- #!/usr/bin/env python import sys,os import datetime PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..') sys.path.insert(0, PROJECT_ROOT) os.environ.update({"DJANGO_SETTINGS_MODULE": "configs.production"}) import django django.setup() from script.base import init_env, get_logger from apps.web.device.models import SIMCard,Device import xlrd from xlrd import xldate_as_tuple # 从SIM卡平台上导出来的excel,导入到数据库中,便于流量结算。 # 1、月末:根据用户的充值情况,把SIM卡数据全部导出来,发给卡商,进行充值。 # 2、月头:卡商充值后,我们利用import_sim_card脚本,把excel导出来,然后导入到数据库,并执行另外一个脚本update_device_sim_info_from_simdb更新设备的超时时间 def is_include_small(str): for a in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']: if a in str: return True return False ii = 0 for obj in SIMCard.objects.all(): if is_include_small(obj.iccid): print obj.iccid SIMCard.get_collection().remove({'iccid':obj.iccid}) ii += 1 if ii % 300 == 0: print ii continue print u'OK'