clientFactory = OpenFlowClientFactory() clientFactory.protocol = OpenFlowClientLine logging.info("protocol = %s" % OpenFlowClientLine.__name__) try: reactor.connectTCP(app.conf.tcp.host, app.conf.tcp.port, clientFactory) logging.debug('Reactor start...') reactor.run() logging.debug('...Reactor stop') except twisted.internet.error.ServiceNameUnknownError as e: # Host:port Error logging.critical('twisted_ServiceNameUnknownError:%s' % e) except Exception as e: logging.critical(e) return if __name__ == '__main__': args = app.build_option_parser() root_path = os.path.dirname(os.path.abspath(__file__)) config_file = os.path.join(root_path, 'configs', args.type + '.ini') makelog(args.type) ret = app.load(config_file) if ret is True and app.connect(app.conf): run() logging.info('reactor stop...exit')
except MySQLdb.Error as e: logging.error('Error:%s' % e) return False return True class ConfigError(Exception): pass if __name__ == "__main__": try: makelog('topologyMysql') logging.info('START---------------') root_path = os.path.dirname(os.path.abspath(__file__)) config_file = os.path.join(root_path, 'configs', 'topology.ini') conf = ConfigLoader(config_file) result_redis = conf.redis_configloder() result_mysql = conf.mysql_configloder() if result_redis is False or result_mysql is False: raise ConfigError('Failed configloader...') mysql_client = connect_mysql(conf) if mysql_client: