Exemplo n.º 1
0
def get_suspensionqq():
    suspension_qq = SuspensionQQModel()
    sort_col = request.args.get('sort_col');
    if sort_col == None:
        sort_col = 'CreatTime';
    sort_type = request.args.get('sort_type')
    if sort_type == None:
        sort_type = 'DESC'
    limit = request.args.get('max')
    if limit == None:
        limit = 5
    offset = int(request.args.get('start'))
    if offset == None:
        offset = 0;
    offset = offset*int(limit)
    data = suspension_qq.get_suspensionqq(fileds="QQ")
    info = "find suspension qq"
    wirte_log_to_file(info)
    total = len(data)
    data = suspension_qq.get_suspensionqq(limit = int(limit),offset=int(offset),sort_col=sort_col,order_type=sort_type)
    all_data = {
        "total" :total,
        "data" :data
    }
    return json.dumps(all_data)
 def add_suspension_qq(self,url,index,path,re_pattern = "\d{5,}-{4}.{5,17}-{4}"):
     logging.info(" add_suspension_qq start ")
     elasticsearch_service = elasticsearchLib(url)
     suspension_qq_model = SuspensionQQModel()
     suspension_qq = elasticsearch_service.get_suspension_qq(index=index,path=path,re_pattern=re_pattern)
     if suspension_qq != 'notfound':
         for i in suspension_qq:
             check_qq_is_exist = suspension_qq_model.check_qq_is_in_db(i)
             if check_qq_is_exist:
                 if check_qq_is_exist['Password'] == suspension_qq[i]:
                     continue
                 else:
                     suspension_qq_model.update_qq_password(qq=i,Password = suspension_qq[i])
             else:
                 qq_data = {}
                 qq_data['QQ'] = i;
                 qq_data['Password'] = suspension_qq[i]
                 qq_data['CreatTime'] = str(datetime.datetime.now().strftime('%Y.%m.%d %H:%M:%S'))
                 logging.info(" add qq to db")
                 suspension_qq_model.add_qq_to_db(qq_data=qq_data)