29
来源:互联网 发布:易赛充值软件 编辑:程序博客网 时间:2024/05/01 09:28
iResult,list_simu_ip = self.GetSimuDevIPList(p_str_topo_name);
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('GetSimuDevIPList failed',Com_imc_oper_manager);
return iResult,{};
simu_db_tool = db_tools();
simu_db_tool.SetDBInfo(param_tool.GetInstance().param_db_simulation.m_str_db_ip,param_tool.GetInstance().param_db_simulation.m_str_db_user,param_tool.GetInstance().param_db_simulation.m_str_db_pw);
iResult = simu_db_tool.OpenDBCon('config_db');
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('fail to open simu db',Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return iResult,{};
dict_id_ip = {};
for elem in list_simu_ip:
int_dev_id = -1;
iResult,int_dev_id = simu_db_tool.GetDevIDByDevIP(elem);
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('GetDevIDByDevIP failed,ip:' + elem,Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return iResult,{};
dict_id_ip[int_dev_id] = elem;
if ( 0 == len(dict_id_ip)):
log_manager.GetInstance().CoutLog('dict id ip get is empty:' + elem,Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return oErrorBase.base_failed,{};
simu_db_tool.CloseDBCon();
log_manager.GetInstance().CoutLog('end to exec GetSimuIDIPDict',Com_imc_oper_manager);
return oErrorBase.base_succeed,dict_id_ip;
**********************************
文件名:inter_match_manager.py
**********************************
import os;
import re;
from data_struct_manager import *;
from error_manager import *;
from log_manager import *;
class inter_match_manager:
__instance = None;
__dict_inter_match = {};
def __init__(self):
pass;
@staticmethod
def GetInstance():
if (None == inter_match_manager.__instance):
inter_match_manager.__instance = inter_match_manager();
return inter_match_manager.__instance;
def GetInterMatchFileDictByIP(self,p_str_ip):
log_manager.GetInstance().CoutLog('begin to exec GetInterMatchFileDictByIP',Com_inter_match_manager);
self.__dict_inter_match = {};
dir_inter_match = dir.inter_match_file_dir;
file_names = os.listdir(dir.inter_match_file_dir);
for file_name in file_names:
pa_ip = p_str_ip;
if (file_name == ('match_' + pa_ip + '.cfg')):
str_ip = p_str_ip;
file_inter_match = None;
try:
file_inter_match = open(dir_inter_match + file_name);
except Exception, e:
log_manager.GetInstance().CoutLog('open file failed,file name:' + dir_inter_match + file_name,Com_inter_match_manager);
return oErrorBase.base_failed;
for line in file_inter_match:
pa_src_inter = re.compile('.*?,');
ma_src_inter = pa_src_inter.search(line);
if ma_src_inter:
src_inter = ma_src_inter.group();
src_inter = src_inter.replace(',','');
pa_des_inter = re.compile(',.*?,');
ma_des_inter = pa_des_inter.search(line);
if ma_des_inter:
des_inter = ma_des_inter.group();
des_inter = des_inter.replace(',','');
self.__dict_inter_match[src_inter] = des_inter;
file_inter_match.close();
log_manager.GetInstance().CoutLog('end to exec GetInterMatchFileDictByIP',Com_inter_match_manager);
return oErrorBase.base_succeed;
def GetDIBySIFromDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec GetDIBySIFromDic',Com_inter_match_manager);
if (0 == len(self.__dict_inter_match)):
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
return oErrorBase.base_failed,'';
for key in self.__dict_inter_match:
if (p_str_si.find(key+ '(E1)') != -1 or p_str_si == key):
log_manager.GetInstance().CoutLog('end to exec GetDIBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,self.__dict_inter_match[key];
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
log_manager.GetInstance().CoutLog('end to exec GetDIBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,'';
def IsDesInterInIDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec IsDesInterInIDic',Com_inter_match_manager);
for key in self.__dict_inter_match:
if (self.__dict_inter_match[key] == p_str_si):
log_manager.GetInstance().CoutLog('end to exec IsDesInterInIDic',Com_inter_match_manager);
return True;
log_manager.GetInstance().CoutLog('end to exec IsDesInterInIDic',Com_inter_match_manager);
return False;
def GetRealIfDescBySIFromDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
for key in self.__dict_inter_match:
if (p_str_si == self.__dict_inter_match[key]):
log_manager.GetInstance().CoutLog('end to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,key;
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
log_manager.GetInstance().CoutLog('end to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_failed,'';
**********************************
文件名:link_manager.py
**********************************
# -*- coding: utf8 -*-
from inter_match_manager import *;
from log_manager import *;
import os;
import re;
from decimal import *
import sys;
default_encoding = 'utf-8';
if sys.getdefaultencoding() != default_encoding:
stdout = sys.stdout;
stdin = sys.stdin;
reload(sys);
sys.stdout = stdout;
sys.stdin = stdin;
sys.setdefaultencoding(default_encoding);
import pymssql;
from m_port_manager import *;
from error_manager import *;
from data_struct_manager import *;
class link_manager:
__instance = None;
__db_ip = '';
__db_user = '';
__db_pw = '';
__list_ip = [];
__dict_link = {};
__str_dev_ip = '';
__new__dict_link = {};
__str_dev_type = '';
__list_link_info = [];
__int_count = 0;
__list_str_ip_multi =[];
__list_str_ip_sim = [];
__dict_ip_to_mip = {};
__dict_ip_to_label = {};
__label_test = 'helloworld';
def __init__(self):
pass;
@staticmethod
def GetInstance():
if (None == link_manager.__instance):
link_manager.__instance = link_manager();
return link_manager.__instance;
def __DecimalToInt(self,Decimal):
str_num = str(Decimal);
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('GetSimuDevIPList failed',Com_imc_oper_manager);
return iResult,{};
simu_db_tool = db_tools();
simu_db_tool.SetDBInfo(param_tool.GetInstance().param_db_simulation.m_str_db_ip,param_tool.GetInstance().param_db_simulation.m_str_db_user,param_tool.GetInstance().param_db_simulation.m_str_db_pw);
iResult = simu_db_tool.OpenDBCon('config_db');
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('fail to open simu db',Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return iResult,{};
dict_id_ip = {};
for elem in list_simu_ip:
int_dev_id = -1;
iResult,int_dev_id = simu_db_tool.GetDevIDByDevIP(elem);
if (oErrorBase.base_succeed != iResult):
log_manager.GetInstance().CoutLog('GetDevIDByDevIP failed,ip:' + elem,Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return iResult,{};
dict_id_ip[int_dev_id] = elem;
if ( 0 == len(dict_id_ip)):
log_manager.GetInstance().CoutLog('dict id ip get is empty:' + elem,Com_imc_oper_manager);
simu_db_tool.CloseDBCon();
return oErrorBase.base_failed,{};
simu_db_tool.CloseDBCon();
log_manager.GetInstance().CoutLog('end to exec GetSimuIDIPDict',Com_imc_oper_manager);
return oErrorBase.base_succeed,dict_id_ip;
**********************************
文件名:inter_match_manager.py
**********************************
import os;
import re;
from data_struct_manager import *;
from error_manager import *;
from log_manager import *;
class inter_match_manager:
__instance = None;
__dict_inter_match = {};
def __init__(self):
pass;
@staticmethod
def GetInstance():
if (None == inter_match_manager.__instance):
inter_match_manager.__instance = inter_match_manager();
return inter_match_manager.__instance;
def GetInterMatchFileDictByIP(self,p_str_ip):
log_manager.GetInstance().CoutLog('begin to exec GetInterMatchFileDictByIP',Com_inter_match_manager);
self.__dict_inter_match = {};
dir_inter_match = dir.inter_match_file_dir;
file_names = os.listdir(dir.inter_match_file_dir);
for file_name in file_names:
pa_ip = p_str_ip;
if (file_name == ('match_' + pa_ip + '.cfg')):
str_ip = p_str_ip;
file_inter_match = None;
try:
file_inter_match = open(dir_inter_match + file_name);
except Exception, e:
log_manager.GetInstance().CoutLog('open file failed,file name:' + dir_inter_match + file_name,Com_inter_match_manager);
return oErrorBase.base_failed;
for line in file_inter_match:
pa_src_inter = re.compile('.*?,');
ma_src_inter = pa_src_inter.search(line);
if ma_src_inter:
src_inter = ma_src_inter.group();
src_inter = src_inter.replace(',','');
pa_des_inter = re.compile(',.*?,');
ma_des_inter = pa_des_inter.search(line);
if ma_des_inter:
des_inter = ma_des_inter.group();
des_inter = des_inter.replace(',','');
self.__dict_inter_match[src_inter] = des_inter;
file_inter_match.close();
log_manager.GetInstance().CoutLog('end to exec GetInterMatchFileDictByIP',Com_inter_match_manager);
return oErrorBase.base_succeed;
def GetDIBySIFromDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec GetDIBySIFromDic',Com_inter_match_manager);
if (0 == len(self.__dict_inter_match)):
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
return oErrorBase.base_failed,'';
for key in self.__dict_inter_match:
if (p_str_si.find(key+ '(E1)') != -1 or p_str_si == key):
log_manager.GetInstance().CoutLog('end to exec GetDIBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,self.__dict_inter_match[key];
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
log_manager.GetInstance().CoutLog('end to exec GetDIBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,'';
def IsDesInterInIDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec IsDesInterInIDic',Com_inter_match_manager);
for key in self.__dict_inter_match:
if (self.__dict_inter_match[key] == p_str_si):
log_manager.GetInstance().CoutLog('end to exec IsDesInterInIDic',Com_inter_match_manager);
return True;
log_manager.GetInstance().CoutLog('end to exec IsDesInterInIDic',Com_inter_match_manager);
return False;
def GetRealIfDescBySIFromDic(self,p_str_si):
log_manager.GetInstance().CoutLog('begin to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
for key in self.__dict_inter_match:
if (p_str_si == self.__dict_inter_match[key]):
log_manager.GetInstance().CoutLog('end to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_succeed,key;
log_manager.GetInstance().CoutLog('get failed:' + p_str_si,Com_inter_match_manager);
log_manager.GetInstance().CoutLog('end to exec GetRealIfDescBySIFromDic',Com_inter_match_manager);
return oErrorBase.base_failed,'';
**********************************
文件名:link_manager.py
**********************************
# -*- coding: utf8 -*-
from inter_match_manager import *;
from log_manager import *;
import os;
import re;
from decimal import *
import sys;
default_encoding = 'utf-8';
if sys.getdefaultencoding() != default_encoding:
stdout = sys.stdout;
stdin = sys.stdin;
reload(sys);
sys.stdout = stdout;
sys.stdin = stdin;
sys.setdefaultencoding(default_encoding);
import pymssql;
from m_port_manager import *;
from error_manager import *;
from data_struct_manager import *;
class link_manager:
__instance = None;
__db_ip = '';
__db_user = '';
__db_pw = '';
__list_ip = [];
__dict_link = {};
__str_dev_ip = '';
__new__dict_link = {};
__str_dev_type = '';
__list_link_info = [];
__int_count = 0;
__list_str_ip_multi =[];
__list_str_ip_sim = [];
__dict_ip_to_mip = {};
__dict_ip_to_label = {};
__label_test = 'helloworld';
def __init__(self):
pass;
@staticmethod
def GetInstance():
if (None == link_manager.__instance):
link_manager.__instance = link_manager();
return link_manager.__instance;
def __DecimalToInt(self,Decimal):
str_num = str(Decimal);
0 0
- 29
- 29
- 29
- 29
- 29
- 29
- 29
- 29
- 29
- 29
- 29
- 2004.8.29
- 2003.4.29
- 2005.08.29
- 【程序29】
- 2006.03.29
- 2006.06.29
- 2006.10.29
- android自定义带动画的柱状图控件
- 【机器学习】隐马尔科夫模型(下)——学习算法和预测算法
- 28
- android获取网页源码/接口JSON数据
- mongodb错误解决办法-bash: ./mongod: cannot execute binary file: Exec format error
- 29
- 第七章 Future,Promise and async()——线程通信
- MyCADCAE-几何模型检查
- MediaPlayer: setDataSource: IOException! uri=**
- SQLi Labs Lesson21
- 阿里云服务器配置LAMP,FTP连接上传代码
- 第八章 使用可调用对象
- 失业保险金的计算
- 30