本文整理匯總了Python中gl.LOG類的典型用法代碼示例。如果您正苦於以下問題:Python LOG類的具體用法?Python LOG怎麽用?Python LOG使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了LOG類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_systematics
def get_systematics(question_id):
mysql = Mysql()
mysql.connect_master()
query_sql = "select D.name as module_name,C.name as unit_name,B.name as topic_name from (select topic_id from link_question_topic where question_id=%(question_id)d)A left outer join (select id,name,unit_id from entity_topic)B on (A.topic_id=B.id) left outer join (select id,name,module_id from entity_unit)C on (B.unit_id=C.id) left outer join (select id,name from entity_module)D on (C.module_id=D.id);"
try:
if mysql.query(query_sql,question_id = int(question_id)):
res = mysql.fetchall()
systematics_list = []
for line in res:
module = line[0]
unit = line[1]
topic = line[2]
systematics_dict = {'module':module,'unit':unit,'topic':topic}
systematics_list.append(systematics_dict)
return systematics_list
else:
return False
except DBException as e:
LOG.error('get systematics error [%s]' % e)
raise CKException('get systematics error')
示例2: connect_master
def connect_master(self):
if self.connect_flag:
self.cur.close()
self.conn.close()
self.connect_flag = False
configer = Configer()
host = configer.get_configer('MYSQL','host')
port = configer.get_configer('MYSQL','port')
user = configer.get_configer('MYSQL','user')
passwd = configer.get_configer('MYSQL','passwd')
db = configer.get_configer('MYSQL','db')
charset = configer.get_configer('MYSQL','charset')
try:
self.conn = MySQLdb.connect(
host = host,
port = int(port),
user = user,
passwd = passwd,
db = db,
charset = charset)
self.cur = self.conn.cursor()
self.connect_flag = True
except MySQLdb.Error,e:
self.status = self.status_enum.CONN_ERR
msg = 'connect failed'
LOG.error('Error:%s' % str(e))
raise DBException(msg)
示例3: q_mark_list
def q_mark_list():
mysql = Mysql()
mysql.connect_master()
query_sql = "select id,name from link_question_mark where enable=1;"
mark_list = []
try:
if mysql.query(query_sql):
mark_tuple = mysql.fetchall()
for mark in mark_tuple:
tmp_tuple = (mark[0],mark[1])
mark_list.append(tmp_tuple)
return mark_list
else:
return None
except DBException as e:
LOG.error('get mark error [%s]' % e)
raise CkException('get mark error')
示例4: q_subject_list
def q_subject_list():
mysql = Mysql()
mysql.connect_master()
query_sql = "select distinct subject from entity_question_new where type is not null;"
subject_list = []
try:
if mysql.query(query_sql):
subject_tuple = mysql.fetchall()
for type in subject_tuple:
tmp_tuple = (type[0])
subject_list.append(tmp_tuple)
return subject_list
else:
return None
except DBException as e:
LOG.error('get subject error [%s]' % e)
raise CkException('get subject error')
示例5: get_group_list
def get_group_list(system_id):
mysql = Mysql()
mysql.connect_master()
query_sql = "select A.id,A.name,B.num from (select id,name from entity_group where system_id=%(system_id)d or id=0)A left outer join (select question_group,count(1) as num from entity_question where upload_id=%(system_id)d group by question_group)B on (A.id=B.question_group);"
try:
if mysql.query(query_sql,system_id = system_id):
res = mysql.fetchall()
group_list = []
for line in res:
group_id = line[0]
group_name = line[1]
question_num = int(line[2]) if line[2] else 0
group_dict = {'id':int(group_id),'name':group_name,'num':int(question_num)}
group_list.append(group_dict)
return group_list
else:
return False
except DBException as e:
LOG.error('check topic error [%s]' % e)
raise CKException('check topic error')
示例6: select_collection
def select_collection(self,collection):
try:
self.collection = self.db[collection]
except ServerSelectionTimeoutError as e:
LOG.error('mongo select failed [%s]' % e)
raise DBException('mongo select failed')
示例7: query
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
示例8: connect
def connect(self,db):
configer = Configer()
mongo_host = configer.get_configer('MONGO','host')
mongo_port = int(configer.get_configer('MONGO','port'))
try:
self.client = MongoClient(host = mongo_host,port = mongo_port)
self.db = self.client[db]
except ConnectionFailure,e:
LOG.error('mongo connect failed [%s]' % e)
raise DBException('mongo connect failed')
示例9: _upload_qiniu
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
示例10: get
def get(self):
enter_func(self)
if not set(['word']).issubset(self.request.arguments.keys()):
return leave_func(self, 1)
if 'page_num' in self.request.arguments.keys() and self.request.arguments['page_num'][0]:
page_num = int(self.request.arguments['page_num'][0])
else:
page_num = 1
if 'page_size' in self.request.arguments.keys() and self.request.arguments['page_size'][0]:
page_size = int(self.request.arguments['page_size'][0])
else:
page_size = 10
keyword = self.request.arguments['word'][0]
if 'uid' in self.request.arguments.keys() and self.request.arguments['uid'][0]:
uid = int(self.request.arguments['uid'][0])
LOG.info('data_statistics: %s' % {'uid': uid, 'keyword': keyword, 'func': self.__class__.__name__})
if not keyword or page_num < 1 or page_size < 1:
return leave_func(self, 1)
url = 'http://wenku.baidu.com/api/interface/search?%s' % urllib.urlencode({ 'word': keyword, 'pn': page_num, 'rn': page_size, 'token': generate_token(), 'host': host })
LOG.info(url)
docs = json.loads(urllib2.urlopen(url).read().decode('raw_unicode_escape'))
LOG.info(docs)
if 0 != docs['status']['code']:
LOG.error(docs['status'])
return leave_func(self, 100)
ret = dict(error_process(0).items() + docs['data'].items())
if 'jsonp' in self.request.arguments.keys():
jsonp = self.request.arguments['jsonp'][0]
leave_func(self, 0)
return self.write('%s(%s)' % (jsonp, json.dumps(ret, ensure_ascii=False)))
leave_func(self, 0)
return self.write(json.dumps(ret, ensure_ascii=False))
示例11: is_seriess
def is_seriess(seriess_id):
mysql = Mysql()
mysql.connect_master()
query_sql = "select 1 from entity_seriess where id = %(seriess_id)d;"
try:
if mysql.query(query_sql,seriess_id = int(seriess_id)):
return True
else:
return False
except DBException as e:
LOG.error('check seriess error [%s]' % e)
raise CkException('check seriess error')
示例12: group_id_exist
def group_id_exist(group_id):
mysql = Mysql()
mysql.connect_master()
query_sql = "select 1 from entity_group where id = '%(group_id)d';"
try:
if mysql.query(query_sql,group_id = int(group_id)):
return True
else:
return False
except DBException as e:
LOG.error('check topic error [%s]' % e)
raise CKException('check topic error')
示例13: chapter_id_exist
def chapter_id_exist(chapter_id):
mysql = Mysql()
mysql.connect_master()
query_sql = "select 1 from entity_teaching_chapter where id='%(chapter_id)d';"
try:
if mysql.query(query_sql,chapter_id = int(chapter_id)):
return True
else:
return False
except DBException as e:
LOG.error('check chapter error [%s]' % e)
raise CKException('check chapter error')
示例14: update_json_by_id
def update_json_by_id(oldid,json):
mysql = Mysql()
mysql.connect_master()
query_sql = "update entity_question_new set json='%(question_json)s' where oldid=%(oldid)d;"
try:
if mysql.query(query_sql,oldid = int(oldid),question_json = json):
return True
else:
return False
except DBException as e:
LOG.error('update json error [%s]' % e)
raise CkException('update json error')
示例15: subprocess
def subprocess(self, cmd, callback):
ioloop = tornado.ioloop.IOLoop.instance()
args = shlex.split(cmd)
LOG.debug(args)
pipe = subprocess.Popen(args, stdout = subprocess.PIPE, close_fds = True)
fd = pipe.stdout.fileno()
result = []
def recv(*args):
data = pipe.stdout.readline()
if data:
result.append(data)
elif pipe.poll() is not None:
ioloop.remove_handler(fd)
callback(''.join(result))
ioloop.add_handler(fd, recv, ioloop.READ)