def getIP(self): try: res=urllib2.urlopen('http://whois.pconline.com.cn/ipJson.jsp',timeout=2000) except: return None if res.getcode()!=200: return None re=res.read().decode('gbk').encode('utf8') res.close() re=re[re.rfind('{'):re.find('}')+1] return json.loads(re)
def getIP(): try: res=urllib2.urlopen('http://whois.pconline.com.cn/ipJson.jsp',timeout=2) except: return None if res.getcode()!=200: return None re=res.read().decode('gbk').encode('utf8') res.close() re=re[re.rfind('{'):re.find('}')+1] return json.loads(re)
def check_pcre_compile(re): options = [] if len(re) and re[0] == '/': optp = re.rfind('/') if optp > 0: options = list(re[optp + 1:]) re = re[1:optp] opts = 0 for opt in options: if opt in PCRE_OPT: opts |= PCRE_OPT[opt] try: sniffles.pcrecomp.compile(re, opts) except: return False return True
def _conditionalize(self, args): part = args[0] next = [] segments = args[1:] for segment in segments: next.append(self._conditionalize(segment)) next = ', '.join(next) if next: next = ''.join([', ', next]); conditions = [] for name in rfind('[:*](\\w+)', part): conditions.append(''.join(['"', name, '" in parameters'])) if conditions: conditions = ' and '.join(conditions) else: conditions = 'true' return ''.join(['((', conditions, ') and "".join(["', rsub('[:*](\\w+)', '", parameters["\\1"], "', part), '"', next, ']) or "")'])