本文整理汇总了Python中settings.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:zzfan,项目名称:ndnflow,代码行数:26,代码来源:ndn_flow.py
示例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)
开发者ID:1060460048,项目名称:assessment,代码行数:32,代码来源:engine.py
示例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")
开发者ID:shockjiang,项目名称:ndnflow,代码行数:32,代码来源:paper_kit.py
示例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)))
开发者ID:shockjiang,项目名称:ndnflow,代码行数:28,代码来源:upcall_event_stat.py
示例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")
开发者ID:shockjiang,项目名称:ndnflow,代码行数:32,代码来源:paper_kit.py
示例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
开发者ID:zzfan,项目名称:ndnflow,代码行数:35,代码来源:ndn_flow.py
示例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))
开发者ID:shockjiang,项目名称:ndnflow,代码行数:30,代码来源:paper_kit.py
示例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")
开发者ID:shockjiang,项目名称:ndnflow,代码行数:32,代码来源:paper_kit.py
示例9: logout
def logout():
'''
退出
'''
log.info("logout")
response.delete_cookie(key='user',secret='chermong')
return jinja2_template('login.html')
开发者ID:packfatty,项目名称:assessment,代码行数:7,代码来源:engine.py
示例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)
开发者ID:jackman0925,项目名称:nowater,代码行数:25,代码来源:tianya_crawler.py
示例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()
开发者ID:shockjiang,项目名称:ndnflow,代码行数:31,代码来源:paper_kit.py
示例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))
开发者ID:zzfan,项目名称:ndnflow,代码行数:25,代码来源:ndn_flow.py
示例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)
开发者ID:1060460048,项目名称:assessment,代码行数:31,代码来源:engine.py
示例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)
开发者ID:packfatty,项目名称:assessment,代码行数:8,代码来源:engine.py
示例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)
开发者ID:packfatty,项目名称:assessment,代码行数:8,代码来源:engine.py
示例16: about_copyright
def about_copyright():
"""
关于版权声明
"""
log.info("about_copyright")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
return jinja2_template('about-copyright.html',user = user,app = chermongapp)
开发者ID:packfatty,项目名称:assessment,代码行数:8,代码来源:engine.py
示例17: about_author
def about_author():
"""
关于作者
"""
log.info("about_author")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
return jinja2_template('about-author.html',user = user,app = chermongapp)
开发者ID:packfatty,项目名称:assessment,代码行数:8,代码来源:engine.py
示例18: user_lookup
def user_lookup():
"""
查看用户信息
"""
log.info("user_lookup")
user = request.get_cookie('user',secret="chermong")
user = db.user.find_one({'name':user})
return jinja2_template('userprofile.html',user = user,app = chermongapp)
开发者ID:packfatty,项目名称:assessment,代码行数:8,代码来源:engine.py
示例19: __init__
def __init__(self, Id, name, fout=None, monitor_out_dir=settings.OUT_DATA_DIR, cache_data=True,
enable_monitor=True, size_fix=None, window_fix=None, rtt_fix=None,
packet_max_data_size=ETH_MTU-IP_HEADER_SIZE-UDP_HEADER_SIZE):
"""
"""
Controller.__init__(self)
self.Id = Id
if monitor_out_dir == None:
monitor_out_dir = settings.OUT_DATA_DIR
self.monitor_out_dir = monitor_out_dir
print self.monitor_out_dir
log.info("monitor file: %s" %(self.monitor_out_dir))
if not os.path.exists(self.monitor_out_dir):
os.makedirs(self.monitor_out_dir)
global CHUNK_HEADER_SIZE, MAX_DATA_SIZE
#if len(ndn_name) > 50:
CHUNK_HEADER_SIZE += len(name)
MAX_DATA_SIZE -= len(name)
if not name.startswith("ndnx:") and not name.startswith("/"):
name = "/" + name
self.ndn_name = pyndn.Name(name)
"""since there is a "name" field in threading.Thread, we name it as ndn_name
"""
self.cache_data = cache_data
self.enable_monitor = enable_monitor
if self.enable_monitor == True:
self.event_log = os.path.join(self.monitor_out_dir, "upcall_events-%s.log" %(self.Id))
self.event_log = open(self.event_log, "w")
self.fout = fout
if self.fout == None:
self.fout = os.path.join(".", "acquire")
if not os.path.exists(self.fout):
os.makedirs(self.fout)
self.fout = os.path.join(self.fout, name.replace("/", "-")[1:])
#self.fout = os.path.join(self.fout, Id)
self.fout = open(self.fout, "w")
self.size_fix = size_fix
self.window_fix = window_fix
self.packet_max_data_size = packet_max_data_size
self.is_all = False #already fetch all the chunks,
self.handle = pyndn.NDN()
self.chunkInfos = []#only insert new elements when first_express_interest
self.mydata = MyData()
self.chunkSizeEstimator = ChunkSizeEstimator(Id=self.Id, out_dir=self.monitor_out_dir, packet_max_data_size=self.packet_max_data_size, is_fix=size_fix, enable_monitor=enable_monitor)
self.window = SlideWindow(Id=self.Id, out_dir=self.monitor_out_dir, is_fix=window_fix, enable_monitor=enable_monitor)
self.rtoEstimator = RtoEstimator(Id=self.Id, out_dir=self.monitor_out_dir, is_fix=rtt_fix, enable_monitor=enable_monitor)
开发者ID:zzfan,项目名称:ndnflow,代码行数:58,代码来源:ndn_flow.py
示例20: timbra_xml
def timbra_xml(xml):
log.info('Enviando a timbrar...')
id_timbrado = util.get_epoch()
ok, data = util.timbra_xml(atributos['emisor']['rfc'], xml, id_timbrado)
if ok:
name = '{}/{}.xml'.format(PATH['TIMBRADAS'], data['UUID'])
util.save_file(name, data['XML'])
log.info('Factura timbrada correctamente: {}'.format(name))
return
开发者ID:e-fector,项目名称:cfdi-test,代码行数:9,代码来源:solo_timbrar.py
注:本文中的settings.log.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论