def send_rate_email(sender, receiver, cc_receiver, to, txt, title): # to = _format_addr(to) subject = title table = """ %s """ % (txt) msg = MIMEMultipart('related') msgAlternative = MIMEMultipart('alternative') msg.attach(msgAlternative) msgText = MIMEText(table, 'html', 'utf-8') msgAlternative.attach(msgText) msg["Accept-Language"] = "zh-CN" msg["Accept-Charset"] = "ISO-8859-1,utf-8" if not isinstance(subject, unicode): subject = unicode(subject) msg['Subject'] = subject msg['To'] = ','.join(to) if cc_receiver != None: msg['CC'] = ','.join(cc_receiver) #----------------------------------------------------------- s = smtplib.SMTP('corp.chinacache.com') answer = s.sendmail(sender, receiver, msg.as_string()) s.close() logger.info( 'send_rate_email to: %s|| cc_receiver: %s|| receiver: %s|| answer: %s' % (to, cc_receiver, receiver, answer)) if str(answer) == '{}': return 'success' else: return 'fail'
def analysis_directions(directions): edge_str = "边缘" upper_str = "上层" flag = "00" try: for line in directions.split(','): if 'e' in line: if flag == '01' or flag == '11': flag = '11' else: flag = '10' edge_str = edge_str + line[1] + "," if line == 'in' or line == 'out': if flag == '10' or flag == '11': flag = '11' else: flag == '10' upper_str = upper_str + line + "," if flag == "10": return edge_str[:-1] + "方向" elif flag == '01': return upper_str[:-1] + "方向" else: return edge_str[:-1] + "方向," + upper_str[:-1] + "方向" except Exception as e: logger.info('analysis_directions[error]: %s' % (traceback.format_exc(e), )) return edge_str
def let_us_start(): # 假设调用接口花费 1s 的时间,从 20:00:00 开始调用预下单接口 60 次将花费 2min 的时间(请求本身1s、sleep1s) # 2min 之后已经没必要继续预约了,基本不会有了 confirm_order_retry_max = 120 # 预约失败自动重试最大次数 while True: # 直接调用 preorder 确认下单,没开始会返回错误: 预约未开始 now = time.strftime("%H%M%S") if now < '195900': suikang.check_status( ) # 不要持续使用 check_status() 接口,这个接口到 19:59:55 的时候可能就没响应了 # logger.info('预约还没开始,请耐心等待~') time.sleep(60) elif '200000' <= now < '200500': retried = 0 while True: success = suikang.comfire_order(config.MASK_TYPE) if success: return elif retried <= confirm_order_retry_max: retried += 1 time.sleep(1) elif now > '200500': logger.info('今天应该大概可能已经没有希望了,明天再来吧') exit(0) else: print('马上就要开始了,做好准备') time.sleep(1)
def get_rate(username, group): try: had_config_channel = limiter_conf.find( {'_id': ObjectId(group)}, {'channels': 1}) all_channels = [] for h in had_config_channel: all_channels = h['channels'] logger.info("get_rate all_channels: %s" % all_channels) sum_upper_rate = 0.0 for line in all_channels: channelCode = get_ChannelCode(line) apiPassword = get_ApiPassword(username) now_time = time.strftime('%Y%m%d%H%M', time.localtime(time.time())) if int(now_time[-1]) < 5: now_time = now_time[:-1] + '0' else: now_time = now_time[:-1] + '5' logger.info('get_rate now_time: %s' % (now_time)) url = UPPER_RATE_API % ( username, apiPassword, channelCode, now_time, now_time) logger.info('get_rate url: %s' % (url)) req = urllib2.Request(url) rcms_res = urllib2.urlopen(req, timeout=10) res_data = rcms_res.read() res_obj = json.loads(res_data) logger.info("get_rate res_obj['Datas'][0]['value']: %s" % (res_obj['Datas'][0]['value'], )) sum_upper_rate = sum_upper_rate + float(res_obj['Datas'][0]['value']) return sum_upper_rate except Exception as e: logger.info('get_rate[error]: %s' % (traceback.format_exc(e), ))
def comfire_order(cat=0): data = comfirm_order_data.copy() if cat == 1: data['category'] = '普通N95口罩' data['commodity_id'] = '100005' data['number'] = 5 elif cat == 2: data['category'] = '普通防护口罩' data['commodity_id'] = '100006' data['number'] = 10 else: logger.warning('unknown mask category.') return False jstr = json.dumps(data, ensure_ascii=False) byte = jstr.encode('utf-8') response = post(URI_CONFIRM_ORDER, data=byte, headers=header, timeout=config.ORDER_TIMEOUT_SECONDS) result = check_success_or_not(response) if result is not None: status = result['data']['status'] if status == 'success': logger.info('预约成功!') return True else: logger.warn('unknown status: ' + status) return False
def get_email_data(need_alarm_rate, need_alarm_current, need_alarm_user): logger.info( "get_email_data need_alarm_rate: %s|| need_alarm_current: %s|| need_alarm_user: %s" % (need_alarm_rate, need_alarm_current, need_alarm_user)) txt_data = "" for line in range(len(need_alarm_rate)): txt_data += "<tr>" txt_data += "<td >" + str(need_alarm_user[line]) + "</td>" txt_data += "<td >" + str(need_alarm_rate[line]) + "</td>" txt_data += "<td >" + str(need_alarm_current[line]) + "</td>" txt_data += "</tr>" txt = "<html>" txt += "<body>" txt += "<table style=\"font-size: 14px;border-collapse:collapse;\" bordercolor=\"#C1DAD7\" border=\"1\"; cellspacing=\"0\">" txt += "<tr>" txt += "<th bgcolor=\"#CAE8EA\" colspan=\"3\" style=\"padding:5px 10px;\" align=\"left\">" + "限速组列表" + "</th>" txt += "</tr>" txt += "<tr>" txt += "<td bgcolor=\"#CAE8EA\" style=\"font-weight:bold;padding:5px 10px;\">" + "用户名" + "</td>" txt += "<td bgcolor=\"#CAE8EA\" style=\"font-weight:bold;padding:5px 10px;\">" + "限速值" + "</td>" txt += "<td bgcolor=\"#CAE8EA\" style=\"font-weight:bold;padding:5px 10px;\">" + "现在总带宽" + "</td>" txt += "</tr>" txt += txt_data txt += "</table>" txt += "</body>" txt += "</html>" logger.info("get_email_data txt: %s" % txt) send_rate_email("*****@*****.**", ["*****@*****.**"], ["*****@*****.**"], ["*****@*****.**"], txt, "限速邮件告警")
def db_update(collection, find, modification): for retry_count in range(RETRY_COUNT): try: ret = collection.update(find, modification) if ret.get("updatedExisting") == True and ret.get("n") > 0: return except Exception as e: logger.info("db_update[error]: %s" % (traceback.format_exc(e), ))
def get_ApiPassword(username): try: req = urllib2.Request(PORTAL_API % (username)) rcms_res = urllib2.urlopen(req, timeout=10) res_data = rcms_res.read() res_obj = json.loads(res_data) logger.info('get_ApiPassword res_obj: %s' % (res_obj, )) return res_obj['apiPassword'] except Exception as e: logger.info('get_ApiPassword[error]: %s' % (traceback.format_exc(e), ))
def del_config_cache(channel, category): ''' 删除配置 ''' try: _key = get_channel_cache_key(channel, category) REDIS_CONNECT_0.delete(_key) except Exception as e: logger.info('del_config_cache[error]: %s' % (traceback.format_exc(e), ))
def get_config_cache(channel, category): ''' 获取配置 ''' res = None try: _key = get_channel_cache_key(channel, category) res = REDIS_CONNECT_0.hgetall(_key) except Exception as e: logger.info('get_config_cache[error]: %s' % (traceback.format_exc(e), )) return res
def get_ChannelCode(channelname): try: req = urllib2.Request(RCMS_ROOT % (channelname)) rcms_res = urllib2.urlopen(req, timeout=10) res_data = rcms_res.read() res_obj = json.loads(res_data) logger.info('get_ChannelCode res_obj: %s' % res_obj) for line in res_obj: if line['channelName'] == channelname: return line['channelCode'] except Exception as e: logger.info('get_ChannelCode[error]: %s' % (traceback.format_exc(e), ))
def get(self): res = get_all_conf(col=limiter_conf) logger.info('LimiterConfigTop[get] res: %s' % res) for k, v in res.items(): if k == 'all_conf': for line in v: line['category'] = analysis_directions(line['category']) self.render('limiter_conf.html', query_id='', all_conf=res['all_conf'], totalpage=res['totalpage'], c_page=0)
def add_limiter_cache(channels, category, info): ''' 添加limiter cache缓存 ''' try: for channel in channels: _key = "%s_limiter_%s" % (channel, category) REDIS_CONNECT_0.set(_key, json.dumps(info)) REDIS_CONNECT_0.expire(_key, 604800) _key1 = "%s_limiter" % channel REDIS_CONNECT_0.set(_key1, json.dumps(info)) except Exception as e: logger.info('add_limiter_cache[error]: %s' % (traceback.format_exc(e), ))
def get(self, conf_id): info = control_conf.find_one({'_id': ObjectId(conf_id)}) if not info: return self.write(error_res('This config had already deleted')) try: control_conf.remove({'_id': ObjectId(conf_id)}) except Exception as e: logger.info('ConfigDel[error]: %s' % (traceback.format_exc(e), )) else: del_config_cache(info['channel'] + info.get('suffix', ''), info['category']) self.redirect('/conf')
def check_report_key(key): if 'http' in key: dev = key[0:key.index('http')] if not dev: return None, None, None, None, None, None, None, None, None, None, None, else: return None, None, None, None, None, None, None, None, None, None, None, channel = key[key.index('http'):] group, rate, category, user, Bbase, Balarm, Bhard, Bgrade, Bpolice = find_group(channel) logger.info("check_report_key group: %s|| rate: %s" % (group, rate)) if not group or not rate or not category or not user: logger.info("check_report_key [channel not found.]: %s" % channel) return None, None, None, None, None, None, None, None, None, None, None, return channel, dev, group, rate, category, user, Bbase, Balarm, Bhard, Bgrade, Bpolice
def del_limiter_cache(channels, category): ''' 删除limiter配置 ''' try: for channel in channels: _key = "%s_limiter_%s" % (channel, category) _key1 = "%s_limiter" % channel logger.info("del_limiter_cache _key: %s" % _key) REDIS_CONNECT_0.delete(_key) REDIS_CONNECT_0.delete(_key1) except Exception as e: logger.info('del_limiter_cache[error]: %s' % (traceback.format_exc(e), ))
def find_group(channel): cache_key = CHANNEL_LIMITER % channel logger.info("find_group cache_key: %s" % cache_key) # cache_key:http://download.52xuexi.net_limiter group = '' rate = '' category = '' Bbase = '' Balarm = '' Bhard = '' Bgrade = '' Bpolice = '' cache = REDIS_CONNECT_0.get(cache_key) ''' ---(2018-06-29 16:15:31.964469)cache--- b'{"category": "e1,e2,e3,e4", "rate": 800.0, "Bpolice": 1.2, "user": "******", "Bhard": 1.0, "_id": "599ab249d101b441a84bb1a5", "Bbase": 170.0, "Bgrade": 3, "Balarm": 0.75}' ''' if cache: data = json.loads(cache) group = data["_id"] rate = data["rate"] category = data["category"] user = data["user"] Bbase = data["Bbase"] Balarm = data["Balarm"] Bhard = data["Bhard"] Bgrade = data["Bgrade"] Bpolice = data["Bpolice"] if group and rate and category and user: return group, rate, category, user, Bbase, Balarm, Bhard, Bgrade, Bpolice result = limiter_conf.find({'channels': channel}, {'rate': 1, '_id': 1, 'category': 1, 'user': 1, 'Bbase': 1, 'Balarm': 1, 'Bhard': 1, 'Bgrade': 1, 'Bpolice': 1}) logger.info("find_group result.count(): %s" % result.count()) if not result or result.count() == 0: logger.info("find_group [channel not found.]: %s" % channel) return None, None, None, None, None, None, None, None, None for line in result: group = "rate_%s" % line["_id"] rate = line["rate"] category = line["category"] user = line["user"] Bbase = line["Bbase"] Balarm = line["Balarm"] Bhard = line["Bhard"] Bgrade = line["Bgrade"] Bpolice = line["Bpolice"] logger.info('find_group [config] group: %s|| rate: %s|| category: %s|| user: %s|| Bbase: %s|| Balarm: %s|| Bhard: %s|| Bgrade: %s|| Bpolice: %s' % (group, rate, category, user, Bbase, Balarm, Bhard, Bgrade, Bpolice)) cache = {} cache["_id"] = group cache["rate"] = rate cache["category"] = category cache["user"] = user cache["Bbase"] = Bbase cache["Balarm"] = Balarm cache["Bhard"] = Bhard cache["Bgrade"] = Bgrade cache["Bpolice"] = Bpolice REDIS_CONNECT_0.set(cache_key, json.JSONEncoder().encode(cache)) # json.dumps(cache) REDIS_CONNECT_0.expire(CHANNEL_LIMITER, CACHE_TTL) return group, rate, category, user, Bbase, Balarm, Bhard, Bgrade, Bpolice
def get(self, conf_id): info = limiter_conf.find_one({'_id': ObjectId(conf_id)}) if not info: return self.write(error_res('This config had already deleted')) try: limiter_conf.remove({'_id': ObjectId(conf_id)}) except Exception as e: logger.info('LimiterConfigDel[get][error]: %s' % (traceback.format_exc(e), )) else: del_limiter_cache(info['channels'], info['category']) self.redirect('/limiter_conf')
def add_config_cache(channel, category, conf): ''' 配置缓存加入 ''' try: for k, v in conf.items(): if isinstance(v, datetime.datetime): conf[k] = datetime.datetime.strftime(v, '%Y-%m-%dT%H:%M:%S') if k == '_id': conf[k] = str(v) _key = get_channel_cache_key(channel, category) REDIS_CONNECT_0.hmset(_key, conf) except Exception as e: logger.info('add_config_cache[error]: %s' % (traceback.format_exc(e), ))
def check_success_or_not(response): if response is None: return None if response.status_code == 200: result = decode_response_as_json(response.content) if result['errcode'] == 0: return result elif result['errcode'] == 400: logger.info('本轮预约未开始,下单失败。') else: logger.warning("errcode:" + str(result['errcode'])) logger.warning("errmsg :" + str(result['errmsg'])) logger.warning("detail :" + str(result['detailErrMsg'])) else: logger.error('http status_code: ' + str(response.status_code)) return None
def post(self): try: logger.info("Receiver[post] request: %s" % self.request) data = json.loads(self.request.body) # data: {'BGP-BJ-Mhttp://musicfile.baidu.com': 500} message = {} if not data: message['error_type'] = 'null data' message['code'] = 201 return json.loads(message) # report_data(data) # ... response = report_data(data) logger.info('Receiver[post] response: %s' % (response, )) self.write(response) except Exception as e: logger.error("Receiver[error]: %s" % (traceback.format_exc(e), ))
def post(self): username = self.get_argument('user') conf_type = self.get_argument('conf_type', 'auth') resp = yield AsyncHTTPClient().fetch(RCMS_API % (username)) w = {'code': 0, 'channels': []} all_channel = [] if resp.code == 200: if resp.body: resp_json = json.loads(resp.body) if resp_json: all_channel = [i['name'] for i in resp_json] else: # 用户名错误or用户无任何频道 w['code'] = 1 else: # 用户名错误or用户无任何频道 w['code'] = 1 else: # rcms 异常 w['code'] = 2 if conf_type == 'auth': can_set_channel = set() if all_channel: a_set = set(all_channel) h_set = set() # had_config_channel = control_conf.find({'channel':{'$in':all_channel}},{'channel':1}) # for h in had_config_channel: # h_set.add(h['channel']) can_set_channel = a_set.difference(h_set) w['channels'] = list(can_set_channel) elif conf_type == 'limiter': can_set_channel = set() if all_channel: a_set = set(all_channel) h_list = [] # had_limiter_channel = limiter_conf.find({'channels':{'$in':all_channel}},{'channels':1}) # for h in had_limiter_channel: # h_list.extend(h['channels']) can_set_channel = a_set.difference(set(h_list)) logger.info('CheckUserToRcms[post] len(set(h_list)): %s' % len(set(h_list))) w['channels'] = list(can_set_channel) self.write(json.dumps(w))
def post(self): query = {} query_id = self.get_argument('query_id', '') logger.info('LimiterConfigTop[post] query_id: %s' % query_id) if query_id: query = {'$or': [{'user': query_id}, {'channel': query_id}]} c_page = int(self.get_argument('c_page', 0)) res = get_all_conf(c_page, query, col=limiter_conf) for k, v in res.items(): if k == 'all_conf': for line in v: line['category'] = analysis_directions(line['category']) self.render('limiter_conf.html', query_id=query_id, all_conf=res['all_conf'], totalpage=res['totalpage'], c_page=c_page)
def check_status(): data = {"city_id": 20} response = post(URI_STATUS_CHECK, data=json.dumps(data), headers=header, timeout=config.CEHCK_STATUS_TIMEOUT_SECONDS) result = check_success_or_not(response) if result is not None: status = result['data']['status'] if status == 'preorder': return True elif status == 'finish': yesterday = datetime.date.today() + datetime.timedelta(days=-1) yesterday_str = str(yesterday.year) + str(yesterday.month) + str( yesterday.day) logger.info('本轮预约未开始。上一轮(' + yesterday_str + ')预约已结束。') elif status == 'wait': logger.info('本轮预约未开始。') else: exit(1) return False
def read_command_args(): args = sys.argv args_count = len(args) - 1 if args_count == 1 and (args[1] == '-h' or args[1] == '--help'): print() print(' -n, --name 设置姓名') print(' -i, --id 设置身份证号码') print(' -m, --mobile 设置手机号码') print(' -t, --type 设置口罩类型, 1=N95(5个), 2=普通防护(10个)') print(' -s, --session 设置会话id') print(' --status-timeout 检查状态超时时间,单位:秒,默认 3 秒') print(' --order_timeout 下单接口超时时间,单位:秒,默认 2 秒') print() print(' -h, --help 查看所有参数', end='\n\n') exit(0) if args_count & 1 == 1: logger.error('[Check your arguments]检查输入参数') exit(1) for i in range(0, args_count >> 1): idx = i * 2 key = args[idx + 1] val = args[idx + 2] logger.debug('{}={}'.format(key, str(val))) if key == '-n' or key == '--name': config.YOUR_NAME = str(val) elif key == '-i' or key == '--id': config.YOUR_IDNO = str(val) elif key == '-m' or key == '--mobile': config.YOUR_MOBILE = str(val) elif key == '-t' or key == '--type': config.MASK_TYPE = int(val) elif key == '-s' or key == '--session': config.LOGIN_SESSION_ID = str(val) elif key == '--status-timeout': config.CEHCK_STATUS_TIMEOUT_SECONDS = int(val) elif key == '--order_timeout': config.ORDER_TIMEOUT_SECONDS = int(val) else: logger.info('[Unknown Arguments]未知参数:{}={}'.format(key, str(val)))
def post(self): limiter_id = self.get_argument('limiter_id') limiter_c1 = self.get_argument('limiter_c1') limiter_c2 = self.get_argument('limiter_c2') limiter_ttl = self.get_argument('limiter_ttl') logger.info( "LimiterPublicConfigC[post] limiter_c1: %s|| limiter_c2: %s|| limiter_ttl: %s" % (limiter_c1, limiter_c2, limiter_ttl)) if not limiter_c1: return self.write(error_res('Please put C1')) if not limiter_c2: return self.write(error_res('Please put C2')) if not limiter_ttl: return self.write(error_res('Please put TTL')) limiter_public_conf.update( {"_id": ObjectId(limiter_id)}, {'$set': { 'C1': limiter_c1, 'C2': limiter_c2, 'TTL': limiter_ttl }}) self.redirect('/limiter_conf/public_param')
def sum_list(current_list, category_list, user_list, group_list): all_dev_rate = [] index = 0 for l in current_list: # logger.info("sum_list category_list: %s" % category_list) direction_two, direction_upper = judge_direction(category_list[index]) # logger.info("sum_list direction_two: %s|| direction_upper: %s" % (direction_two, direction_upper, )) if direction_two == "11": one_three_direction = 0.0 two_four_direction = 0.0 for li in category_list[index].split(","): if li != 'in' and li != 'out': dev_ra = sum_list_single(current_list[index], li) if li == 'e1' or li == 'e3': one_three_direction = one_three_direction + dev_ra else: two_four_direction = two_four_direction + dev_ra if direction_upper == 'true': upper_rate = get_rate(user_list[index], group_list[index]) logger.info("sum_list upper_rate: %s" % upper_rate) if upper_rate == None: one_three_direction = one_three_direction + 0.0 two_four_direction = two_four_direction + 0.0 else: one_three_direction = one_three_direction + upper_rate two_four_direction = two_four_direction + upper_rate if one_three_direction >= two_four_direction: all_dev_rate.append(one_three_direction) else: all_dev_rate.append(two_four_direction) else: for li in category_list[index].split(","): if li != 'in' and li != 'out': dev_rate = sum_list_single(current_list[index], li) if direction_upper == 'true': upper_rate = get_rate(user_list[index], group_list[index]) if upper_rate == None: logger.info("sum_list upper_rate: %s" % upper_rate) dev_rate = dev_rate + 0.0 else: logger.info("sum_list upper_rate: %s" % upper_rate) dev_rate = dev_rate + upper_rate all_dev_rate.append(dev_rate) index = index + 1 return all_dev_rate
def post(self): category = self.get_argument('category', '') # logger.info('ConfigAdd[post] category: %s' % category) user = self.get_argument('user', '') # logger.info('ConfigAdd[post] user: %s' % user) channels = self.get_arguments('box_channels') # logger.info('ConfigAdd[post] channel: %s' % channel) suffix = self.get_argument('suffix') if not suffix: suffix = '' cycle = self.get_argument('cycle', 0) # if not cycle: # return self.write(error_res('Please put cycle')) cycle = 0 if not cycle else int(cycle) # logger.info('ConfigAdd[post] cycle: %s' % cycle) num = self.get_argument('num', 0) # if not num: # return self.write(error_res('Please put num')) num = 0 if not num else int(num) # logger.info('ConfigAdd[post] num: %s' % num) visit_cycle = self.get_argument('visit_cycle', 0) # if not visit_cycle: # return self.write(error_res('Please put visit_cycle')) visit_cycle = 0 if not visit_cycle else int(visit_cycle) # logger.info("ConfigAdd[post] visit_cycle: %s" % visit_cycle) visit_num = self.get_argument('visit_num', 0) # if not visit_num: # return self.write(error_res('Please put visit_num')) visit_num = 0 if not visit_num else int(visit_num) # logger.info("ConfigAdd[post] visit_num: %s" % visit_num) # cache_invalid_time = self.get_argument('cache_invalid_time') # if not cache_invalid_time: # return self.write(error_res('Please put cache_invalid_time')) cache_invalid_time = int(cycle) # logger.info("ConfigAdd[post] cache_invalid_time: %s" % cache_invalid_time) add_query_time = self.get_argument('add_query_time') rules_str = self.get_argument('rules_map') if rules_str: for line in rules_str.split('\n'): if len(line.split(',')) != 4: return self.write( error_res( 'Please enter the right field: multi-rules-config-board.' )) rules_map = [{ "theKey": i.split(',')[0].strip(), "theCycle": int(i.split(',')[1].strip()), "theNum": int(i.split(',')[2].strip()), "thePeriod": int(i.split(',')[3].strip()) } for i in rules_str.split('\n')] else: rules_map = [] # logger.info('ConfigAdd[post] rules_map: %s' % (rules_map, )) named_str = self.get_argument('named_map') if named_str: for line in named_str.split('\n'): if len(line.split(',')) != 5: return self.write( error_res('Please enter the right field: named.')) named_map = [{ "named": i.split(',')[0].strip(), "locationName": i.split(',')[1].strip(), "namedCycle": int(i.split(',')[2].strip()), "namedNum": int(i.split(',')[3].strip()), "namedPeriod": int(i.split(',')[4].strip()) } for i in named_str.split('\n')] else: named_map = [] logger.info('ConfigAdd[post] named_map: %s' % (named_map, )) if not add_query_time: # if not have add_query_time the add_query_time equal cycle add_query_time = cycle add_query_time = int(add_query_time) all_query_time = self.get_argument('all_query_time') if not all_query_time: all_query_time = 24 * 60 * 60 all_query_time = int(all_query_time) for c in channels: config_cache = get_config_cache(c + suffix, category) if config_cache: return self.write( error_res('%s %s config cache had already added' % (c + suffix, category))) for i in channels: logger.info( 'ConfigAdd[post] i: %s|| category: %s|| num: %s|| cycle: %s' % ( i, category, num, cycle, )) tempDict = { 'user': user, 'channel': i, 'suffix': suffix, 'num': num, 'category': category, 'cycle': cycle, 'visit_cycle': visit_cycle, 'visit_num': visit_num, 'cache_invalid_time': cache_invalid_time, 'created_time': datetime.datetime.now(), 'add_query_time': add_query_time, 'all_query_time': all_query_time } if rules_map: tempDict.update({'rules_map': rules_map}) if named_map: tempDict.update({'named_map': named_map}) control_conf.insert(tempDict) logger.info('ConfigAdd[post] type(suffix): %s|| suffix: %s' % (type(suffix), suffix)) makeSthStrInDict(tempDict, 'rules_map') makeSthStrInDict(tempDict, 'named_map') add_config_cache("%s%s" % (i, str(suffix)), category, tempDict) self.redirect('/conf')
def get(self): res = get_all_conf(col=limiter_public_conf) logger.info('LimiterPublicConfig[get] res: %s' % res) self.render('limiter_public_conf.html', all_conf=res['all_conf'])
def get(self): logger.info("Receiver[get] request: %s" % (self.request, ))