Exemplo n.º 1
0
    def __init__(self, args):
        self._original_excepthook = sys.excepthook

        self.args = args

        self._mappers_manager = MapperManager()

        self._model_controller = ModelController(self._mappers_manager)

        self._plugin_manager = PluginManager(
            os.path.join(CONF.getConfigPath(), "plugins"))

        self._workspace_manager = WorkspaceManager(self._mappers_manager)

        # Create a PluginController and send this to UI selected.
        self._plugin_controller = PluginController('PluginController',
                                                   self._plugin_manager,
                                                   self._mappers_manager)

        if self.args.cli:
            self.app = CliApp(self._workspace_manager, self._plugin_controller)
            CONF.setMergeStrategy("new")
        else:
            self.app = UiFactory.create(self._model_controller,
                                        self._plugin_manager,
                                        self._workspace_manager,
                                        self._plugin_controller, self.args.gui)

        self.timer = TimerClass()
        self.timer.start()
Exemplo n.º 2
0
    def __init__(self, args):
        self._original_excepthook = sys.excepthook

        self.args = args

        logger = getLogger(self)
        if args.creds_file:
            try:
                with open(args.creds_file, 'r') as fp:
                    creds = json.loads(fp.read())
                    username = creds.get('username')
                    password = creds.get('password')
                    session_cookie = login_user(CONF.getServerURI(), username,
                                                password)
                    if session_cookie:
                        logger.info('Login successful')
                        CONF.setDBUser(username)
                        CONF.setDBSessionCookies(session_cookie)
                    else:
                        logger.error('Login failed')
            except (IOError, ValueError):
                logger.error("Credentials file couldn't be loaded")

        self._mappers_manager = MapperManager()
        pending_actions = Queue()
        self._model_controller = ModelController(self._mappers_manager,
                                                 pending_actions)

        self._plugin_manager = PluginManager(
            os.path.join(CONF.getConfigPath(), "plugins"),
            pending_actions=pending_actions,
        )

        self._workspace_manager = WorkspaceManager(self._mappers_manager)

        # Create a PluginController and send this to UI selected.
        self._plugin_controller = PluginController('PluginController',
                                                   self._plugin_manager,
                                                   self._mappers_manager,
                                                   pending_actions)

        if self.args.cli:

            self.app = CliApp(self._workspace_manager, self._plugin_controller)

            if self.args.keep_old:
                CONF.setMergeStrategy("old")
            else:
                CONF.setMergeStrategy("new")

        else:
            self.app = UiFactory.create(self._model_controller,
                                        self._plugin_manager,
                                        self._workspace_manager,
                                        self._plugin_controller, self.args.gui)

        self.timer = TimerClass()
        self.timer.start()