• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tracelog.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tracelog.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _frame_to_msg

    def _frame_to_msg(self, frame):
        """
        Method: _frame_to_msg
        Description: 将frame装换为AcpMessage消息
        Parameter: 
            frame: AppFrame
        Return: 待接受消息端的url和AcpMessage消息
        Others: 
        """

        # AppFrame转换为CallAcpMsg
        try:
            msg_id = self._struct.unpack_from(frame.get_custom_bytes())[0]
        except:
            tracelog.exception("SimpleCallAcpSrv._frame_to_msg() failed. "
                                "frame.get_custom_bytes():%s" % (
                                    repr(frame.get_custom_bytes())))
            return None, None

        url = frame.get_custom_bytes()[self._struct.size:]
        if len(url) == 0:
            tracelog.error("SimpleCallAcpSrv._frame_to_msg() failed. "
                            "url is null")
            return None, None
            
        msg = pycallacp.AcpMessage(frame.get_cmd_code(), frame.get_data())
        msg.set_msg_id(msg_id)
                
        return url, msg
开发者ID:allenforrest,项目名称:wxbiz,代码行数:29,代码来源:basic_app.py


示例2: handle_cmd

    def handle_cmd(self, frame):
        """
        Method: handle_cmd
        Description: 注销请求处理函数,调用name_mit_manager的相应函数进行处理,然后更新本地缓存,再广播到其他APP。
        Parameter: 
            frame: 注销请求消息,数据区为AppUnRegisterRequest
        Return: 
        Others: 
        """

        buf = frame.get_data()
        result = bf.AppUnRegisterResponse()
        result.init_all_attr()
        app = self.get_worker().get_app()
        try:
            un_reg_req = bf.AppUnRegisterRequest.deserialize(buf)
            tracelog.info("unregist name service:%r" % un_reg_req)
        except Exception:            
            result.return_code = err_code_mgr.ER_INVALID_DESERIALIZE_STRING_ERROR
            result.description = err_code_mgr.get_error_msg(err_code_mgr.ER_INVALID_DESERIALIZE_STRING_ERROR
                                                            , cmd='UnRegisterApp'
                                                            , param_name='AppUnRegisterRequest')            
            app.send_ack(frame, result.serialize())
            tracelog.error('%s\n%s'%(result.description, buf))
            return
            
        result = self.get_worker().unregister_app(un_reg_req)        

        if un_reg_req.need_reponse is True:
            app.send_ack(frame, result.serialize())
        
        return
开发者ID:allenforrest,项目名称:wxbiz,代码行数:32,代码来源:name_manage_worker.py


示例3: maintain_log_find

def maintain_log_find(log_path,start_time,end_time):
    """
    Function: maintain_log_find
    Description: 查找日志目录下的符合要求的日志文件,并且分类为转储日志和当前日志
    Parameter: 
        log_path: 日志文件路径
        start_time: 起始时间
        end_time: 截至时间
    Return: current_file,dumpfile (当前文件列表,转储文件列表)
    Others: 无
    """

    current_file = []
    dumpfile_map = {}
    dumpmatch = r'\w+_\d+_(\d{4}_(\d{2}_){4}\d{2})\.(log|zip)$'
    for f in os.listdir(log_path):
        dumptemp = re.match(dumpmatch,f)
        if dumptemp is not None:
            try:
                filetime = time.strptime(dumptemp.group(1), '%Y_%m_%d_%H_%M_%S')
                filetime = time.mktime(filetime)
                dumpfile_map[f] = filetime
            except Exception, err:
                tracelog.error('find unknow log: (%s)and exception %s'% (dumptemp.group(1),err))
        else:
            current_file.append(f)
开发者ID:allenforrest,项目名称:wxbiz,代码行数:26,代码来源:maintain_log_zip.py


示例4: register_handler

    def register_handler(self, handler, *args):
        """
        Method:    register_handler
        Description: 注册模板handler
        Parameter: 
            handler: handler对象
            *args: 该handler处理的命令码
        Return: 
        Others: 
            命令码可以是int类型的数值,表示单个命令码
            也可以是两个int组成的元组,表示一个范围内的命令码(闭区间)
            
            例如: 
                register_handler(handler, (100, 200))
                register_handler(handler, 100) 
                register_handler(handler, 100, 103, ...)
        """

        if len(args) == 0:
            tracelog.error("no cmd range for handler %s" % handler)
            return

        for cmd_code_range in args:
            if isinstance(cmd_code_range, int):
                self.__template_cmd_handlers[cmd_code_range] = handler

            else:
                code1, code2 = cmd_code_range
                if code1 <= code2:
                    for cmd_code in xrange(code1, code2 + 1):
                        self.__template_cmd_handlers[cmd_code] = handler
                else:
                    for cmd_code in xrange(code2, code1+ 1):
                        self.__template_cmd_handlers[cmd_code] = handler
开发者ID:allenforrest,项目名称:wxbiz,代码行数:34,代码来源:cmd_worker.py


示例5: run_case

    def run_case(self, app, case):
        """
        Method:    run_case
        Description: 运行一个用例
        Parameter: 
            case: 一个用例, instance of ALECase
        Return: 
            0: 成功
            非0: 失败
        Others: 
        """

        tracelog.info("run case %s..." % str(case))

        ret = self.find_case_entity(case)    
        if ret != 0:
            return -1

        case.case_entity

        frame = bf.AppFrame()
        frame.set_cmd_code(case.case_entity.get_cmd_code())
        frame.add_data(case.case_entity.gen_request())
        frame.set_receiver_pid(app.get_pid("AleGate"))

        ack_frames = bf.rpc_request(frame, case.case_entity.get_timeout())
        if len(ack_frames) == 0:
            tracelog.error("wait for response timeout. case:%s" % str(case)) 
        else:
            case.case_entity.handle_ack(ack_frames[0].get_data())
        
        return 0
开发者ID:allenforrest,项目名称:wxbiz,代码行数:32,代码来源:send_ale_cmd_app.py


示例6: __unbind_virtual_ip

    def __unbind_virtual_ip(self, write_log):
        """
        Method: __unbind_virtual_ip
        Description: 解除绑定的虚拟ip
        Parameter: 
            write_log: 解除绑定虚拟ip失败时,是否需要记录日志
        Return: 错误码
        Others: 
        """

        if self.__cluster_cfg_info.virtual_cluster_ip == "":
            return

        ret, msg = unbind_virtual_ip(self.__cluster_cfg_info.virtual_cluster_ip
                                , self.__cluster_cfg_info.virtual_cluster_mask
                                , self.__cluster_cfg_info.external_NIC)
                                
        if ret != 0 and write_log:
            tracelog.error("unbind_virtual_ip(%s/%s on %s) failed:%d, %s" % (
                            self.__cluster_cfg_info.virtual_cluster_ip
                            , self.__cluster_cfg_info.virtual_cluster_mask
                            , self.__cluster_cfg_info.external_NIC
                            , ret
                            , msg))
            
        return ret
开发者ID:allenforrest,项目名称:wxbiz,代码行数:26,代码来源:cluster_thread.py


示例7: __switch_to_slave

    def __switch_to_slave(self):
        """
        Method: __switch_to_slave
        Description: 将角色切换到slave
        Parameter: 无
        Return: 
        Others: 
        """

        # 切换到slave

        old_role = self.__role
        old_state = self.__state
        
        self.__role = CLUSTER_ROLE_SLAVE
        self.__state = CLUSTER_STATE_NORMAL
        tracelog.info("the current cluster node %s switch to slave. state:%d" % (
                            self.__cluster_cfg_info.my_inner_ip
                           , state))

        ret_code  = self.__unbind_virtual_ip(True)
        if ret_code != 0:
            tracelog.error("unbind virtual ip faild. ret_code:%d" % ret_code)
            
        self.__cluster_node.on_state_change(old_role, old_state, self.__role, state)
开发者ID:allenforrest,项目名称:wxbiz,代码行数:25,代码来源:cluster_thread.py


示例8: load

    def load(self, cfg_file_path):
        """
        Method: load
        Description: 从指定的配置文件中加载设备配置信息
        Parameter: 
            cfg_file_path: 配置文件的路径
        Return: 错误码
        Others: 
        """

        ret = 0
        
        try:
            xmldoc = ET.parse(cfg_file_path)
            xmlroot = xmldoc.getroot()
            
            ret = self.__load_device_info(xmlroot)

            if ret == 0:
                ret = self.__load_cluster_info(xmlroot)

            if ret != 0:
                tracelog.error("load device configuration failed. cfg_file_path:%s" % cfg_file_path)
                
        except:
            tracelog.exception("load device configuration failed. cfg_file_path:%s" % cfg_file_path)
            return -1

        return ret
开发者ID:allenforrest,项目名称:wxbiz,代码行数:29,代码来源:device_cfg_info.py


示例9: reset_NE_state

    def reset_NE_state(self):
        """
        Method: reset_NE_state
        Description: 重置网元的状态
        Parameter: 无
        Return: 错误码
        Others: 将全同步未结束的,都设置为需要全同步。本接口在进程启动初始化时调用
        """

        # mit启动时,将那些之前状态为非normal的,设置为normal,
        # 并且是否需要同步设置为1
        multisql = mit.MultiSQL()
        multisql.set_oracle_sql(('update tbl_NEDbSyncState '
                                'set "need_sync_full"=1, "sync_state"=%d '
                                'where "sync_state"<>%d') % (
                                   db_sync_update_const.NE_STATE_NORMAL
                                 , db_sync_update_const.NE_STATE_NORMAL))
        multisql.set_sqlite_sql(('update tbl_NEDbSyncState '
                                'set [need_sync_full]=1, [sync_state]=%d '
                                'where [sync_state]<>%d') % (
                                   db_sync_update_const.NE_STATE_NORMAL
                                 , db_sync_update_const.NE_STATE_NORMAL))
                 
        ret = self.raw_exec_ex("NEDbSyncState", multisql)

        if ret.get_err_code() != 0:
            tracelog.error("update tbl_NEDbSyncState failed. %d, %s" % (
                            ret.get_err_code()
                          , ret.get_msg()))
            return ret.get_err_code() 

        return 0
        
开发者ID:allenforrest,项目名称:wxbiz,代码行数:32,代码来源:db_sync_mit.py


示例10: __load_device_info

    def __load_device_info(self, xmlroot):
        """
        Method: __load_device_info
        Description: 从配置文件中加载设备信息
        Parameter: 
            xmlroot: xml解析后的ET结构
        Return: 错误码
        Others: 
        """

        
        dev_ele = xmlroot.find("device")
        if dev_ele is None:
            tracelog.error("'device' element not found!")
            return -1

        dev_id = dev_ele.get("id", "").strip().encode("utf-8")
        if dev_id == "":
            tracelog.error("'device.id' is not configured!")
            return -1
            
        self.__device_id = dev_id
        
        nic = dev_ele.get("external_NIC", "").strip()
        self.__device_external_NIC = nic.encode("utf-8")

        nic= dev_ele.get("internal_NIC", "").strip()
        #if nic == "":
        #    tracelog.error("'device.internal_NIC' is not configured!")
        #    return -1

        self.__device_internal_NIC = nic.encode("utf-8")

        return  self.init_ip_from_os()
开发者ID:allenforrest,项目名称:wxbiz,代码行数:34,代码来源:device_cfg_info.py


示例11: __load_cluster_info

    def __load_cluster_info(self, xmlroot):
        """
        Method: __load_cluster_info
        Description: 从XML结构中,解析得到设备的信息
        Parameter: 
            xmlroot: ET结构,xml的根节点
        Return: 
        Others: 
        """

        cluster_ele = xmlroot.find("cluster")
        if cluster_ele is None:
            tracelog.error("'cluster' element not found!")
            return -1
        
        enable = cluster_ele.get("enable", "").strip()
        if enable == "":
            tracelog.error("'cluster.enable' is not configured!")
            return -1
        
        self.__cluster_enable = int(enable)
        
        self.__cluster_virtual_ip = cluster_ele.get("virtual_ip", "").strip()
        self.__cluster_virtual_mask = cluster_ele.get("virtual_mask", "").strip()
        self.__cluster_max_nodes_num = int(cluster_ele.get("max_nodes_num", "0").strip())
        

        return 0
开发者ID:allenforrest,项目名称:wxbiz,代码行数:28,代码来源:device_cfg_info.py


示例12: del_iptables_rule

    def del_iptables_rule(self,rule):       
        """
        Method: del_iptables_rule
        Description: 删除防火墙设置的原子操作
        Parameter: 
            rule: 防火墙规则,是个三元组,格式如下("网卡名称","tcp或udp","端口号")
        Return: 0代表成功,1代表失败
        Others: 无
        """

        #删除
        return_code = os_execute("iptables -D INPUT -i %s -p %s --dport %s -j ACCEPT" %(
                                rule[0],rule[2],rule[1]))
        
        if return_code !=0:
            tracelog.error('Fail to del iptables rule')
            return 1
        else:
            tracelog.info('iptables rule deleted and info is %s card %s port %s treaty'%(
                            rule[0],rule[2],rule[1]))
        
        
        return_code = os_execute("service iptables save")
        if return_code !=0:
            tracelog.error('Fail to save iptables rule')
            return 1
        else:
            tracelog.info('Success to save iptables')
            
        return 0
开发者ID:allenforrest,项目名称:wxbiz,代码行数:30,代码来源:iptables.py


示例13: __call_oracle_imp

    def __call_oracle_imp(self):
        """
        Method: __call_oracle_imp
        Description: 调用oracle的impdp命令
        Parameter: 无
        Return: 错误码
        Others: 
        """


        mocs = self.get_worker().get_app().get_synchronized_mocs()
        tables = ["tbl_"+moc.get_moc_name() for moc in mocs.itervalues()]
        timeout = len(tables)*300 + 300 # 秒
              
        db_file_dir = os.path.join(self.get_worker().get_app().get_app_top_path()
                                , db_sync_common_const.DB_SYNC_DIR
                                )
                                
        ret = call_oracle_cmd.call_impdp(tables
                                            , db_file_dir
                                            , timeout)
        if ret != 0:
            tracelog.error("call_impdp failed. ret:%d" % ret)
            return -1
        
        return 0
开发者ID:allenforrest,项目名称:wxbiz,代码行数:26,代码来源:sync_full_imp_handler.py


示例14: start_listen

    def start_listen(self):
        """
        Method: start_listen
        Description: 开始监听
        Parameter: 无
        Return:错误码
        Others: 
        """

        if self._ssl_option is None:
            ret = self.bind("", self._port)
        else:
            ret = self.bind_with_ssl(""
                                , self._port
                                , self._ssl_option.get("key_file", "")
                                , self._ssl_option["cert_file"]
                                , self._ssl_option["proto_version"])

        if ret == 0:
            tracelog.info("SimpleCallAcpSrv start listen on port %d, ssl_option:%s"%(
                            self._port
                            , self._ssl_option))
        else:
            tracelog.error("SimpleCallAcpSrv listen on port %d failed, ssl_option:%s"%(
                            self._port
                            , self._ssl_option))

        return ret
开发者ID:allenforrest,项目名称:wxbiz,代码行数:28,代码来源:basic_app.py


示例15: __add_node

    def __add_node(self, node_ip, is_enable):
        """
        Method: __add_node
        Description: 增加节点
        Parameter: 
            node_ip: 节点的ip
            is_enable: 是否启用了
        Return: 错误码
        Others: 
        """

        ret = 0
        
        if node_ip == self.__cluster_cfg_info.my_inner_ip:
            return ret

        for node in self.__other_nodes:
            if node.get_ip() == node_ip:
                break
        else:
            node_info = ClusterNodeInfo(node_ip)                
            if is_enable == 0:                    
                node_info.set_enable(False)

            self.__other_nodes.append(node_info)
            url = self.__get_url(node_ip)
            ret = self.__callacp_client.new_connect(url)
            if ret != 0:
                tracelog.error("new connection to cluster node failed. %s" % url)
                
        return ret
开发者ID:allenforrest,项目名称:wxbiz,代码行数:31,代码来源:cluster_thread.py


示例16: handle_cmd

    def handle_cmd(self, frame):
        """
        Method:    handle_cmd
        Description: 处理消息
        Parameter: 
            frame: AppFrame
        Return: 无
        Others: 
        """
        
        para = cluster_msg_def.RmvClusterNodeRequest.deserialize(frame.get_data())

        if para is None:
            tracelog.error("invalid request! frame:%s" %(frame))
            return

        
        rep = cluster_msg_def.RmvClusterNodeResponse()        
        cur_cluster = self.get_worker().get_cur_cluster()
        if cur_cluster is None:
            rep.return_code = err_code_mgr.ER_CLUSTER_IS_DISABLE
            rep.description = err_code_mgr.get_error_msg(err_code_mgr.ER_CLUSTER_IS_DISABLE)
        else:
            rep.return_code, rep.description = cur_cluster.rmv_node(para.ip)

        # 发送应答
        self.get_worker().send_ack(frame,rep.serialize())
开发者ID:allenforrest,项目名称:wxbiz,代码行数:27,代码来源:cluster_cfg_worker.py


示例17: on_msg_received

    def on_msg_received(self, url_or_srv_name, msg):
        """
        Method: on_msg_received
        Description: "收到消息"的处理接口
        Parameter: 
            url_or_srv_name: 消息发送者的url
            msg: 消息
        Return: 
        Others: 
        """

        #print "on_msg_received", msg.get_cmd_code()
        
        cmd_code = msg.get_cmd_code()        
        if (cmd_code != cluster_cmd_code.CMD_CLUSTER_QUERY_STATE
           and cmd_code != cluster_cmd_code.CMD_CLUSTER_ACK_STATE):
           tracelog.error("ClusterServerEventHandler receved invalid msg:%d" % cmd_code)
           return
            
        try:
            state_msg = ClusterStateMsg.deserialize(msg.get_data())
            if state_msg is None:
                tracelog.error("ClusterStateMsg.deserialize failed. "
                                "msg:%d, %r" % (cmd_code, msg.get_data()))
                return
                
            if cmd_code == cluster_cmd_code.CMD_CLUSTER_QUERY_STATE:                
                self.__cluster_thread.on_query_state(url_or_srv_name, state_msg)
                
            elif cmd_code == cluster_cmd_code.CMD_CLUSTER_ACK_STATE:
                self.__cluster_thread.on_ack_state(state_msg)            
                
        except:
            tracelog.exception("handler msg(%d) failed" % cmd_code)
开发者ID:allenforrest,项目名称:wxbiz,代码行数:34,代码来源:cluster_thread.py


示例18: handle_cmd

    def handle_cmd(self, frame):
        """
        Method: handle_cmd
        Description: 请求处理函数,如果EventQueryRequest对象反序列化成功,进行必要的参数检查,
                                然后调用事件查询处理器,查询事件记录数,和指定分页的记录,返回给查询者。
        Parameter: 
            frame: 请求消息,data中为EventQueryRequest对象
        Return: 无
        Others: 
        """

        buf = frame.get_data()
        tracelog.info('EventQueryHandler data %s'%buf)
        result = message_across_app.EventQueryResponse()
        result.init_all_attr()
        result.count = 0
        result.event_query_result = []
            
        try:
            req = message_across_app.EventQueryRequest.deserialize(buf)
        except Exception, err:
            tracelog.error('EventQueryHandler deserialize exception: %s'%err)
            result.user_session = ''            
            result.return_code = err_code_mgr.ER_INVALID_DESERIALIZE_STRING_ERROR
            result.description = err_code_mgr.get_error_msg(err_code_mgr.ER_INVALID_DESERIALIZE_STRING_ERROR
                                                            , cmd='EventQuery'
                                                            , param_name='EventQueryRequest')
            result.count = 0
            result.event_query_result = []
            self.send_ack(frame, (result.serialize(), ))            
            return
开发者ID:allenforrest,项目名称:wxbiz,代码行数:31,代码来源:event_operation_worker.py


示例19: __switch_to_master

    def __switch_to_master(self, state):
        """
        Method: __switch_to_master
        Description: 将角色切换到master
        Parameter: 
            state: 状态
        Return: 
        Others: 
        """

        # 切换到master

        old_role = self.__role
        old_state = self.__state
        self.__mater_node_info.update(self.__cluster_cfg_info.my_inner_ip, self.__start_time)
        
        self.__role = CLUSTER_ROLE_MASTER
        self.__state = state
        tracelog.info("the current cluster node %s switch to master. state:%d" % (
                          self.__cluster_cfg_info.my_inner_ip
                        , state))

        ret_code  = self.__bind_virtual_ip(True)
        if ret_code != 0:
            tracelog.error("bind virtual ip faild. ret_code:%d" % ret_code)

        self.__cluster_node.on_state_change(old_role, old_state, self.__role, state)

        # 进入master状态后,重新设置其他节点的状态
        self.__reset_query_counter(True)
开发者ID:allenforrest,项目名称:wxbiz,代码行数:30,代码来源:cluster_thread.py


示例20: __handle_full_sync_ntf

 def __handle_full_sync_ntf(self, frame, ne_id, sync_object, event):
     """
     Method: __handle_full_sync_ntf
     Description: 处理全同步事件通知
     Parameter:
         frame: 数据帧
         ne_id: 网元的ID
         sync_object: 同步传输对象
         event: 事件通知
     Return: 
     Others: 
     """
     
     tracelog.info('receive full sync notification from NE(%d)' % ne_id)
     
     error_code = NEInfoMgr.set_ne_need_sync_full(ne_id
                 , self.get_worker().get_app().get_mit_manager()
                 , True)
                 
     if error_code != 0:
         tracelog.error("set_ne_need_sync_full() failed: %d" % error_code)
         # 不给EAU回应答;EAU收到收不到应答后,下次重试
         return
         
     result = DBSyncResult()
     result.id = sync_object.id
     result.return_code = error_code
     result.error_message = ''
     result.event_ids = []
     self.__send_ack(frame, result.serialize())
开发者ID:allenforrest,项目名称:wxbiz,代码行数:30,代码来源:db_sync_update_worker.py



注:本文中的tracelog.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tracelog.info函数代码示例发布时间:2022-05-27
下一篇:
Python traceback.walk_tb函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap