Create a native VoltDB execution engine
15413
ExecutionEngine initializeEE()
    {
        String hostname = CoreUtils.getHostnameOrAddress();
        HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
        ExecutionEngine eeTemp = null;
        Deployment deploy = m_context.cluster.getDeployment().get("deployment");
        final int defaultDrBufferSize = Integer.getInteger("DR_DEFAULT_BUFFER_SIZE", 512 * 1024); // 512KB
        int configuredTimeout = Integer.getInteger("MAX_EXPORT_BUFFER_FLUSH_INTERVAL", 4*1000);
        final int exportFlushTimeout = configuredTimeout > 0 ? configuredTimeout : 4*1000;
        int tempTableMaxSize = deploy.getSystemsettings().get("systemsettings").getTemptablemaxsize();
        if (System.getProperty("TEMP_TABLE_MAX_SIZE") != null) {
            // Allow a system property to override the deployment setting
            // for testing purposes.
            tempTableMaxSize = Integer.getInteger("TEMP_TABLE_MAX_SIZE");
        }

        try {
            // NATIVE_EE_JNI and NATIVE_EE_LARGE_JNI
            if (m_backend.isDefaultJNITarget) {
                eeTemp =
                    new ExecutionEngineJNI(
                        m_context.cluster.getRelativeIndex(),
                        m_siteId,
                        m_partitionId,
                        m_context.getNodeSettings().getLocalSitesCount(),
                        CoreUtils.getHostIdFromHSId(m_siteId),
                        hostname,
                        m_context.cluster.getDrclusterid(),
                        defaultDrBufferSize,
                        tempTableMaxSize,
                        hashinatorConfig,
                        m_isLowestSiteId,
                        exportFlushTimeout);
            }
            else if (m_backend == BackendTarget.NATIVE_EE_SPY_JNI){
                Class<?> spyClass = Class.forName("org.mockito.Mockito");
                Method spyMethod = spyClass.getDeclaredMethod("spy", Object.class);
                ExecutionEngine internalEE = new ExecutionEngineJNI(
                        m_context.cluster.getRelativeIndex(),
                        m_siteId,
                        m_partitionId,
                        m_context.getNodeSettings().getLocalSitesCount(),
                        CoreUtils.getHostIdFromHSId(m_siteId),
                        hostname,
                        m_context.cluster.getDrclusterid(),
                        defaultDrBufferSize,
                        tempTableMaxSize,
                        hashinatorConfig,
                        m_isLowestSiteId,
                        exportFlushTimeout);
                eeTemp = (ExecutionEngine) spyMethod.invoke(null, internalEE);
            }
            else if (m_backend.isIPC) {
                // set up the EE over IPC
                eeTemp =
                    new ExecutionEngineIPC(
                            m_context.cluster.getRelativeIndex(),
                            m_siteId,
                            m_partitionId,
                            m_context.getNodeSettings().getLocalSitesCount(),
                            CoreUtils.getHostIdFromHSId(m_siteId),
                            hostname,
                            m_context.cluster.getDrclusterid(),
                            defaultDrBufferSize,
                            tempTableMaxSize,
                            m_backend,
                            VoltDB.instance().getConfig().m_ipcPort,
                            hashinatorConfig,
                            m_isLowestSiteId,
                            exportFlushTimeout);
            }
            else {
                /* This seems very bad. */
                throw new VoltAbortException(
                        String.format("Unexpected BackendTarget value %s", m_backend)
                );
            }
            eeTemp.loadCatalog(m_startupConfig.m_timestamp, m_startupConfig.m_serializedCatalog);
            eeTemp.setBatchTimeout(m_context.cluster.getDeployment().get("deployment").
                            getSystemsettings().get("systemsettings").getQuerytimeout());
        }
        // just print error info an bail if we run into an error here
        catch (final Exception ex) {
            hostLog.l7dlog( Level.FATAL, LogKeys.host_ExecutionSite_FailedConstruction.name(),
                            new Object[] { m_siteId, m_siteIndex }, ex);
            VoltDB.crashLocalVoltDB(ex.getMessage(), true, ex);
        }
        return eeTemp;
    }
971296
public VoltTable[] run(SystemProcedureExecutionContext ctx) {
        // Choose the lowest site ID on this host to actually flip the bit
        VoltDBInterface voltdb = VoltDB.instance();
        OperationMode opMode = voltdb.getMode();

        if (ctx.isLowestSiteId()) {
            ZooKeeper zk = voltdb.getHostMessenger().getZK();
            try {
                Stat stat;
                OperationMode zkMode = null;
                Code code;
                do {
                    stat = new Stat();
                    code = Code.BADVERSION;
                    try {
                        byte [] data = zk.getData(VoltZK.operationMode, false, stat);
                        zkMode = data == null ? opMode : OperationMode.valueOf(data);
                        if (zkMode == RUNNING) {
                            break;
                        }
                        stat = zk.setData(VoltZK.operationMode, RUNNING.getBytes(), stat.getVersion());
                        code = Code.OK;
                        zkMode = RUNNING;
                        break;
                    } catch (BadVersionException ex) {
                        code = ex.code();
                    }
                } while (zkMode != RUNNING && code == Code.BADVERSION);

                m_stat = stat;
                voltdb.getHostMessenger().unpause();
                voltdb.setMode(RUNNING);
                // for snmp
                SnmpTrapSender snmp = voltdb.getSnmpTrapSender();
                if (snmp != null) {
                    snmp.resume("Cluster resumed.");
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
        t.addRow(VoltSystemProcedure.STATUS_OK);
        return new VoltTable[] {t};
    }
197674
def initdb(self):
        """"""
        if hasattr(self, 'alchemist'):
            self.alchemist.meta.create_all(self.engine)
            if 'branch' not in self.globl:
                self.globl['branch'] = 'trunk'
            if 'rev' not in self.globl:
                self.globl['rev'] = 0
            return
        from sqlite3 import OperationalError
        cursor = self.connection.cursor()
        try:
            cursor.execute('SELECT * FROM global;')
        except OperationalError:
            cursor.execute(self.strings['create_global'])
        if 'branch' not in self.globl:
            self.globl['branch'] = 'trunk'
        if 'turn' not in self.globl:
            self.globl['turn'] = 0
        if 'tick' not in self.globl:
            self.globl['tick'] = 0
        for table in (
            'branches',
            'turns',
            'graphs',
            'graph_val',
            'nodes',
            'node_val',
            'edges',
            'edge_val',
            'plans',
            'plan_ticks'
        ):
            try:
                cursor.execute('SELECT * FROM ' + table + ';')
            except OperationalError:
                cursor.execute(self.strings['create_' + table])
231098
def main(arguments=None):
    

    # setup the command-line util settings
    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="WARNING",
        options_first=False,
        projectName=False
    )
    arguments, settings, log, dbConn = su.setup()

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    if os.path.isfile(pathToYaml):
        from fundamentals.mysql import yaml_to_database
        # PARSE YAML FILE CONTENTS AND ADD TO DATABASE
        yaml2db = yaml_to_database(
            log=log,
            settings=settings,
            dbConn=dbConn
        )
        yaml2db.add_yaml_file_content_to_database(
            filepath=pathToYaml,
            deleteFile=deleteFlag
        )
        basename = os.path.basename(pathToYaml)
        print "Content of %(basename)s added to database" % locals()

    else:
        from fundamentals.mysql import yaml_to_database
        yaml2db = yaml_to_database(
            log=log,
            settings=settings,
            dbConn=dbConn,
            pathToInputDir=pathToYaml,
            deleteFiles=deleteFlag
        )
        yaml2db.ingest()
        print "Content of %(pathToYaml)s directory added to database" % locals()

    return
1321868
def engine(log_file, no_distribute, yes, config_file, make_html_report,
           upgrade_db, db_version, what_if_I_upgrade, run,
           list_hazard_calculations, list_risk_calculations,
           delete_calculation, delete_uncompleted_calculations,
           hazard_calculation_id, list_outputs, show_log,
           export_output, export_outputs, exports='',
           log_level='info', reuse_hazard=False):
    
    if not run:
        # configure a basic logging
        logs.init()

    if config_file:
        config.read(os.path.abspath(os.path.expanduser(config_file)),
                    soft_mem_limit=int, hard_mem_limit=int, port=int,
                    multi_user=valid.boolean, multi_node=valid.boolean)

    if no_distribute:
        os.environ['OQ_DISTRIBUTE'] = 'no'

    # check if the datadir exists
    datadir = datastore.get_datadir()
    if not os.path.exists(datadir):
        os.makedirs(datadir)

    dbserver.ensure_on()
    # check if we are talking to the right server
    err = dbserver.check_foreign()
    if err:
        sys.exit(err)

    if upgrade_db:
        msg = logs.dbcmd('what_if_I_upgrade', 'read_scripts')
        if msg.startswith('Your database is already updated'):
            pass
        elif yes or confirm('Proceed? (y/n) '):
            logs.dbcmd('upgrade_db')
        sys.exit(0)

    if db_version:
        safeprint(logs.dbcmd('db_version'))
        sys.exit(0)

    if what_if_I_upgrade:
        safeprint(logs.dbcmd('what_if_I_upgrade', 'extract_upgrade_scripts'))
        sys.exit(0)

    # check if the db is outdated
    outdated = logs.dbcmd('check_outdated')
    if outdated:
        sys.exit(outdated)

    # hazard or hazard+risk
    if hazard_calculation_id == -1:
        # get the latest calculation of the current user
        hc_id = get_job_id(hazard_calculation_id, getpass.getuser())
    elif hazard_calculation_id:
        # make it possible to use calculations made by another user
        hc_id = get_job_id(hazard_calculation_id)
    else:
        hc_id = None
    if run:
        log_file = os.path.expanduser(log_file) \
            if log_file is not None else None
        job_inis = [os.path.expanduser(f) for f in run]
        if len(job_inis) == 1 and not hc_id:
            # init logs before calling get_oqparam
            logs.init('nojob', getattr(logging, log_level.upper()))
            # not using logs.handle that logs on the db
            oq = readinput.get_oqparam(job_inis[0])
            smart_run(job_inis[0], oq, log_level, log_file,
                      exports, reuse_hazard)
            return
        for i, job_ini in enumerate(job_inis):
            open(job_ini, 'rb').read()  # IOError if the file does not exist
            job_id = run_job(job_ini, log_level, log_file,
                             exports, hazard_calculation_id=hc_id)
            if not hc_id:  # use the first calculation as base for the others
                hc_id = job_id
    # hazard
    elif list_hazard_calculations:
        for line in logs.dbcmd(
                'list_calculations', 'hazard', getpass.getuser()):
            safeprint(line)
    elif delete_calculation is not None:
        del_calculation(delete_calculation, yes)
    # risk
    elif list_risk_calculations:
        for line in logs.dbcmd('list_calculations', 'risk', getpass.getuser()):
            safeprint(line)

    # export
    elif make_html_report:
        safeprint('Written %s' % make_report(make_html_report))
        sys.exit(0)

    elif list_outputs is not None:
        hc_id = get_job_id(list_outputs)
        for line in logs.dbcmd('list_outputs', hc_id):
            safeprint(line)
    elif show_log is not None:
        hc_id = get_job_id(show_log)
        for line in logs.dbcmd('get_log', hc_id):
            safeprint(line)

    elif export_output is not None:
        output_id, target_dir = export_output
        dskey, calc_id, datadir = logs.dbcmd('get_output', int(output_id))
        for line in core.export_output(
                dskey, calc_id, datadir, os.path.expanduser(target_dir),
                exports or 'csv,xml'):
            safeprint(line)

    elif export_outputs is not None:
        job_id, target_dir = export_outputs
        hc_id = get_job_id(job_id)
        for line in core.export_outputs(
                hc_id, os.path.expanduser(target_dir), exports or 'csv,xml'):
            safeprint(line)

    elif delete_uncompleted_calculations:
        logs.dbcmd('delete_uncompleted_calculations', getpass.getuser())

    else:
        engine.parentparser.prog = 'oq engine'
        engine.parentparser.print_usage()
574168
def execute_makeblastdb(type, title, input)
      @output.puts "Executing makeblastdb for #{title} dbtype #{type}..."

      makeblast_log = File.join(@log_dir, "makeblastdb.log")
      output        = File.dirname(input)

      cmd = "makeblastdb " <<
        "-dbtype #{type} " <<
        "-title #{title} " <<
        "-in #{input} " <<
        "-out #{output} " <<
        "-hash_index >> #{makeblast_log}"
      system(cmd)
      if $?.exitstatus > 0
        raise "makeblastdb error. " <<
          "See #{makeblast_log} for details."
      end
    end
1324663
def create():
    
    # Generate project locale
    locale = env.locale.replace("UTF-8", "utf8")
    with hide("stdout"):
        if locale not in run("locale -a"):
            sudo("locale-gen %s" % env.locale)
            sudo("update-locale %s" % env.locale)
            sudo("service postgresql restart")
            run("exit")

    # Create project path
    run("mkdir -p %s" % env.proj_path)

    # Set up virtual env
    run("mkdir -p %s" % env.venv_home)
    with cd(env.venv_home):
        if exists(env.proj_name):
            if confirm("Virtualenv already exists in host server: %s"
                       "\nWould you like to replace it?" % env.proj_name):
                run("rm -rf %s" % env.proj_name)
            else:
                abort()
        run("virtualenv %s" % env.proj_name)

    # Upload project files
    if env.deploy_tool in env.vcs_tools:
        vcs_upload()
    else:
        rsync_upload()

    # Create DB and DB user
    pw = db_pass()
    user_sql_args = (env.proj_name, pw.replace("'", "\'"))
    user_sql = "CREATE USER %s WITH ENCRYPTED PASSWORD '%s';" % user_sql_args
    psql(user_sql, show=False)
    shadowed = "*" * len(pw)
    print_command(user_sql.replace("'%s'" % pw, "'%s'" % shadowed))
    psql("CREATE DATABASE %s WITH OWNER %s ENCODING = 'UTF8' "
         "LC_CTYPE = '%s' LC_COLLATE = '%s' TEMPLATE template0;" %
         (env.proj_name, env.proj_name, env.locale, env.locale))

    # Set up SSL certificate
    if not env.ssl_disabled:
        conf_path = "/etc/nginx/conf"
        if not exists(conf_path):
            sudo("mkdir %s" % conf_path)
        with cd(conf_path):
            crt_file = env.proj_name + ".crt"
            key_file = env.proj_name + ".key"
            if not exists(crt_file) and not exists(key_file):
                try:
                    crt_local, = glob(join("deploy", "*.crt"))
                    key_local, = glob(join("deploy", "*.key"))
                except ValueError:
                    parts = (crt_file, key_file, env.domains[0])
                    sudo("openssl req -new -x509 -nodes -out %s -keyout %s "
                         "-subj '/CN=%s' -days 3650" % parts)
                else:
                    upload_template(crt_local, crt_file, use_sudo=True)
                    upload_template(key_local, key_file, use_sudo=True)

    # Install project-specific requirements
    upload_template_and_reload("settings")
    with project():
        if env.reqs_path:
            pip("-r %s/%s" % (env.proj_path, env.reqs_path))
        pip("gunicorn setproctitle psycopg2 "
            "django-compressor python-memcached")
    # Bootstrap the DB
        manage("createdb --noinput --nodata")
        python("from django.conf import settings;"
               "from django.contrib.sites.models import Site;"
               "Site.objects.filter(id=settings.SITE_ID).update(domain='%s');"
               % env.domains[0])
        for domain in env.domains:
            python("from django.contrib.sites.models import Site;"
                   "Site.objects.get_or_create(domain='%s');" % domain)
        if env.admin_pass:
            pw = env.admin_pass
            user_py = ("from django.contrib.auth import get_user_model;"
                       "User = get_user_model();"
                       "u, _ = User.objects.get_or_create(username='admin');"
                       "u.is_staff = u.is_superuser = True;"
                       "u.set_password('%s');"
                       "u.save();" % pw)
            python(user_py, show=False)
            shadowed = "*" * len(pw)
            print_command(user_py.replace("'%s'" % pw, "'%s'" % shadowed))

    return True
230314
function execute() {
  var context = getDefaultContext();
  var compiledOutput = fs.readFileSync(this.outputPath)

  vm.runInContext(compiledOutput, context, this.outputPath);

  var module = extractModule(this.moduleName, context);

  this.compiledModule = context.Elm.fullscreen(module, this.defaults);
}
266025
def main():
    """"""
    args = get_args()

    # Make Chronophore's directories and files in $HOME
    DATA_DIR = pathlib.Path(appdirs.user_data_dir(__title__))
    LOG_FILE = pathlib.Path(appdirs.user_log_dir(__title__), 'debug.log')
    os.makedirs(str(DATA_DIR), exist_ok=True)
    os.makedirs(str(LOG_FILE.parent), exist_ok=True)

    if args.version:
        print('{} {}'.format(__title__, __version__))
        raise SystemExit

    if args.debug:
        CONSOLE_LOG_LEVEL = logging.DEBUG
    elif args.verbose:
        CONSOLE_LOG_LEVEL = logging.INFO
    else:
        CONSOLE_LOG_LEVEL = logging.WARNING

    logger = set_up_logging(LOG_FILE, CONSOLE_LOG_LEVEL)
    logger.debug('-'*80)
    logger.info('{} {}'.format(__title__, __version__))
    logger.debug('Log File: {}'.format(LOG_FILE))
    logger.debug('Data Directory: {}'.format(DATA_DIR))

    if args.testdb:
        DATABASE_FILE = DATA_DIR.joinpath('test.sqlite')
        logger.info('Using test database.')
    else:
        DATABASE_FILE = DATA_DIR.joinpath('chronophore.sqlite')

    logger.debug('Database File: {}'.format(DATABASE_FILE))
    engine = create_engine('sqlite:///{}'.format(str(DATABASE_FILE)))
    Base.metadata.create_all(engine)
    Session.configure(bind=engine)

    if args.log_sql:
        logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

    if args.testdb:
        add_test_users(session=Session())

    controller.flag_forgotten_entries(session=Session())

    if args.tk:
        from chronophore.tkview import TkChronophoreUI
        TkChronophoreUI()
    else:
        try:
            from PyQt5.QtWidgets import QApplication
        except ImportError:
            print(
                'Error: PyQt5, which chronophore uses for its'
                + ' graphical interface, is not installed.'
                + "\nInstall it with 'pip install PyQt5'"
                + " or use the old Tk ui with 'chronophore --tk'."
            )
            raise SystemExit
        else:
            from chronophore.qtview import QtChronophoreUI
            app = QApplication(sys.argv)
            chrono_ui = QtChronophoreUI()
            chrono_ui.show()
            sys.exit(app.exec_())

    logger.debug('{} stopping'.format(__title__))
857730
public VoltTable[] run(SystemProcedureExecutionContext ctx) {
        // Choose the lowest site ID on this host to actually flip the bit

        if (ctx.isLowestSiteId()) {
            VoltDBInterface voltdb = VoltDB.instance();
            OperationMode opMode = voltdb.getMode();
            if (LOG.isDebugEnabled()) {
                LOG.debug("voltdb opmode is " + opMode);
            }
            ZooKeeper zk = voltdb.getHostMessenger().getZK();
            try {
                Stat stat;
                OperationMode zkMode = null;
                Code code;
                do {
                    stat = new Stat();
                    code = Code.BADVERSION;
                    try {
                        byte [] data = zk.getData(VoltZK.operationMode, false, stat);
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("zkMode is " + (zkMode == null ? "(null)" : OperationMode.valueOf(data)));
                        }
                        zkMode = data == null ? opMode : OperationMode.valueOf(data);
                        if (zkMode == PAUSED) {
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("read node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid()));
                            }
                            break;
                        }
                        stat = zk.setData(VoltZK.operationMode, PAUSED.getBytes(), stat.getVersion());
                        code = Code.OK;
                        zkMode = PAUSED;
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("!WROTE! node at version " + stat.getVersion() + ", txn " + ll(stat.getMzxid()));
                        }
                        break;
                    } catch (BadVersionException ex) {
                        code = ex.code();
                    }
                } while (zkMode != PAUSED && code == Code.BADVERSION);

                m_stat = stat;
                voltdb.getHostMessenger().pause();
                voltdb.setMode(PAUSED);

             // for snmp
                SnmpTrapSender snmp = voltdb.getSnmpTrapSender();
                if (snmp != null) {
                    snmp.pause("Cluster paused.");
                }

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        // Force a tick so that stats will be updated.
        // Primarily added to get latest table stats for DR pause and empty db check.
        ctx.getSiteProcedureConnection().tick();

        VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
        t.addRow(VoltSystemProcedure.STATUS_OK);
        return (new VoltTable[] {t});
    }
921289
def execute():
    """"""

    if len(sys.argv) <= 1:
        raise SystemExit(
            'No Arguments provided. use [--help] for more information.'
        )

    # Capture user arguments
    _args = arguments.ArgumentParserator(
        arguments_dict=turbolift.ARGUMENTS,
        env_name='TURBO',
        epilog=turbolift.VINFO,
        title='Turbolift',
        detail='Multiprocessing Swift CLI tool.',
        description='Manage Swift easily and fast.'
    )
    user_args = _args.arg_parser()
    user_args['run_indicator'] = True
    debug_log = False
    stream_logs = True

    # Load system logging
    if user_args.get('debug'):
        debug_log = True
        user_args['run_indicator'] = False

    # Load system logging
    if user_args.get('quiet'):
        stream_logs = False
        user_args['run_indicator'] = False

    _logging = logger.LogSetup(
        debug_logging=debug_log,
        colorized_messages=user_args.get('colorized', False)
    )
    _logging.default_logger(name='turbolift', enable_stream=stream_logs)
    job = worker.Worker(job_args=user_args)
    job.run_manager()
130914
def initdb(self):
        '''
        '''

        self.database = EXPFACTORY_DATABASE
        bot.info("DATABASE: %s" %self.database)

        # Supported database options
        valid = ('sqlite', 'postgres', 'mysql', 'filesystem')
        if not self.database.startswith(valid):
            bot.warning('%s is not yet a supported type, saving to filesystem.' % self.database)
            self.database = 'filesystem'

        # Add functions specific to database type
        self.init_db() # uses url in self.database

        bot.log("Data base: %s" % self.database)
429089
function runTool(platform, args, done) {
  if (args.length < 1) {
    console.log('usage: query.js file.wtf-trace "[query string]"');
    done(1);
    return;
  }

  var inputFile = args[0];
  var exprArgs = args.slice(1);
  var expr = exprArgs.join(' ').trim();

  console.log('Querying ' + inputFile + '...');

  // Create database for querying.
  var loadStart = wtf.now();
  wtf.db.load(inputFile, function(db) {
    if (db instanceof Error) {
      console.log('ERROR: unable to open ' + inputFile, db);
      done(1);
      return;
    }

    var loadDuration = wtf.now() - loadStart;
    console.log('Database loaded in ' + loadDuration.toFixed(3) + 'ms');
    console.log('');

    queryDatabase(db, expr);

    done(0);
  });
}
265157
def create_execution_engine():
    
    # Create a target machine representing the host
    target = llvm.Target.from_default_triple()
    target_machine = target.create_target_machine()
    # And an execution engine with an empty backing module
    backing_mod = llvm.parse_assembly("")
    engine = llvm.create_mcjit_compiler(backing_mod, target_machine)
    return engine
720431
def launch(run=True, **args):
    """"""

    verbosity['console'] = args['log'] if not args['quiet'] else 100
    verbosity['global'] = min(args['log'], args['logfileverbosity'])
    verbosity['file'] = args['logfileverbosity'] if args['dolog'] else 100
    set_logfile(args['logfilepath'], args['instance'])

    if args['livelog'] is True:
        from hfos import logger
        logger.live = True

    hfoslog("Running with Python", sys.version.replace("\n", ""),
            sys.platform, lvl=debug, emitter='CORE')
    hfoslog("Interpreter executable:", sys.executable, emitter='CORE')
    if args['cert'] is not None:
        hfoslog("Warning! Using SSL without nginx is currently not broken!",
                lvl=critical, emitter='CORE')

    hfoslog("Initializing database access", emitter='CORE', lvl=debug)
    initialize(args['dbhost'], args['dbname'], args['instance'])

    server = construct_graph(args)
    if run and not args['norun']:
        server.run()

    return server
698963
def makeblastdb(self):
        """"""
        while True:  # while daemon
            fastapath = self.dqueue.get()  # grabs fastapath from dqueue
            # remove the path and the file extension for easier future globbing
            db = os.path.splitext(fastapath)[0]
            nhr = '{}.nhr'.format(db)  # add nhr for searching
            # fnull = open(os.devnull, 'w')  # define /dev/null
            if not os.path.isfile(str(nhr)):  # if check for already existing dbs
                # Create the databases
                # TODO use MakeBLASTdb class
                threadlock = threading.Lock()
                command = 'makeblastdb -in {} -parse_seqids -max_file_sz 2GB -dbtype nucl -out {}'.format(fastapath, db)
                # subprocess.call(shlex.split('makeblastdb -in {} -parse_seqids -max_file_sz 2GB -dbtype nucl -out {}'
                #                            .format(fastapath, db)), stdout=fnull, stderr=fnull)
                out, err = run_subprocess(command)
                threadlock.acquire()
                write_to_logfile(command, command, self.logfile, None, None, None, None)
                write_to_logfile(out, err, self.logfile, None, None, None, None)
                threadlock.release()
            self.dqueue.task_done()
448353
def main(arguments=None):
    

    # setup the command-line util settings
    su = tools(
        arguments=arguments,
        docString=__doc__,
        logLevel="WARNING",
        options_first=False,
        projectName=False
    )
    arguments, settings, log, dbConn = su.setup()

    # unpack remaining cl arguments using `exec` to setup the variable names
    # automatically
    for arg, val in arguments.iteritems():
        if arg[0] == "-":
            varname = arg.replace("-", "") + "Flag"
        else:
            varname = arg.replace("<", "").replace(">", "")
        if isinstance(val, str) or isinstance(val, unicode):
            exec(varname + " = '%s'" % (val,))
        else:
            exec(varname + " = %s" % (val,))
        if arg == "--dbConn":
            dbConn = val
        log.debug('%s = %s' % (varname, val,))

    from fundamentals.mysql import sqlite2mysql
    converter = sqlite2mysql(
        log=log,
        settings=settings,
        pathToSqlite=pathToSqliteDB,
        tablePrefix=tablePrefix,
        dbConn=dbConn
    )
    converter.convert_sqlite_to_mysql()

    return