def get_dm_list():
    mo = mongo_obj.MongoOper()
    dm_obj = mo.db['dm_obj']
    dm_objs = dm_obj.find()
    dm_list = []
    for dm in dm_objs:
        dm_list.append(dm)
    # for x in dm_list:
    #     print x
    print len(dm_list)
    return dm_list
Exemple #2
0
def store_domain(
    collection_name
):  ## at this circumustance ,collection_name should always be 'domain'
    '''
    只能执行一遍,没有去除重复
    :param collection_name:
    :return:
    '''
    mo = mongo_obj.MongoOper()
    domn = mo.db[collection_name]
    sqlhlp = mysql_obj.MysqldbHelper()
    domlist = sqlhlp.get_domains(config.get_time_limit())
    domain_ob = {}
    domain_ob['domains'] = domlist
    domn.insert(domain_ob)
Exemple #3
0
def store_dm_obj(domain_names,
                 collection_name):  ## collection_name should be 'domain_obj'
    mo = mongo_obj.MongoOper()
    domn = mo.db[collection_name]
    sqlhlp = mysql_obj.MysqldbHelper()
    lens = len(domain_names)
    i = 1
    for dm in domain_names:
        print i
        i += 1
        obj_list = sqlhlp.get_domain_info(dm)
        tmp = {}
        tmp['name'] = dm
        tmp['person'] = []
        tmp['phone'] = []
        tmp['email'] = []
        tmp['ip'] = ''
        for ob in obj_list:
            if ob['Domain_IP'].strip() != '' and ob['Domain_IP'] != None:
                tmp['ip'] = ob['Domain_IP']
            if ob['Registrar_Name'].strip(
            ) != '' and ob['Registrar_Name'] != None:
                tmp['person'].append(ob['Registrar_Name'])
            if ob['Admin_Name'].strip() != '' and ob['Admin_Name'] != None:
                tmp['person'].append(ob['Admin_Name'])
            if ob['Tech_Name'].strip() != '' and ob['Tech_Name'] != None:
                tmp['person'].append(ob['Tech_Name'])
            if ob['Domain_IP'].strip() != '' and ob['Domain_IP'] != None:
                tmp['ip'] = ob['Domain_IP']
            ## phone
            if ob['Registrar_Phone'].strip(
            ) != '' and ob['Registrar_Phone'] != None:
                tmp['phone'].append(ob['Registrar_Phone'])
            if ob['Admin_Phone'].strip() != '' and ob['Admin_Phone'] != None:
                tmp['phone'].append(ob['Admin_Phone'])
            if ob['Tech_Phone'].strip() != '' and ob['Tech_Phone'] != None:
                tmp['phone'].append(ob['Tech_Phone'])
            ## email
            if ob['Registrar_Email'].strip(
            ) != '' and ob['Registrar_Email'] != None:
                tmp['email'].append(ob['Registrar_Email'])
            if ob['Admin_Email'].strip() != '' and ob['Admin_Email'] != None:
                tmp['email'].append(ob['Admin_Phone'])
            if ob['Tech_Email'].strip() != '' and ob['Tech_Email'] != None:
                tmp['email'].append(ob['Tech_Email'])
        domn.insert(tmp)
Exemple #4
0
def recorrect():  ## 粗心大意的结果,多花费了一个小时时间来擦屁股.....
    print 'this is recorrect!!!'
    mo = mongo_obj.MongoOper()
    domn = mo.db['domain_obj']
    ret_dic = get_admin_email_dic()
    dm_obj = mo.db['dm_obj']
    domain_objs = domn.find()
    i = 0
    for cu in domain_objs:
        print i
        i += 1
        tmp = {}
        tmp['name'] = cu['name']
        tmp['ip'] = cu['ip']
        tmp['person'] = list(set(cu['person']))
        tmp['phone'] = list(set(cu['phone']))
        xxx = ret_dic[cu['name']]
        tmp['email'] = list(set(xxx))
        dm_obj.insert(tmp)
Exemple #5
0
def get_domain_names(collection_name):
    mo = mongo_obj.MongoOper()
    domn = mo.db[collection_name]
    cur = domn.find_one({})
    return cur['domains']