import time dir_cur = os.path.normpath(os.path.dirname(os.path.abspath(__file__)).split('bin')[0]) if dir_cur not in sys.path: sys.path.insert(0, dir_cur) log_dir = os.path.normpath(dir_cur + os.path.sep + 'logs' + os.path.sep + 'sync_snmp_logs') if not os.path.isdir(log_dir): os.makedirs(log_dir) log_file = os.path.normpath(log_dir + os.path.sep + 'sync_snmp_trap.log') logging_config = os.path.normpath(dir_cur + os.path.sep + 'config' + os.path.sep + 'snmp_sync' + os.path.sep + 'logging.config') logging.config.fileConfig(logging_config, defaults={'log_file': log_file}) from com.ericsson.xn.commons import CommonUtil from com.ericsson.xn.commons.PyProperties import Properties CommonUtil.pre_check(systems=['Linux', 'Windows', 'Darwin']) from com.ericsson.xn.snmp import SnmpTrapUtils logging.critical('********** start alarm sync **********') class Options: def __init__(self, f_path): p = Properties(f_path, True).get_map() self.list = p['list'] self.id = p['id'] self.ip = p['ip'] self.port = int(p['port']) self.v3port = int(p['v3port']) self.number = int(p['number'])
#! /usr/bin/python # -*- coding: utf-8 -*- import os import sys import signal import logging import logging.config dir_cur = os.path.normpath(os.path.dirname(os.path.abspath(__file__)).split('sbin')[0]) if dir_cur not in sys.path: sys.path.insert(0, dir_cur) from com.ericsson.xn.commons import CommonUtil CommonUtil.pre_check(['Linux', 'Darwin'], True, True) log_dir = os.path.normpath(dir_cur + os.path.sep + 'logs' + os.path.sep + 'base_server') if not os.path.isdir(log_dir): os.makedirs(log_dir) log_file = os.path.normpath(log_dir + os.path.sep + 'base_server_daemon.log') logging_config = os.path.normpath(dir_cur + os.path.sep + 'config' + os.path.sep + 'base_server_daemon' + os.path.sep + 'logging.config') logging.config.fileConfig(logging_config, defaults={'log_file': log_file}) from com.ericsson.xn.commons.BaseServer import BaseServerDaemonMode if __name__ == '__main__': self_file = os.path.abspath(__file__) folder_pids = os.path.normcase(dir_cur + os.path.sep + 'pids') if not os.path.isdir(folder_pids): os.makedirs(folder_pids) pid = os.path.normpath(folder_pids + os.path.sep + 'base_server_daemon.pid')