Example #1
0
    def from_cmdline_args(args, workspace, migration_root, env=None):
        """
        Normally only this method is called form outside of this module in
        order to instance the proper server implementation.

        Parameters:
            args: the command line arguments from CodeChecker.py
            workspace: path to the CodeChecker workspace directory
            migration_root: path to the database migration scripts
            env: a run environment dictionary.
        """

        if not host_check.check_sql_driver(args.postgresql):
            LOG.error("The selected SQL driver is not available.")
            sys.exit(1)

        if args.postgresql:
            LOG.debug("Using PostgreSQLServer")
            return PostgreSQLServer(workspace,
                                    migration_root,
                                    args.dbaddress,
                                    args.dbport,
                                    args.dbusername,
                                    args.dbname,
                                    run_env=env)
        else:
            LOG.debug("Using SQLiteDatabase")
            return SQLiteDatabase(workspace, migration_root, run_env=env)
Example #2
0
    def from_cmdline_args(args, migration_root, env=None):
        """
        Normally only this method is called form outside of this module in
        order to instance the proper server implementation.

        Parameters:
            args: the command line arguments from CodeChecker.py
            migration_root: path to the database migration scripts
            env: a run environment dictionary.
        """

        if not host_check.check_sql_driver(args.postgresql):
            LOG.error("The selected SQL driver is not available.")
            sys.exit(1)

        if args.postgresql:
            LOG.debug("Using PostgreSQLServer")
            if 'workspace' in args:
                data_url = os.path.join(args.workspace, 'pgsql_data')
            else:
                # TODO: This will be refactored eventually so that
                # CodeChecker is no longer bringing up a postgres database...
                # It is an external dependency, it is an external
                # responbitility. Until then, use the default folder now
                # for the new commands who no longer define workspace.
                if 'dbdatadir' in args:
                    workspace = args.dbdatadir
                else:
                    workspace = util.get_default_workspace()
                data_url = os.path.join(workspace, 'pgsql_data')
            return PostgreSQLServer(data_url,
                                    migration_root,
                                    args.dbaddress,
                                    args.dbport,
                                    args.dbusername,
                                    args.dbname,
                                    run_env=env)
        else:
            LOG.debug("Using SQLiteDatabase")
            if 'workspace' in args:
                data_file = os.path.join(args.workspace, 'codechecker.sqlite')
            else:
                data_file = args.sqlite
            return SQLiteDatabase(data_file, migration_root, run_env=env)
Example #3
0
    def from_cmdline_args(args,
                          model_meta,
                          migration_root,
                          interactive=False,
                          env=None):
        """
        Normally only this method is called form outside of this module in
        order to instance the proper server implementation.

        Parameters:
            args: the command line arguments from CodeChecker.py, but as a
              dictionary (if argparse.Namespace, use vars(args)).
            model_meta: the meta identifier of the database model to use
            migration_root: path to the database migration scripts
            interactive: whether or not the database connection can be
              interactive on the server's shell.
            env: a run environment dictionary.
        """

        if not host_check.check_sql_driver(args['postgresql']):
            LOG.error("The selected SQL driver is not available!")
            raise IOError("The SQL driver to be used is not available!")

        if args['postgresql']:
            LOG.debug("Using PostgreSQL:")
            return PostgreSQLServer(
                model_meta,
                migration_root,
                args['dbaddress'],
                args['dbport'],
                args['dbusername'],
                args['dbname'],
                password=args['dbpassword'] if 'dbpassword' in args else None,
                interactive=interactive,
                run_env=env)
        else:
            LOG.debug("Using SQLite:")
            data_file = os.path.abspath(args['sqlite'])
            LOG.debug("Database at " + data_file)
            return SQLiteDatabase(data_file,
                                  model_meta,
                                  migration_root,
                                  run_env=env)