Beispiel #1
0
    def __init__(self,
                 configManager,
                 startupSlide,
                 show_panel,
                 command_queue,
                 cmdline_args,
                 lockfile_fd,
                 auto_start=True,
                 restart_after_minute=-1):
        """FileRock client initialization.

        Loads and configures all application components.

        @param configManager:
                    Instance of filerockclient.config.configManager
        @param startupSlide:
                    Boolean telling whether the startup slides should
                    be shown.
        @param show_panel:
                    Boolean telling whether the UI should appear to the
                    user after the startup.
        @param command_queue:
                    Instance of Queue.Queue where to put commands for
                    filerockclient.application.Application.
        @param cmdline_args:
                    List of arguments which the client has been invoked with.
        @param lockfile_fd:
                    File descriptor of the lock file which ensures there
                    is only one instance of FileRock Client running.
                    Child processes have to close it to avoid stale locks.
        @param auto_start:
                    Boolean telling whether the client should automatically
                    connect to the server after initialization.
        @param restart_after_minute:
                    Number of minutes after which the application must
                    be restarted. There is no restart to do if it is
                    less than 0.
        """
        self.logger = logging.getLogger("FR")
        self.cfg = configManager
        self.startupSlide = startupSlide
        self.show_panel = show_panel
        self.auto_start = auto_start
        self.cmdline_args = cmdline_args
        self.lockfile_fd = lockfile_fd
        self.restart_after_time = restart_after_minute
        self.sys_config_path = self.cfg.get_config_dir()
        self.temp_dir = self.cfg.get('Application Paths', 'temp_dir')

        self.logger.info(u"Hello, this is FileRock client (version %s)" %
                         CURRENT_CLIENT_VERSION)
        self.logger.debug(u"python variable __debug__==%r" % __debug__)

        self.logger.debug(u"Initializing Metadata DB...")
        database_file = self.cfg.get('Application Paths', 'metadatadb')
        self._metadata_db = MetadataDB(database_file)
        self._metadata_db_exists_at_start = not self._metadata_db.recreated

        self.logger.debug(u"Initializing InternalFacade...")
        self._internal_facade = InternalFacade(
            self, command_queue, logging.getLogger('FR.InternalFacade'))

        self.logger.debug(u"Initializing UIController...")
        self._ui_controller = UIController(
            self._metadata_db, logging.getLogger('FR.UIController'))

        self.logger.debug(u"Initializing ClientFacade...")
        self._client_facade = ClientFacade(
            self, command_queue, logging.getLogger('FR.ClientFacade'))

        self.logger.debug(u"Initializing zombie ClientFacade...")
        import copy
        self._zombie_client_facade = copy.copy(self._client_facade)
        self._zombie_client_facade._set_zombie()

        self._scheduler = Scheduler()

        self.logger.debug(u"Initializing Hashes DB...")
        hashesdb_file = self.cfg.get('Application Paths', 'hashesdb')
        self.hashesDB = HashesDB(hashesdb_file)

        self.logger.debug(u"Initializing Storage Cache...")
        self.storage_cache = StorageCache(
            self.cfg.get('Application Paths', 'storage_cache_db'))

        self.logger.debug(u"Initializing Linker...")
        self.linker = Linker(self.cfg, self._ui_controller)

        self.logger.debug(u"Initializing OS settings manager...")
        self.os_settings_manager = OsConfig(cmdline_args=self.cmdline_args)

        self._warebox = None
        self.queue = None
        self.connector = None
        self.FSWatcher = None
        self.startup_synchronization = None
        self._server_session = None