當前位置: 首頁>>代碼示例>>Python>>正文


Python LOG.debug方法代碼示例

本文整理匯總了Python中gl.LOG.debug方法的典型用法代碼示例。如果您正苦於以下問題:Python LOG.debug方法的具體用法?Python LOG.debug怎麽用?Python LOG.debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gl.LOG的用法示例。


在下文中一共展示了LOG.debug方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: subprocess

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
    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)
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:19,代碼來源:question.py

示例2: get

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
    def get(self):
        enter_func(self)
        if not set(['url']).issubset(self.request.arguments.keys()):
            _leave_func(self, 1, {})
            return
        url = urllib.quote(urllib.quote(self.request.arguments['url'][0]))
        cmds = []
        cmds.append(self.gen_cmd(url, 'ChromelessView&Embed=1', '6', '2'))
        cmds.append(self.gen_cmd(url, 'SlideShowView', '1', '0'))
        cmds.append(self.gen_cmd(url, 'ReadingView', '0', '0'))
        cmds.append(self.gen_cmd(url, 'ReadingView', '0', '4'))

        for cmd in cmds:
            LOG.info(cmd)
            stdoutput = yield gen.Task(self.subprocess, cmd)
            LOG.debug(stdoutput)
            if json.loads(stdoutput)['Error']:
                _leave_func(self, 2, {})
                return
        _leave_func(self, 0, {})
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:22,代碼來源:question.py

示例3: _leave_func

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
def _leave_func(self, code, msg):
    LOG.debug('%s(%s) %s ...' % (self.__class__.__name__, json.dumps(self.request.arguments, ensure_ascii=False), error_process(code)))
    self.finish(dict(error_process(code).items() + msg.items()))
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:5,代碼來源:question.py

示例4: leave_func

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
def leave_func(self, code):
    if 0 == code:
        LOG.debug('%s(%s) ...' % (self.__class__.__name__, json.dumps(self.request.arguments, ensure_ascii=False)))
    else:
        LOG.debug('%s(%s) %s' % (self.__class__.__name__, json.dumps(self.request.arguments, ensure_ascii=False), error_process(code)))
        self.write(error_process(code))
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:8,代碼來源:question.py

示例5: enter_func

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
def enter_func(self):
    LOG.debug('%s(%s) ...' % (self.__class__.__name__, json.dumps(self.request.arguments, ensure_ascii=False)))
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:4,代碼來源:question.py

示例6: post

# 需要導入模塊: from gl import LOG [as 別名]
# 或者: from gl.LOG import debug [as 別名]
    def post(self):

        self.set_header("Access-Control-Allow-Origin", "*")

        enter_func(self)

        if not set(['id', 'json', 'html', 'topic', 'level', 'type', 'group', 'chapter']).issubset(self.request.arguments.keys()):
            return leave_func(self, 1)

        theme         = self.request.arguments['topic'][0]
        type_id       = self.request.arguments['type'][0]
        level_id      = self.request.arguments['level'][0]
        group_id      = self.request.arguments['group'][0]
        chapter_id    = self.request.arguments['chapter'][0]
        question_id   = self.request.arguments['id'][0]
        question_json = self.request.arguments['json'][0]
        question_html = self.request.arguments['html'][0]

        try:
            if not (type_id.isdigit() and int(type_id) and level_id.isdigit() and int(level_id) and group_id.isdigit() and question_id.isdigit() and int(question_id) and theme + chapter_id and question_json and question_html):
                return leave_func(self, 1)
            if chapter_id and not chapter_id.isdigit():
                return leave_func(self, 1)

            if Business.is_level(level_id) is False:
                LOG.error('invalid level_id[%s]' % level_id)
                return leave_func(self, 1)

            try:
                #question_json = urllib.unquote(question_json)
                encode_json = {}
                encode_json['content'] = json.loads(question_json, encoding = 'utf-8')
                #question_html = urllib.unquote(question_html)
                encode_html = {}
                encode_html['content'] = json.loads(question_html, encoding = 'utf-8')
            except:
                traceback.print_exc()
                LOG.error(sys.exc_info())
                return leave_func(self, 100)

            sql_list = []
            if chapter_id:
                sql_list.append('INSERT INTO link_question_chapter(question_id, chapter_id) VALUE(%s, %s) ON DUPLICATE KEY UPDATE chapter_id = %s' % (question_id, chapter_id, chapter_id)) # 生成更新章節關聯信息的SQL

            if theme: # 主題
                sql_list.append('DELETE FROM link_question_topic WHERE question_id = %s' % question_id) # 生成刪除原有主題關聯的SQL
                for theme_id in theme.split(','): # 將傳入的主題號按逗號切割
                    if Business.is_topic(theme_id) is False: # 判斷主題號是否存在
                        LOG.error('invalid theme_id[%s]' % theme_id)
                        return leave_func(self, 1)
                    sql_list.append('INSERT INTO link_question_topic (question_id, topic_id) VALUES (%s, %s)' % (question_id, theme_id)) # 生成將新主題關聯插庫的SQL

            question_type = Business.is_type(type_id)
            if question_type is False: # 判斷題目類型是否存在
                LOG.error('invalid type_id[%s]' % type_id)
                return leave_func(self, 1)

            answer_num = 0
            if 'answer' in encode_json['content'].keys():
                if type_id == '1':
                    answer_num = len(encode_json['content']['answer'])
                elif type_id == '2':
                    answer_num = len([int(answer_group['index']) for answer_group in encode_json['content']['answer']])

            sql_list.append('UPDATE entity_question SET difficulty = %s, update_time = now(), question_type = "%s", question_group = %s, answer_num = %s WHERE id = %s' % (level_id, question_type, group_id, answer_num, question_id)) # 生成更新題目屬性的SQL

            mysql_handle = Mysql().get_handle()
            mysql_cursor = mysql_handle.cursor(MySQLdb.cursors.DictCursor)
            mysql_cursor.execute('SELECT question_docx, html FROM entity_question WHERE id = %s' % question_id) # 通過題目ID查詢存儲的json/html文件名
            result = mysql_cursor.fetchall()
            if not result:
                LOG.error('invalid question_id[%s]' % question_id)
                return leave_func(self, 1)

            qiniu = QiniuWrap()
            mongo = Mongo()
            mongo.connect('resource')

            if result[0]['question_docx'] and '.json' in result[0]['question_docx']:
                json_name = result[0]['question_docx']
                # 將七牛上的json文件刪除後重新上傳
                qiniu.bucket.delete("temp", json_name)
                qiniu.upload_data("temp", json_name, question_json)
                # 將MongoDB中的json文件刪除後重新上傳
                mongo.select_collection('mongo_question_json')
                LOG.debug('resource.mongo_question_json.remove( { question_id: %s } )' % question_id)
                mongo.remove( { "question_id" : int(question_id) } )
                encode_json['question_id'] = int(question_id)
                LOG.debug('resource.mongo_question_json.insert_one( %s )' % encode_json)
                mongo.insert_one(encode_json)

            if result[0]['html'] and '.html' in result[0]['html']:
                html_name = result[0]['html']
                # 將七牛上的html文件刪除後重新上傳
                qiniu.bucket.delete("temp", html_name)
                qiniu.upload_data("temp", html_name, question_html)
                # 將MongoDB中的html文件刪除後重新上傳
                mongo.select_collection('mongo_question_html')
                LOG.debug('resource.mongo_question_html.remove( { question_id: %s } )' % question_id)
                mongo.remove( { "question_id" : int(question_id) } )
#.........這裏部分代碼省略.........
開發者ID:XDF-server,項目名稱:api_resource,代碼行數:103,代碼來源:question.py


注:本文中的gl.LOG.debug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。