本文整理汇总了Python中settings.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upcall
def upcall(self, kind, upcallInfo):
if kind == pyndn.UPCALL_FINAL:#handler is about to be deregistered
return pyndn.RESULT_OK
if kind in [pyndn.UPCALL_INTEREST, pyndn.UPCALL_CONSUMED_INTEREST, pyndn.UPCALL_CONTENT_UNVERIFIED, pyndn.UPCALL_CONTENT_BAD]:
log.error("unexpected kind: %s" %kind)
return pyndn.RESULT_OK
if kind == pyndn.UPCALL_CONTENT:
self.is_all = True
log.info("get data back: %s" %(upcallInfo.Interest.name))
self.stop()
return pyndn.RESULT_OK
elif kind == pyndn.UPCALL_INTEREST_TIMED_OUT:
if self.turn == -1:
return pyndn.RESULT_REEXPRESS
else:
if self.ist_sentN < self.turn:
log.debug("timeout: %s" %(upcallInfo.Interest.name))
self.ist_sentN += 1
return pyndn.RESULT_REEXPRESS
else:
log.info("CANNOT get data back after %d trials: %s" %(self.turn, upcallInfo.Interest.name))
self.stop()
return pyndn.RESULT_OK
示例2: edit
def edit(page = 1):
"""
进行互评
"""
log.info("edit")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
schoolid,option = request.query.get('schoolid'),request.query.get('option')
db.assessment.update({'schoolid':user['schoolid'],"pro-others.schoolid":schoolid},{"$set":{"pro-others.$.option":option}})
pro_others = list(db.assessment.find_one({'schoolid':user['schoolid']},fields = ['pro-others'])['pro-others'])
options = list(db.options.find())#因为返回的是一个类似的list的cursor,但是它只能循环一次,所以将它转换为list
paginator = Paginator(pro_others,10,0)
pro_others = paginator.page(page)
page_range,num_pages = paginator.page_range,paginator.num_pages
show_firstpage = False if int(page) == 1 else True
show_lastpage = False if int(page) == num_pages else True
show_pages = 5
if num_pages <= show_pages:#当数量不足时
newpage_range = page_range
else:
newpage_range = list()
if int(page) + show_pages > num_pages:#用于显示后几位
for pagenum in range(num_pages - show_pages + 1,num_pages + 1):
newpage_range.append(pagenum)
else:
for pagenum in range(int(page),int(page)+show_pages):
newpage_range.append(pagenum)
return jinja2_template('edit-assessment.html',user = user,app = chermongapp,
options = options,pro_others = pro_others,show_firstpage=show_firstpage,
show_lastpage=show_lastpage,num_pages=num_pages,page_range=newpage_range)
示例3: read
def read(self):
"""read data from cache
"""
log.info("!+ %s cache reading begins")
fin = open(self.cacheout)
if self.datass == None:
self.datass = []
if self.datass == []:
pass
else:
assert isinstance(self.datass[0], list), "self.datass[0] is not a list"
assert len(self.datass[0]) == 0, "self.datass[0] is not empty"
self.datass = []
for line in fin.readlines():
line = line.strip()
if line.startswith("#headers:"):
cols = line[len("#headers:"):].strip().split("|")
if self.headers == None:
for head in cols:
if header != "":
self.headers.append(col)
elif line.startswith("#command:") or line.startswith("#note:"):
pass
elif line != "":
cols = line.split()
li = [float(cols[i]) for i in range(len(cols))]
self.datass.append(li)
log.info("!- %s cache reading ends")
示例4: stat
def stat(self):
f = open(self.fpath)
lastkind = "none"
count = 0
for line in f.readlines():
parts = line.split(",")
kind = parts[0].split("=")[1]
index = parts[2].split("=")[1]
if kind == lastkind:
count += 1
else:
count = 1
if kind == "loss":
count = -1 * count
self.datas.append(count)
#print "kind=%s, count=%s" %(kind, count)
if kind != "loss" and kind != "fetch":
print "!!!!!!!!kind = %s" %(kind)
count = 0
log.info("datas contains %d elements" %(len(self.datas)))
示例5: scatter
def scatter(self):
log.debug(self.Id+" begin to draw ")
plt.clf()
cans = []
for line in self.lines:
log.debug("line.xs="+str(line.xs))
log.debug("line.ys="+str(line.ys))
log.debug("plt atts="+str(line.plt))
#can = plt.plot(line.xs, line.ys, line.plt.pop("style", "-"), **line.plt)
can = plt.scatter(x=line.xs, y=line.ys, s=self.kwargs.get("c", 1), **line.plt)
cans.append(can)
plt.grid(True)
plt.xlabel(self.canvas.pop("xlabel", "X"))
plt.ylabel(self.canvas.pop("ylabel", "X"))
plt.xlim(xmax=self.canvas.pop("xmax", None))
self.extend(plt)#extend line
plt.legend(**self.canvas)
#loc='lower/upper left'
if HOSTOS.startswith("Darwin"):
pass
plt.savefig(self.pngout)
plt.savefig(self.pdfout)
log.debug(self.Id+" fig save to "+self.pngout)
plt.close()
log.info(self.Id+" ends")
示例6: stop
def stop(self):
self.status = Controller.STATUS_OFF
"""this is important, since we don't want to call stop twice.
stop is called implicitly in in_order_content when consuemr acquire all the contents
thus, when upper layer application call stop, it won't cause any problem, like fout is closed
meanwhile, we don't suggest upper layer applications change the status
"""
if _pyndn.is_run_executing(self.handle.ndn_data):
self.handle.setRunTimeout(1)
if not self.fout.closed:
self.mydata.endT = datetime.datetime.now()
self.fout.flush()
self.fout.close()
if self.enable_monitor:
if not self.event_log.closed:
self.event_log.flush()
self.event_log.close()
if threading.currentThread().is_alive():
log.info("%s stops!" %(self.Id))
log.info("requestedChunkN=%s" %(len(self.chunkInfos)))
log.info(str(self.mydata))
log.info(str(self.window))
log.info(str(self.chunkSizeEstimator))
return 0
示例7: run
def run(self):
""" run the case, after running, the statstical result is held in self.data as list
"""
#CaseTemplate.LiveN += 1
log.info("> " +self.Id+" begins TotalN/LiveN/SuccessN/ExistingN/FailN=%d/%d/%d/%d/%d" \
%(CaseTemplate.TotalN, CaseTemplate.LiveN, CaseTemplate.SuccessN, CaseTemplate.ExistingN, CaseTemplate.FailN))
if not self.to_refresh():
CaseTemplate.ExistingN += 1
self.read()
self.datas = self.datass[0]
self.result = True
pass
else:
rst = self.underlying()
if rst == True:
CaseTemplate.SuccessN += 1
self.result = True
self.get_data()
if not self.is_refresh:
self.write()
else:
log.error(self.Id+" return error" )
if os.path.exists(self.cacheout):
os.remove(self.cacheout)
CaseTemplate.FailN += 1
self.result = False
CaseTemplate.LiveN -= 1
log.info("< " +self.Id+" ends TotalN/LiveN/SuccessN/ExistingN/FailN=%d/%d/%d/%d/%d" \
%(CaseTemplate.TotalN, CaseTemplate.LiveN, CaseTemplate.SuccessN, CaseTemplate.ExistingN, CaseTemplate.FailN))
示例8: write
def write(self):
"""write data to cache
layout: horizontal, every sublist will be placed in one row
"""
if self.datass == None:
log.critical("datass is None")
return
fout = open(self.cacheout, "w") #write the data to result file
if self.headers != None:
line = ""
for header in self.headers:
line += "|" + header
line.strip()
line = "#headers: " + line+"\n"
fout.write(line)
#line = "#command: " + case.cmd + "\n"
#fout.write(line)
#assert self.datass != None, "self.datass == None"
assert isinstance(self.datass, list), "self.datass is not a list, %s" %(self.datass)
#assert isinstance(self.datass[0], list), "self.datass[0] is not a list, %s" %(self.datass[0])
for li in self.datass:
for val in li:
fout.write("%s\t" %(val))
fout.write("\n")
fout.flush()
fout.close()
log.info("$ " + self.Id+" cache writing")
示例9: logout
def logout():
'''
退出
'''
log.info("logout")
response.delete_cookie(key='user',secret='chermong')
return jinja2_template('login.html')
示例10: __init__
def __init__(self, main_url, url="", obj_name=None, limit=0, html=True, floor=0):
self.limit = limit
self.counter = 0
self.html = html
self.floor = floor
self.nowurl = url or main_url
self.starturl = url or main_url
self.page = 1
# 天涯目前贴子分两类,处理规则各不相同
# techforum、publicforum
self.thread_type = self.starturl.split("/")[3]
content = reconnecting_urlopen(main_url, retry=100).decode("gbk", "ignore")
log.info("content %s %s %s" % (len(content), type(content), content[:100]))
soup = BeautifulSoup(content)
# 处理obj_name
self.obj_name = obj_name
if not self.obj_name:
# 获得楼主昵称
if self.thread_type == "techforum":
self.obj_name = soup.find("div", {"class": "vcard"}).find("a", target="_blank").renderContents()
else:
self.obj_name = self.get_firstauthor(soup)
示例11: notify
def notify(self, way="email", **msg): #way="email"|"print"
'''notify users about running result, currently there are two ways: email, print
'''
self.t1 = time.time()
data = PAPER+" ends "+str(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(self.t1)))+ \
" TotalN=" + str(CaseTemplate.TotalN) +" SuccessN="+str(CaseTemplate.SuccessN)+ \
" ExistingN="+str(CaseTemplate.ExistingN) +" FailN="+str(CaseTemplate.FailN)
data = msg.get("data", data)
log.info(data)
if way == "print":
return
TO = msg.get("to", ["[email protected]"])
FROM = "[email protected]"
SMTP_HOST = "smtp.163.com"
user= "06jxk"
passwords="jiangxiaoke"
mailb = ["paper ends", data]
mailh = ["From: "+FROM, "To: [email protected]", "Subject: " +data]
mailmsg = "\r\n\r\n".join(["\r\n".join(mailh), "\r\n".join(mailb)])
send = SMTP(SMTP_HOST)
send.login(user, passwords)
rst = send.sendmail(FROM, TO, mailmsg)
if rst != {}:
self.log.warn("send mail error: "+str(rst))
else:
self.log.info("sending mail finished")
send.close()
示例12: express_interest
def express_interest(self, chunkinfo):
"""this method may express illegal Interest, thus, re_express_interest and first_express_interest are in charge of checking;
even that, there may also illegal Interest, due to unknown final_byte, leading to useless chunkinfo in chunkinfos and illegal Data(Nack) or Interest timeout
(we do not use is_all to check, since final_byte is more accurate and is_all -> final_byte);
thus, we need do_receiving_content to handle illegal Data
"""
assert chunkinfo != None, "chunkinfo == None"
assert chunkinfo.endT == None, "chunkinfo.endT != None"
selector = pyndn.Interest()
selector.answerOriginKind = 0#producer generate every time
selector.childSelctor = 1
selector.interestLifetime = self.rtoEstimator.get_rto()
rst = self.handle.expressInterest(chunkinfo.ndn_name, self, selector)
if rst != None and rst < 0:
log.info("fail to express interest=%s with result %s" %(chunkinfo.ndn_name, rst))
self.window.update_nack(chunkinfo)
chunkinfo.status = 0
else:
chunkinfo.retxN += 1
log.debug("express interest=%s" %(chunkinfo.ndn_name))
示例13: manage_user
def manage_user(page = 1):
"""
查看用户信息
"""
log.info("manage_user")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
users = list(db.user.find())
paginator = Paginator(users,10,0)
try:
users = paginator.page(page)
except (EmptyPage, InvalidPage):
users = paginator.page(paginator.num_pages)
page_range,num_pages = paginator.page_range,paginator.num_pages
show_firstpage = False if int(page) == 1 else True
show_lastpage = False if int(page) == num_pages else True
show_pages = 5
if num_pages <= show_pages:#当数量不足时
newpage_range = page_range
else:
newpage_range = list()
if int(page) + show_pages > num_pages:#用于显示后几位
for pagenum in range(num_pages - show_pages + 1,num_pages + 1):
newpage_range.append(pagenum)
else:
for pagenum in range(int(page),int(page)+show_pages):
newpage_range.append(pagenum)
return jinja2_template('manage-user.html',user = user,app = chermongapp,
users = users,show_firstpage=show_firstpage,show_lastpage=show_lastpage,
num_pages=num_pages,page_range=newpage_range)
示例14: index
def index():
"""
显示主页面
"""
log.info("index")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
return jinja2_template('index.html',user = user,app = chermongapp)
示例15: changepasswd
def changepasswd():
"""
修改密码
"""
log.info("changepasswd")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
return jinja2_template('changepasswd.html',user = user,app = chermongapp)