本文整理汇总了Python中student.Student.instance方法的典型用法代码示例。如果您正苦于以下问题:Python Student.instance方法的具体用法?Python Student.instance怎么用?Python Student.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.Student
的用法示例。
在下文中一共展示了Student.instance方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def get(self):
if isStudent(self):
self.finish(success=False,notification='权限不足,无法修改数据')
return
idc = self.get_argument('idc','')
name = self.get_argument('name','')
stu = Student.instance()
if name == '' :
stu.logger.warning('request param name is empty')
self.finish(success=False)
return
if idc == '' :
stu.logger.warning('request param idc is empty')
self.finish(success=False)
return
sid = stu.getStuIdOnName(name)
ret = self.searchAndDelRI(sid,idc)
if ret == 0 :
stu.logger.info('Delete reward info done')
self.finish(success=True)
return
self.finish(success=False)
return
示例2: getAttendInfoBetween
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def getAttendInfoBetween(self,begin,end):
stu = Student.instance()
try:
if type(begin) != type(datetime) :
begin = datetime.strptime(begin,'%Y/%m/%d')
if type(end) != type(datetime) :
end = datetime.strptime(end,'%Y/%m/%d')
stu.logger.info(begin)
stu.logger.info(end)
if end < begin :
return []
days = (end-begin).days
stu.logger.info(days)
rets=[]
for n in range(0,days+1):
day = begin + timedelta(n)
day = day.strftime('%Y/%m/%d')
stu.logger.info(day)
ret = stu.getAttendInfo(day)
stu.logger.info(ret)
for info in ret:
info = json.loads(info)
rets.append(info)
return rets
except Exception,e:
stu.logger.error(e)
示例3: post
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def post(self):
try:
if isStudent(self):
self.finish(success=False,notification='权限不足,无法修改数据')
return
stu = Student.instance()
stuinfo = json.loads(self.request.body)
if type(stuinfo)==type({}) and stuinfo.has_key('data') :
sis = stuinfo['data']
if type(sis)==type({}):
sis = [sis]
for si in sis:
ret = stu.getStuInfo(si['stuid'])
if si.has_key('idc') and not si['idc'].startswith('stu_'):
si['idc'] = u'stu_' +stu.getuuid()
if not si.has_key('idc'):
si['idc'] = u'stu_' +stu.getuuid()
if si.has_key('class') and not si['class'].isdigit() :
si['class'] = stu.getClassIdOnName(si['class'])
stu.setStuIdOnName(si['name'],si['stuid'])
stu.logger.info('set stu id(%s) on name(%s) ' % (si['stuid'],si['name']))
stu.setStuIDofClass(si['stuid'],si['class'])
stu.logger.info('set stu id(%s) on class id (%s) ' % (si['stuid'],si['class']))
stu.logger.info('set stu info %s' % str(si))
stu.setStuInfo(si)
except Exception,e:
stu.logger.error(e)
self.finish(success=False)
return
示例4: getNewsList
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def getNewsList(self,count=25):
stu = Student.instance()
news = stu.getNotices(to=count-1)
ret=[]
for new in news:
new = stu.str2dict(new)
if new.has_key('idc') and new.has_key('title') :
ret.append({'id':new['idc'],'text':new['title'],'leaf':'true','icon':'static/pic/rss.gif'})
return ret
示例5: setStuIDOnName
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def setStuIDOnName():
stu = Student.instance()
r = stu.getDB()
sks = r.keys('student:20*')
for sk in sks:
sid = sk[8:]
si = stu.getStuInfo(sid)
sn = si['name']
stu.setStuIdOnName(sn,sid)
print sid,sn
示例6: compRank
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def compRank(self,data,key,value):
stu = Student.instance()
tmp=[]
for d in data.values():
tmp.append(float(d[key]))
tmp = list(set(tmp))
tmp.sort(reverse=True)
for d in data.values():
d[value] = tmp.index(float(d[key])) + 1
示例7: searchAndDelRI
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def searchAndDelRI(self,sid,idc):
try:
stu = Student.instance()
ris = stu.getRewardInfo(sid)
for ri in ris:
tmp = stu.str2dict(ri)
if idc == tmp['idc'] :
stu.deleteRewardInfo(sid,ri)
break
except Exception,e:
stu.logger.error(e)
示例8: searchAndDelAI
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def searchAndDelAI(self,day,idc) :
try:
stu = Student.instance()
ais = stu.getAttendInfo(day)
for ai in ais:
tmp = stu.str2dict(ai)
if tmp.has_key('idc') and tmp['idc'] == idc :
stu.deleteAttendInfo(day,ai)
return 0
return 1
except Exception,e:
stu.logger.info(e)
return -1
示例9: initClass
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def initClass():
stu = Student.instance()
cls = stu.getAllClassIDs()
for c in cls:
ci={}
ci['id'] = c['id']
ci['name'] = c['name']
ci['teacher']='' #head teacher
ci['telephone']='' # teacher's phone number
ci['master']='' # master of the class
ci['mphone'] ='' # master 's phone
ci['stuids']=[] # all stu id
stu.setClassInfo(c['id'],ci)
示例10: searchAndDelQI
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def searchAndDelQI(self,cid,idc):
try:
stu = Student.instance()
qs = stu.getQuanInfo(cid)
for q in qs:
tmp = stu.str2dict(q)
if tmp.has_key('idc') and tmp['idc'] == idc :
stu.deleteQuanInfo(cid,q)
return 0
return 1
except Exception,e:
stu.logger.error(e)
return -1
示例11: addUser
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def addUser():
stu = Student.instance()
r = stu.getDB()
stuKeys = r.keys("student:*")
for key in stuKeys:
value={}
stuInfo = r.get(key)
#stuid = key.replace('student:','')
if stuInfo!= None:
stuInfo = json.loads(stuInfo)
if stuInfo['stuid']=='0':
continue
else:
value['user'] = stuInfo['stuid']
value['role'] = '80000' #student
value['pwd'] = stuInfo['identify'][-8:]
stu.setUserInfo(stuInfo['user'],value)
print stuInfo['stuid'],value
示例12: getQuanInfoBetween
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import instance [as 别名]
def getQuanInfoBetween(begin,end):
stu = Student.instance()
stu.logger.info("begin:"+str(begin)+" end:"+str(end))
ret = []
qinfos = stu.getAllQuanInfos()
for qi in qinfos:
date = datetime.strptime(str(qi['quan_date']),'%Y/%m/%d')
if begin<= date and end>= date:
stu.logger.info('quaninfo:'+str(qi))
try:
qi['student'] = stu.getStuNameOnId(qi['student'])
qi['quan_type']= stu.getQuanNameOnId(qi['quan_type']).decode('utf-8')
qi['class'] = stu.getClassNameOnId(qi['class'])
stu.logger.info('qinfo : %s' % str(qi))
except Exception,e:
stu.logger.error(e)
continue
ret.append(qi)