Esempio n. 1
0
 def __init__(self, config_file = "config.cfg", reporter = None):
     """
     Construct a world handler instance.  Also reads the configuration file and
     creates new handler objects that belong under main tasklet observation.
     @param config_file Configuration file to read.  The default file name is "config.cfg".
     """
     self.reporter = reporter;
     
     # Read the configuration file.
     self.config = Config.VTank_Config();
     if not self.config.read(config_file):
         raise Force_Exit_Exception, "Reading configuration file failed!";
     
     # Create a database object.
     self.database = Database(self.config.database_host, self.config.database_user, 
         self.config.database_passwd, self.config.database_name);
     
     if not self.database.connect():
         # Connection to DB failed! This is considered a fatal error.
         raise Force_Exit_Exception, "Unable to connect to database: " \
             + str(self.database.get_last_error());
             
     Equipment_Manager.set_manager(Equipment_Manager._Manager(self.database));
     
     self.initialize_ice();
     
     self.client_tracker = Client_Tracker(self.config, self.database, reporter);
     
     # Prevent constructor from being called again.
     World_Handler.__init__ = World_Handler.__nomore__;
Esempio n. 2
0
    def __init__(self, config_file="config.cfg", reporter=None):
        """
        Construct a world handler instance.  Also reads the configuration file and
        creates new handler objects that belong under main tasklet observation.
        @param config_file Configuration file to read.  The default file name is "config.cfg".
        """
        self.reporter = reporter

        # Read the configuration file.
        self.config = Config.VTank_Config()
        if not self.config.read(config_file):
            raise Force_Exit_Exception, "Reading configuration file failed!"

        # Create a database object.
        self.database = Database(self.config.database_host,
                                 self.config.database_user,
                                 self.config.database_passwd,
                                 self.config.database_name)

        if not self.database.connect():
            # Connection to DB failed! This is considered a fatal error.
            raise Force_Exit_Exception, "Unable to connect to database: " \
                + str(self.database.get_last_error())

        Equipment_Manager.set_manager(Equipment_Manager._Manager(
            self.database))

        self.initialize_ice()

        self.client_tracker = Client_Tracker(self.config, self.database,
                                             reporter)

        # Prevent constructor from being called again.
        World_Handler.__init__ = World_Handler.__nomore__