本文整理匯總了Python中gl.LOG.info方法的典型用法代碼示例。如果您正苦於以下問題:Python LOG.info方法的具體用法?Python LOG.info怎麽用?Python LOG.info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gl.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def get(self):
enter_func(self)
if not set(['subject', 'grade', 'version']).issubset(self.request.arguments.keys()):
return leave_func(self, 1)
params = { 'subject': self.request.arguments['subject'][0], 'grade': self.request.arguments['grade'][0], 'version': self.request.arguments['version'][0] }
if 'unit' in self.request.arguments.keys():
params['Unite'] = self.request.arguments['unit'][0]
if 'lesson' in self.request.arguments.keys():
params['Lesson'] = self.request.arguments['lesson'][0]
if 'word' in self.request.arguments.keys():
params['word'] = self.request.arguments['word'][0]
if 'stype' in self.request.arguments.keys():
params['stype'] = self.request.arguments['stype'][0]
if 'order' in self.request.arguments.keys():
params['order'] = self.request.arguments['order'][0]
if 'page_num' in self.request.arguments.keys():
params['pn'] = self.request.arguments['page_num'][0]
else:
params['pn'] = 1
if 'page_size' in self.request.arguments.keys():
params['rn'] = self.request.arguments['page_size'][0]
params['token'] = generate_token()
params['host'] = host
url = 'http://wenku.baidu.com/api/interface/getsubject?%s' % urllib.urlencode(params)
LOG.info(url)
ret = json.loads(urllib2.urlopen(url).read().decode('raw_unicode_escape'))
LOG.info(ret)
if 0 != ret['status']['code']:
LOG.error('baidu library interface error: %s' % ret['status'])
return leave_func(self, 100)
ret = dict(error_process(0).items() + ret['data'].items())
leave_func(self, 0)
return self.write(json.dumps(ret, ensure_ascii=False))
示例2: query
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def query(self,sql,**kwds):
try:
self.sql = sql % kwds
LOG.info('execute SQL[%s]' % (self.sql))
self.cur.execute(self.sql)
except MySQLdb.Warning,w:
LOG.warn('Warning:%s' % str(w))
self.status = self.status_enum.QUERY_WAR
示例3: query
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def query(self,sql,**kwds):
self.cur.execute("show variables like 'autocommit';")
flag = self.cur.fetchone()
LOG.info(flag)
try:
self.sql = sql % kwds
LOG.info('execute SQL[%s]' % (self.sql))
self.cur.execute(self.sql)
except MySQLdb.Warning,w:
LOG.warn('Warning:%s' % str(w))
self.status = self.status_enum.QUERY_WAR
示例4: post
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def post(self):
for i in range(1):
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':''}
essential_keys = set(['filepath','timestamp','secret'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = 'invalid parameter'
LOG.error('ERROR[in parameter invalid]')
break
filepath = ''.join(self.request.arguments['filepath'])
timestamp = ''.join(self.request.arguments['timestamp'])
secret = ''.join(self.request.arguments['secret'])
if Base.empty(filepath) or Base.empty(timestamp) or Base.empty(secret):
ret['code'] = 1
ret['message'] = 'invalid parameter'
LOG.error('ERROR[parameter empty]')
break
key = filepath + timestamp
secret_key = sha1(key).hexdigest()
if secret == secret_key:
doit = Doit()
doit.transcode(filepath)
LOG.info('QUEUE[put transcode task(%s)}' % filepath)
ret['code'] = 0
ret['message'] = 'success'
break
else:
ret['code'] = 4
ret['message'] = 'secure key error'
LOG.error('ERR[secure key error]')
break
self.write(json.dumps(ret))
LOG.info('PARAMETER OUT[%s]' % ret)
LOG.info('API OUT[%s]' % (self.__class__.__name__))
示例5: _upload_qiniu
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def _upload_qiniu(self,ori_url):
from gl import LOG
LOG.info('Original Image Url [%s]' % ori_url)
if not self.img_url_exp.match(ori_url):
suffix = ori_url[ori_url.rfind('.'):]
qiniu_file_name = md5(ori_url).hexdigest() + suffix
LOG.info('Open Refer Imgage[%s]' % ori_url)
request = urllib2.Request(ori_url)
response = urllib2.urlopen(request)
img_data = response.read()
#LOG.info('img data [%s]' % img_data)
qiniu = QiniuWrap()
res = qiniu.upload_data('qdimg',qiniu_file_name,img_data)
if not res:
qiniu_url = self.qiniu_prefix % ('qdimg',qiniu_file_name)
LOG.info('[%s] local [%s] successful' % (ori_url,qiniu_url))
return qiniu_url
else:
LOG.error('upload qiniu error [%s]' % res)
return None
示例6: post
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def post(self):
for i in range(1):
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':'','uptoken':-9999}
essential_keys = set(['bucket','key','timestamp','secret'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = -5
ret['message'] = 'parameter is wrong'
break
bucket_name = ''.join(self.request.arguments['bucket'])
key = ''.join(self.request.arguments['key'])
timestamp = ''.join(self.request.arguments['timestamp'])
secret = ''.join(self.request.arguments['secret'])
key = bucket_name + key + timestamp
secret_key = sha1(key).hexdigest()
#if secret == secret_key:
qiniu = QiniuWrap()
uptoken = qiniu.get_uptoken(bucket_name,key)
ret['code'] = 0
ret['message'] = 'success'
ret['uptoken'] = uptoken
'''
else:
ret['code'] = -1
ret['message'] = 'secure key error'
'''
LOG.info('PARAMETER OUT[%s]' % ret)
LOG.info('API OUT[%s]' % (self.__class__.__name__))
self.write(json.dumps(ret))
示例7: define
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define,options
from loader import Loader
define('port',default = 8999,help='this is default port',type = int)
if __name__ == "__main__":
Loader.load()
from gl import LOG
from transcode import Transcode
tornado.options.parse_command_line()
application = tornado.web.Application([
(r'/transcode',Transcode),
],)
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
LOG.info('local_api is started,port is [%s]' % options.port)
tornado.ioloop.IOLoop.instance().start()
示例8: post
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def post(self):
for i in range(1):
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':''}
essential_keys = set(['question_id','group_id'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERROR[in parameter invalid]')
break
question_id = ''.join(self.request.arguments['question_id'])
group_id = ''.join(self.request.arguments['group_id'])
if Base.empty(question_id) or Base.empty(group_id):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERROR[parameter empty]')
break
configer = Configer()
remote_host = configer.get_configer('REMOTE','host')
remote_port = configer.get_configer('REMOTE','port')
remote_uri = configer.get_configer('REMOTE','uri')
remote_url = "http://%s:%s/%s" % (remote_host,remote_port,remote_uri)
token = self.get_cookie("teacher_id")
LOG.info('TOKEN[%s]' % token)
if token is None:
ret['code'] = 6
ret['message'] = '無效參數'
LOG.error('ERROR[token empty]')
break
post_data = {'token' : token}
client = httpclient.AsyncHTTPClient()
response = yield gen.Task(client.fetch,remote_url,method = 'POST',body = urllib.urlencode(post_data))
#response = Http.post(remote_url,post_data)
LOG.info('REMOTE RES CODE[%d]' % response.code)
if 200 == response.code:
encode_body = json.loads(response.body)
if 0 == encode_body['code'] or 2 == encode_body['code']:
ret['code'] = 7
ret['message'] = '無效參數'
LOG.error('ERROR[token not exist]')
break
if 1 == encode_body['code']:
subject_id = encode_body['subject_id']
grade_id = encode_body['grade_id']
system_id = encode_body['system_id']
org_type = encode_body['org_type']
db = Mysql()
question_sql = "update entity_question set question_group=%(group_id)d where upload_id=%(system_id)d and id=%(question_id)d;"
try:
db.connect_master()
question_res = db.query(question_sql,question_id = int(question_id),system_id
= int(system_id),group_id=int(group_id))
if not question_res:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[mysql error]')
break
question_sql = db.get_last_sql()
LOG.info('SQL[%s] - RES[%s]' % (question_sql,question_res))
except DBException as e:
db.rollback()
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[mysql error]')
break
else:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[remote error]')
break
else:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[remote error]')
#.........這裏部分代碼省略.........
示例9: get
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def get(self):
for i in range(1):
self.set_header("charset","utf-8");
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':'','group_list' : [],'default_num' : 0}
essential_keys = set(['timestamp','secret'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[in parameter invalid]')
break
timestamp = ''.join(self.request.arguments['timestamp'])
secret = ''.join(self.request.arguments['secret'])
if Base.empty(timestamp):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERROR[parameter empty]')
break
key = timestamp;
secret_key = sha1(key).hexdigest()
if secret == secret_key:
configer = Configer()
remote_host = configer.get_configer('REMOTE','host')
remote_port = configer.get_configer('REMOTE','port')
remote_uri = configer.get_configer('REMOTE','uri')
remote_url = "http://%s:%s/%s" % (remote_host,remote_port,remote_uri)
token = self.get_cookie("teacher_id")
LOG.info('TOKEN[%s]' % token)
if token is None:
ret['code'] = 6
ret['message'] = '無效參數'
LOG.error('ERROR[token empty]')
break
post_data = {'token' : token}
client = httpclient.AsyncHTTPClient()
response = yield gen.Task(client.fetch,remote_url,method = 'POST',body = urllib.urlencode(post_data))
#response = Http.post(remote_url,post_data)
LOG.info('REMOTE RES CODE[%d]' % response.code)
if 200 == response.code:
encode_body = json.loads(response.body)
if 0 == encode_body['code'] or 2 == encode_body['code']:
ret['code'] = 7
ret['message'] = '無效參數'
LOG.error('ERR[token not exist]')
break
if 1 == encode_body['code']:
#subject_id = encode_body['subject_id']
#grade_id = encode_body['grade_id']
system_id = encode_body['system_id']
#org_type = encode_body['org_type']
try:
group_list,default_num = Business.get_group_list(system_id)
if group_list is not False:
ret['group_list'] = group_list
ret['default_num'] = default_num
except DBException as e:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERR[mysql error]')
break
else:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[remote error]')
break
else:
ret['code'] = 3
ret['message'] = '服務器錯誤'
LOG.error('ERROR[remote error]')
break
ret['code'] = 0
ret['message'] = 'success'
break
else:
ret['code'] = 4
ret['message'] = 'secure key error'
LOG.error('ERR[secure key error]')
#.........這裏部分代碼省略.........
示例10: post
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def post(self):
for i in range(1):
self.set_header("Access-Control-Allow-Origin", "*")
LOG.info('API IN[%s]' % (self.__class__.__name__))
LOG.info('PARAMETER IN[%s]' % self.request.arguments)
ret = {'code':'','message':''}
essential_keys = set(['json','html','topic','level','type','group','chapter','ref'])
if Base.check_parameter(set(self.request.arguments.keys()),essential_keys):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[in parameter invalid]')
break
question_json = ''.join(self.request.arguments['json'])
question_html = ''.join(self.request.arguments['html'])
question_topic = ''.join(self.request.arguments['topic'])
question_level = ''.join(self.request.arguments['level'])
question_type = ''.join(self.request.arguments['type'])
question_group = ''.join(self.request.arguments['group'])
question_chapter = ''.join(self.request.arguments['chapter'])
ref = ''.join(self.request.arguments['ref'])
if Business.is_level(question_level) is False:
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[level is invalid]')
break
try:
#question_json = urllib.unquote(question_json)
#question_json = question_json.replace("'","\"")
encode_json = json.loads(question_json,encoding = 'utf-8')
#question_html = urllib.unquote(question_html)
#question_html = question_html.replace("'","\"")
encode_html = json.loads(question_html,encoding = 'utf-8')
LOG.info('Json Loads Successful')
answer_num = 0
if Base.empty(question_topic) and Base.empty(question_chapter):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[topic and chapter empty]')
break
if Base.empty(question_group):
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[group empty]')
break
if Base.empty(question_topic) is False:
topic_list = question_topic.split(',')
for question_theme in topic_list:
if Business.is_topic(question_theme) is False:
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[topic %s invalid]' % question_theme)
break
type_name = Business.is_type(question_type)
if type_name is False:
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[type is invalid]')
break
option_num = 0
LOG.info('Json Parse Start')
if type_name == '選擇題'.decode('utf-8'):
if 'answer' in encode_json.keys():
answer_num = len(encode_json['answer'])
option_num = len(encode_json['options'])
if type_name == '填空題'.decode('utf-8'):
if 'answer' in encode_json.keys():
answer_num = max([int(group['index']) for group in encode_json['answer']])
LOG.info('Json Parse End')
if not Base.empty(question_chapter):
if Business.chapter_id_exist(question_chapter) is False:
ret['code'] = 1
ret['message'] = '無效參數'
LOG.error('ERR[seriess %s invalid]' % question_theme)
break
except (ValueError,KeyError,TypeError):
ret['code'] = 1
ret['message'] = '無效參數'
#.........這裏部分代碼省略.........
示例11: get
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def get(self):
if 'page' not in self.request.arguments.keys():
pid = 0
else:
pid = int(''.join(self.request.arguments['page']))
if 'type' not in self.request.arguments.keys():
filted_type = '1'
else:
filted_type = ''.join(self.request.arguments['type'])
if 'data' not in self.request.arguments.keys():
filted_data = '1'
else:
filted_data = urllib.unquote(''.join(self.request.arguments['data']))
access = {'2' : 'q_type_filter','3' : 'q_subject_filter'}[filted_type]
filted_set = getattr(Business,access)(filted_data,pid,1)
qid = filted_set[0][0]
subject = filted_set[0][1]
username = self.get_secure_cookie('uname')
index_dict = {'username':username,'title' : '新舊題對比展示','subject' : subject}
old_dict = Search._old_question(qid)
combine_dict = dict(index_dict,**old_dict)
num_access = {'2' : 'q_type_filter_num','3' : 'q_subject_filter_num'}[filted_type]
num = getattr(Business,num_access)(filted_data)
mark_list = Business.q_mark_list()
mark_dict = {'mark_list' : mark_list}
combine_dict = dict(combine_dict,**mark_dict)
new_dict = Search._new_question(qid)
front_url = r'href = /page?type=%s&data=%s&page=%d' % (filted_type,filted_data,pid-1)
next_url = r'href = /page?type=%s&data=%s&page=%d' % (filted_type,filted_data,pid+1)
page_dict = {"front_is_able" : "","next_is_able" : "","front" : front_url,"next" : next_url}
#self.set_secure_cookie("pid",str(pid),expires_days = None)
if pid >= num-1:
#self.set_secure_cookie("pid","0")
page_dict["next_is_able"] = "disabled"
page_dict["next"] = ""
if 0 >= pid:
page_dict["front_is_able"] = "disabled"
page_dict["front"] = ""
combine_dict = dict(combine_dict,**page_dict)
combine_dict = dict(combine_dict,**new_dict)
systematics_list = Business.get_systematics(qid)
systematics_dict = {'systematics_list' : systematics_list}
LOG.info('haha%s' % systematics_dict)
combine_dict = dict(combine_dict,**systematics_dict)
self.render("new_old_question_show.html",**combine_dict)
示例12: local_img
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def local_img(self,string):
from gl import LOG
update_flag = False
LOG.info('start local img,question id [%s]' % string)
question_id = int(string)
mongo = Mongo()
mongo.connect('resource')
mongo.select_collection('mongo_question_json')
json = mongo.find_one({'question_id':question_id},{'content':1})
mongo.select_collection('mongo_question_html')
html = str(mongo.find_one({'question_id':question_id},{'content':1}))
#img_expr = parse("content[*].*[*]")
#img_list = [match.value for match in img_expr.find(json) if isinstance(match.value,dict) and\
# 'type' in match.value.keys() and match.value['type'] == 'image']
#pprint.pprint(json)
content = ''
if json:
content = json['content']
for key,wrap in content.items():
for idx,item in enumerate(content[key]):
if isinstance(item,str):
continue
if isinstance(item,dict):
if 'group' in item.keys():
group = item['group']
for index,item1 in enumerate(group):
if isinstance(item1,dict) and 'type' in item1.keys() and item1['type'] == 'image':
ori_url = item1['value']
qiniu_url = self._upload_qiniu(ori_url)
if qiniu_url:
content[key][idx]['group'][index]['value'] = qiniu_url
update_flag = True
html = html.replace(ori_url,qiniu_url)
if 'type' in item.keys() and item['type'] == 'image':
ori_url = item['value']
qiniu_url = self._upload_qiniu(ori_url)
if qiniu_url:
content[key][idx]['value'] = qiniu_url
update_flag = True
html = html.replace(ori_url,qiniu_url)
if isinstance(item,list):
for index,item1 in enumerate(item):
if 'type' in item1.keys() and item1['type'] == 'image':
ori_url = item1['value']
qiniu_url = self._upload_qiniu(ori_url)
if qiniu_url:
content[key][idx][index]['value'] = qiniu_url
update_flag = True
html = html.replace(ori_url,qiniu_url)
if update_flag:
mongo.select_collection('mongo_question_json')
json_effected = mongo.update_many({'question_id':question_id},{'$set':{'content':content}})
mongo.select_collection('mongo_question_html')
html_effected = mongo.update_many({'question_id':question_id},{'$set':{'content':html}})
LOG.info('mongo update successful json[%d] -- html[%d]' % (json_effected,html_effected))
示例13: post
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
def post(self):
for i in range(1):
LOG.info('- %s - API IN' % (self.__class__.__name__))
ret = {'code':'','message':''}
示例14:
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
# *-* coding:utf-8 *-*
from loader import Loader
if __name__ == '__main__':
Loader.load()
from gl import LOG
LOG.info('START[doit start]')
Loader.start()
示例15:
# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import info [as 別名]
application = tornado.web.Application([
(r'/api/upload_question',UploadQuestion),
(r'/api/get_exercises', get_exercises),
(r'/api/update_exercises', update_exercises),
(r'/api/delete_exercises', delete_exercises),
(r'/api/search_keyword', search_keyword),
(r'/api/get_class', get_class),
(r'/api/get_token', get_token),
(r'/api/get_subject', get_subject),
(r'/api/doc_download', doc_download),
(r'/api/get_doc_info', get_doc_info),
(r'/api/create_group',CreateGroup),
(r'/api/get_group_list',GetGroupList),
(r'/api/update_group',UpdateGroup),
(r'/api/delete_group',DeleteGroup),
(r'/api/transfer_group',TransferGroup),
(r'/api/uptoken',UpToken),
(r'/api/transcode',Transcode),
(r'/api/transcode_res',TranscodeRes),
(r'/api/check_ppt', check_ppt),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
LOG.info('idc_api is started,port is [%s]' % options.port)
tornado.ioloop.IOLoop.instance().start()