Beispiel #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()
Beispiel #2
0
def process_workspaces(mappers_manager, plugin_manager, query, disable_polling):
    report_managers = []
    controllers = []
    for workspace in query.all():
        pending_actions = Queue()
        plugin_controller = PluginController(
            'PluginController',
            plugin_manager,
            mappers_manager,
            pending_actions
        )
        mappers_manager.createMappers(workspace.name)
        controller = ModelController(mappers_manager, pending_actions)
        workspace_manager = WorkspaceManager(mappers_manager)
        setUpAPIs(controller, workspace_manager, hostname=None, port=None)
        controller.start()
        controllers.append(controller)
        report_manager = ReportManager(
            0.1,
            workspace.name,
            plugin_controller,
            polling=not disable_polling
        )
        report_managers.append(report_manager)
        report_manager.start()

    for report_manager in report_managers:
        report_manager.stop()

    for controller in controllers:
        controller.stop()
Beispiel #3
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()