def domain_create_task(domain_name, create_type, create_time, submitter, description, remark, compute_status=0): task_id = pinyin.get(domain_name, format='strip', delimiter='_') try: es.get(index=weibo_domain_index_name, doc_type=weibo_domain_index_type, id=task_id)['_source'] return 'domain name exists!' except: try: domain_task_dict = dict() #domain_task_dict['xnr_user_no'] = xnr_user_no domain_task_dict['domain_pinyin'] = pinyin.get(domain_name, format='strip', delimiter='_') domain_task_dict['domain_name'] = domain_name domain_task_dict['create_type'] = json.dumps(create_type) domain_task_dict['create_time'] = create_time domain_task_dict['submitter'] = submitter domain_task_dict['description'] = description domain_task_dict['remark'] = remark domain_task_dict['compute_status'] = compute_status r.lpush(weibo_target_domain_detect_queue_name, json.dumps(domain_task_dict)) item_exist = dict() #item_exist['xnr_user_no'] = domain_task_dict['xnr_user_no'] item_exist['domain_pinyin'] = domain_task_dict['domain_pinyin'] item_exist['domain_name'] = domain_task_dict['domain_name'] item_exist['create_type'] = domain_task_dict['create_type'] item_exist['create_time'] = domain_task_dict['create_time'] item_exist['submitter'] = domain_task_dict['submitter'] item_exist['description'] = domain_task_dict['description'] item_exist['remark'] = domain_task_dict['remark'] item_exist['group_size'] = '' item_exist['compute_status'] = 0 # 存入创建信息 es.index(index=weibo_domain_index_name, doc_type=weibo_domain_index_type, id=item_exist['domain_pinyin'], body=item_exist) mark = True except: mark = False return mark
def domain_update_task(domain_name, create_type, create_time, submitter, description, remark, compute_status=0): task_id = pinyin.get(domain_name, format='strip', delimiter='_') try: domain_task_dict = dict() #domain_task_dict['xnr_user_no'] = xnr_user_no domain_task_dict['domain_pinyin'] = pinyin.get(domain_name, format='strip', delimiter='_') domain_task_dict['domain_name'] = domain_name domain_task_dict['create_type'] = json.dumps(create_type) domain_task_dict['create_time'] = create_time domain_task_dict['submitter'] = submitter domain_task_dict['description'] = description domain_task_dict['remark'] = remark domain_task_dict['compute_status'] = compute_status print 'create_type' print create_type r.lpush(tw_target_domain_detect_queue_name, json.dumps(domain_task_dict)) item_exist = dict() #item_exist['xnr_user_no'] = domain_task_dict['xnr_user_no'] item_exist['domain_pinyin'] = domain_task_dict['domain_pinyin'] item_exist['domain_name'] = domain_task_dict['domain_name'] item_exist['create_type'] = domain_task_dict['create_type'] item_exist['create_time'] = domain_task_dict['create_time'] item_exist['submitter'] = domain_task_dict['submitter'] item_exist['description'] = domain_task_dict['description'] item_exist['remark'] = domain_task_dict['remark'] item_exist['group_size'] = '' item_exist['compute_status'] = 0 # 存入创建信息 es.index(index=tw_domain_index_name, doc_type=tw_domain_index_type, id=item_exist['domain_pinyin'], body=item_exist) mark = True except Exception, e: print e mark = False
def domain_create_task(domain_name, create_type, create_time, submitter, description, remark, compute_status=0): task_id = pinyin.get(domain_name, format='strip', delimiter='_') try: es.get(index=fb_domain_index_name, doc_type=fb_domain_index_type, id=task_id)['_source'] return 'domain name exists!' except: try: domain_task_dict = dict() domain_task_dict['domain_pinyin'] = pinyin.get(domain_name, format='strip', delimiter='_') domain_task_dict['domain_name'] = domain_name domain_task_dict['create_type'] = json.dumps(create_type) domain_task_dict['create_time'] = create_time domain_task_dict['submitter'] = submitter domain_task_dict['description'] = description domain_task_dict['remark'] = remark domain_task_dict['compute_status'] = compute_status # print 'domain_task_dict' # print domain_task_dict # print 'before: r.lrange' # print r.lrange(fb_target_domain_detect_queue_name,0,100) r.lpush(fb_target_domain_detect_queue_name, json.dumps(domain_task_dict)) # print 'after: r.lrange' # print r.lrange(fb_target_domain_detect_queue_name,0,100) item_exist = dict() item_exist['domain_pinyin'] = domain_task_dict['domain_pinyin'] item_exist['domain_name'] = domain_task_dict['domain_name'] item_exist['create_type'] = domain_task_dict['create_type'] item_exist['create_time'] = domain_task_dict['create_time'] item_exist['submitter'] = domain_task_dict['submitter'] item_exist['description'] = domain_task_dict['description'] item_exist['remark'] = domain_task_dict['remark'] item_exist['group_size'] = '' item_exist['compute_status'] = 0 # 存入创建信息 print es.index(index=fb_domain_index_name, doc_type=fb_domain_index_type, id=item_exist['domain_pinyin'], body=item_exist) mark = True except Exception, e: print e mark = False return mark
def get_login_name(xnr_user_no): try: print 'execut get_login_name function--------------------------------------------------------------------------------' get_results = es_xnr.get(index=qq_xnr_index_name,doc_type=qq_xnr_index_type,id=xnr_user_no)['_source'] print get_results, 'es results-=-=-=-=-=-==-=-=-=========================-----------------------------------------------' qq_number = get_results['qq_number'] qqbot_port = get_results['qqbot_port'] access_id = get_results['access_id'] #qqbot_port = '8199' p_str1 = 'python '+ ABS_LOGIN_PATH + ' -i '+str(qqbot_port) + ' >> login'+str(qqbot_port)+'.txt' #qqbot_port = '8190' qqbot_num = qq_number qqbot_port = str(qqbot_port) qqbot_mc = access_id #'sirtgdmgwiivbegf' #qqbot_mc = 'worunhzbzyipdagc' # yuanlai >>>>>>>>>>>>8.20 #p_str1 = 'python '+ ABS_LOGIN_PATH + ' -i '+qqbot_port + ' -o ' + qqbot_num + ' -m ' + qqbot_mc + ' >> login'+qqbot_port+'.txt' # xuanhui 8.20 把邮件发送到80217252 p_str1 = 'python '+ ABS_LOGIN_PATH + ' -i '+qqbot_port + ' -o ' + '80617252' + ' -m ' + qqbot_mc + ' >> login'+qqbot_port+'.txt' #p_str1 = 'python '+ ABS_LOGIN_PATH + ' -i '+qqbot_port + ' -o ' + qqbot_num + ' -m ' + qqbot_mc command_str = 'python '+ ABS_LOGIN_PATH + ' -i '+qqbot_port + ' -o ' + qqbot_num + ' -m ' + qqbot_mc print 'p_str1:', p_str1 print '=========================================================================' p_str2 = 'pgrep -f ' + '"' + command_str + '"' print 'p_str2::',p_str2 process_ids = subprocess.Popen(p_str2, \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) process_id_list = process_ids.stdout.readlines() for process_id in process_id_list: process_id = process_id.strip() kill_str = 'kill -9 ' + process_id print 'kill_str::',kill_str p2 = subprocess.Popen(kill_str, \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p2 = subprocess.Popen(p_str1, \ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # # 存储qq端口、授权码等消息,用于后台主进程调用 qq_info = dict() qq_info['qq_num'] = qqbot_num qq_info['qq_port'] = qqbot_port qq_info['access_id'] = qqbot_mc r.lpush(r_qq_receive_message,json.dumps(qq_info)) return True except: return False