本文整理汇总了Python中tracelog.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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
示例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
示例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()
示例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
示例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
示例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
示例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
示例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