本文整理汇总了Python中common.Common.log方法的典型用法代码示例。如果您正苦于以下问题:Python Common.log方法的具体用法?Python Common.log怎么用?Python Common.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_proxy
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import log [as 别名]
txt = txt.decode('gbk', 'ignore')
return txt
def test_proxy(ip, port, prot='http', timeout=15, url='http://ww.xitek.com/link/201504/08-175881.html', keywords='100252'):
proxy = urllib2.ProxyHandler( { prot:"%s:%s" % (ip, port) } )
opener = urllib2.build_opener(proxy)
try:
resp = opener.open(url, timeout=timeout)
txt = gethtmlfromresp(resp)
except Exception, e:
return None
if txt.find(keywords) != -1: # '11002528' is the regist no. of xitek, should be presented on the page
return txt
else:
try:
logger.log(u"ERROR: '%s' not found. Content-Encoding='%s'\n%s\n%s\n%s" % (keywords, resp.info().get('Content-Encoding'), '='*80, txt, '=' * 80))
except:
pass
return None
def refresh_proxies(num=None):
logger.log(u'refreshing proxy list num=%s' % (num))
newlist = build_proxies(num)
if not newlist:
return None
# refresh proxy list
g_proxies_lock.acquire()
while g_proxies: g_proxies.pop()
g_proxies.extend(newlist)
g_proxies_lock.release()
示例2: len
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import log [as 别名]
if len(sys.argv) > 1:
quickstartnum = sys.argv[1]
else:
quickstartnum = 0
return int(quickstartnum)
if __name__ == '__main__':
daily()
hourly(quickstart())
logger = Common()
while True:
reload(ids)
for badid in ids.badids:
for vest, status in ids.badids[badid]:
if status == u'inactive':
continue
build_hunters()
hunter = get_hunter()
if hunter:
try:
hunter.log(u'开始处理:%s 肉身:%s, hunters: %d个' % (vest, badid, len(g_hunters)))
deal(badid, vest, hunter)
hunter.log(u'处理完成!%s 肉身:%s' % (vest, badid))
except Exception, e:
hunter.log(u"处理 %s 失败。%s" % (vest, str(e)))
finally:
time.sleep(3)
else:
logger.log(u"没有可用的hunter了!快快补充!")
time.sleep(60)
示例3: log
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import log [as 别名]
def log(self, msg, newline=False):
newmsg = u"%s (proxy=>%s:%s)" % (msg, self.addr, self.port)
Common.log(self, newmsg, newline=newline)
示例4: FestivalHunter
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import log [as 别名]
mesg = u'失败(%d): %s 肉身:%s, 马甲: %s 原板块ID: %s' % (code, url, u'糊涂终结者', vest, fid)
mesg = mesg + "\n" + u"原帖地址: %s" % (u'http://forum.xitek.com/forum-redirect-goto-findpost-ptid-%d-pid-%d.html' % (tid, pid))
hunter.log(mesg)
if code == 0: # 如果是此次回复成功的,那么休息35秒再发贴,因为论坛可能有成功发帖的时间限制
time.sleep(31)
elif code == 4: # 如果马甲阵亡,打印后退出线程。
hunter.log(u'%s 阵亡。退出线程:%s 。' % (hunter.name, threading.current_thread().name))
break
else:
time.sleep(20)
conn.close()
if __name__ == '__main__':
logger.log(u"\n\n\n\n\n嘉年华即将开始于:(%s)" % (sys.argv[1]))
logger.log(u"duration: %s seconds." % (get_duration()))
logger.log(u"warning post: %s" % (warning()))
xitekv2.proxy.refresh_proxies(30)
t = threading.Timer(60*60, xitekv2.hourly)
t.setDaemon(True)
t.start()
hunter_pairs = []
for hunter_name, hunter_pass, vest in g_pairs:
h = FestivalHunter(hunter_name, hunter_pass)
if h.login():
h.log(u'"%s"登录成功' % (h.name))
hunter_pairs.append((h,vest))
workers = []
timeleft = get_dead_line() - time.time()