def compare_url(last_url=None,new_url=None): diff_url_str="" if len(last_url)<len(new_url): for url in list(set(new_url)-set(last_url)): diff_url_str+="\n\t"+url msg="New node has been found:<hl>{0:s}</hl>".format(diff_url_str) else: for url in list(set(last_url)-set(new_url)): diff_url_str+="\n\t"+url msg="Missed node:<hl>{0:s}</hl>".format(diff_url_str) logger.warning(msg)
def confcompare(self, url_dict, conf_file): if not os.path.isfile(conf_file): msg='Didn\'t find <hl>compare files</hl> to check the response data.' logger.warning(msg) conf = configparser.ConfigParser() conf.optionxform = str conf.read(conf_file) current_url_name=url_dict["Name"] if current_url_name in conf: for opt,value in conf[current_url_name].items(): if opt in url_dict: if str(url_dict[opt])==value.strip(): msg="{0}: Value mathced for key: {1}, got: {2}"\ .format(current_url_name,opt, value.strip()) logger.info(msg) else: msg="{0}: Value mismatched for key: <hl>{1}</hl>, expect: <hl>{2}</hl>, got: {3}"\ .format(current_url_name,opt, value.strip(),str(url_dict[opt])) logger.error(msg) else: msg="{0}: Can't find key: <hl>{1}</hl> in response data, check config"\ .format(current_url_name,opt) logger.error(msg)
def request_time_check(self, request_time,url): msg="RESTful Server takes <hl>'{0}'</hl> to respond URL:{1}".format(request_time,url) if request_time>CONF.REQUEST.http_time_warn and request_time<CONF.REQUEST.http_time_error: logger.warning(msg) elif request_time>CONF.REQUEST.http_time_error: logger.error(msg)