Install modul ke database
196700
public function setModules()
	{
		$moduleVendorPath	= Yii::getPathOfAlias('application.vendor.ommu');
		$installedModule	= $this->getModulesFromDir();
		$cacheModule		= file(Yii::getPathOfAlias('application.config').'/cache_module.php');
		$toBeInstalled		= array();
		
		$caches = array();
		foreach($cacheModule as $val) {
			$caches[] = trim($val);
		}

		if(!$installedModule)
			$installedModule = array();
		
		foreach($caches as $cache) {
			if(!in_array($cache, array_map("trim", $installedModule)))
				$this->deleteModuleDb($cache);
		}

		$moduleDb = $this->cacheModuleConfig(true);
		foreach($installedModule as $module) {
			$module = trim($module);
			if(!in_array($module, array_map("trim", $moduleDb))) {
				$config = $this->getModuleConfig($module);
				$moduleFile = join('/', array($moduleVendorPath, $module, ucfirst($module).'Module.php'));

				if($config && file_exists($moduleFile) && $module == $config['folder_name']) {
					$model=new OmmuPlugins;
					$model->folder = $module;
					$model->name = $config['name'];
					$model->desc = $config['description'];
					if($config['model'])
						$model->model = $config['model'];
					$model->save();
				}
			}
		}
		
		$this->generateModules();
	}
1226989
function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_COUPON_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', '280', 'Sort order of display.', '6', '2', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'true', 'Include Shipping in calculation', '6', '5', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'false', 'Include Tax in calculation.', '6', '6','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'Standard', 'Re-Calculate Tax', '6', '7','zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS', '0', 'Use the following tax class when treating Discount Coupon as Credit Note.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
  }
244818
protected function bootDatabaseEnvVars()
    {
        // Set default database config
        $databaseConfig = $this->getDatabaseConfig();
        $databaseConfig['database'] = $this->getDatabaseName();
        DB::setConfig($databaseConfig);
    }
1319848
def service(ctx):
    """"""

    install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'])
357107
def setup_db(connection_string):
    
    global DB_Session, engine
    new_database = False
    if connection_string == 'sqlite://' or not database_exists(connection_string):
        new_database = True
    engine = create_engine(connection_string, connect_args={'timeout': 20})
    entities.Base.metadata.create_all(engine)
    DB_Session = sessionmaker(bind=engine)
    db_path = os.path.dirname(__file__)

    if new_database:
        # bootstrapping the db with classifications types.
        json_file = open(os.path.join(db_path, 'bootstrap.json'))
        data = json.load(json_file)
        session = get_session()
        session.execute('PRAGMA user_version = {0}'.format(beeswarm.server.db.DATABASE_VERSION))
        for entry in data['classifications']:
            c = session.query(Classification).filter(Classification.type == entry['type']).first()
            if not c:
                classification = Classification(type=entry['type'], description_short=entry['description_short'],
                                                description_long=entry['description_long'])
                session.add(classification)
            else:
                c.description_short = entry['description_short']
                c.description_long = entry['description_long']
        for username in data['bait_users']:
            u = session.query(BaitUser).filter(BaitUser.username == username).first()
            if not u:
                logger.debug('Creating default BaitUser: {}'.format(username))
                password = data['bait_users'][username]
                bait_user = BaitUser(username=username, password=password)
                session.add(bait_user)
        session.commit()
    else:
        result = engine.execute("PRAGMA user_version;")
        version = result.fetchone()[0]
        result.close()
        logger.info('Database is at version {0}.'.format(version))
        if version != beeswarm.server.db.DATABASE_VERSION:
            logger.error('Incompatible database version detected. This version of Beeswarm is compatible with '
                         'database version {0}, but {1} was found. Please delete the database, restart the Beeswarm '
                         'server and reconnect the drones.'.format(beeswarm.server.db.DATABASE_VERSION,
                                                                   version))
            sys.exit(1)
913875
public function install()
    {
        define('GL_INSTALL', true);
        $this->init();
        echo '<pre>';
        $fail = false;
        $db = new DatabaseManager();
        if ($db->connectAndSelect()) {
            $this->setDatabase($db);
            $this->log('Connection to database ok');

            $this->log('Installing Database...');
            $models = $this->getModels();
            foreach ($models as $model) {
                $instance = new $model(null);
                if ($instance instanceof Model) {
                    $diff = $instance->getStructureDifferences($db, isset($_GET['drop']));
                    $this->log('Installing table \'' . $instance->getTableName() . '\' generated by ' . get_class($instance) . '...',
                        2);
                    foreach ($diff as $action) {
                        $this->log('Action: ' . $action['sql'] . '...', 3, false);

                        if (isset($_GET['exec'])) {
                            try {
                                DBStructure::runAction($db, $instance, $action);
                                $this->log('[OK]', 0);
                            } catch (\Exception $ex) {
                                $this->log('[FAIL]', 0);
                                $fail = true;
                            }
                        }
                        echo "\n";
                    }
                }
            }
            if (!isset($_GET['exec'])) {
                $this->log('Please <a href="?exec">click here</a> to make this changes in the database.');
            } else {
                $db2 = new DBStructure();
                $db2->setDatabaseUpdate();
                $this->log('All done site ready for develop/production!');
            }
        } else {
            if ($db->getConnection() !== null) {
                if (isset($_GET['create_database'])) {
                    if ($db->exec('CREATE DATABASE ' . $this->config['database']['database'])) {
                        echo 'Database created successful! Please reload the navigator';
                    } else {
                        echo 'Can not create the database!';
                    }
                } else {
                    echo 'Can\'t select the database <a href="install.php?create_database">Try to create database</a>';
                }
            } else {
                echo 'Cannot connect to database';
            }
        }
    }
1324360
public void main() {

        fMain = new Frame("HSQLDB Database Manager for Zaurus");
        imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2,
                2));

        fMain.setIconImage(imgEmpty);
        fMain.addWindowListener(this);

        MenuBar bar = new MenuBar();

        // no shortcuts used
        String[] fitems = {
            "-Connect...", "--", "-Open Script...", "-Save Script...",
            "-Save Result...", "--", "-Exit"
        };

        addMenu(bar, "File", fitems);

        String[] vitems = {
            "-Refresh Tree", "--", "-View Tree", "-View Command",
            "-View Result", "-View Editor", "--", "-Results in Grid",
            "-Results in Text"
        };

        addMenu(bar, "View", vitems);

        String[] sitems = {
            "-SELECT", "-INSERT", "-UPDATE", "-DELETE", "--", "-CREATE TABLE",
            "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-SCRIPT",
            "-SHUTDOWN", "--", "-Test Script"
        };

        addMenu(bar, "SQL", sitems);

        Menu recent = new Menu("Recent");

        mRecent = new Menu("Recent");

        bar.add(mRecent);

        String[] soptions = {
            "-AutoCommit on", "-AutoCommit off", "-Commit", "-Rollback", "--",
            "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on",
            "-Logging off", "--",
            "-Insert test data"    // , "-Transfer"
        };

        addMenu(bar, "Options", soptions);

        String[] shelp = { "-Show HTML-Help in browser" };

        addMenu(bar, "?", shelp);
        fMain.setMenuBar(bar);
        fMain.setSize(defWidth, defHeight);
        fMain.add("Center", this);
        initGUI();

        sRecent = new String[iMaxRecent];

        Dimension d    = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension size = fMain.getSize();

        // (ulrivo): arguments from command line or
        // full size on screen with less than 640 width
        if (d.width > 640) {
            fMain.setLocation((d.width - size.width) / 2,
                              (d.height - size.height) / 2);
        } else if (defWidth > 0 && defHeight > 0) {
            fMain.setLocation(defLocX, defLocY);
            fMain.setSize(defWidth, defHeight);
        } else {
            fMain.setLocation(0, 0);
            fMain.setSize(d);
        }

        fMain.show();

        // (ulrivo): load query from command line
        if (defQuery != null) {
            txtCommand.setText(DatabaseManagerCommon.readFile(defQuery));
        }

        txtCommand.requestFocus();
    }
416433
public function boot()
    {
        // Fix UTF8MB4 support for MariaDB < 10.2 and MySQL < 5.7
        if (Config::get('database.connections.mysql.charset') === 'utf8mb4') {
            Schema::defaultStringLength(191);
        }

        Paginator::defaultSimpleView('system::pagination.simple-default');

        /*
         * Boot plugins
         */
        PluginManager::instance()->bootAll();

        parent::boot('system');
    }
1014247
def install(self, update=False):
        
        offline = self.offline or update
        self.create_env(offline)
        self.install_pkgs(offline)
        self.install_pip(offline)
        return tuple()
1176937
def add(context, filenames):
    
    logging.info(_('Current Mode: Add Linux data'))
    context.obj['database'].add_data(filenames)
    sys.exit(0)
1305148
def install_database(name, owner, template='template0', encoding='UTF8', locale='en_US.UTF-8'):
    


    create_database(name, owner, template=template, encoding=encoding,
                        locale=locale)
562036
private function registerMainDatabase()
    {
        $filename = NABU_ETC_PATH.DIRECTORY_SEPARATOR.NABU_DB_DEFAULT_FILENAME_CONFIG;
        if (!file_exists($filename) && ($file = fopen($filename, "w")) !== false) {
            fwrite($file,
                    "<?php\n".
                    "\$db_user = \"nabu-3\";\n".
                    "\$db_passwd = \"nabu-3\";\n".
                    "\$db_host = \"localhost:3306\";\n".
                    "\$db_schema = \"nabu-3\";\n".
                    "\$db_trace_query = false;\n".
                    "?>\n"
                    );
            fclose($file);
        }

        $this->main_database = new CMySQLConnector($filename);
        $this->main_database->setSpaceOptimization(true);
        if ($this->main_database->connect()) {
            if (!$this->main_database->testConnection()) {
                //throw new exceptions\ENabuCoreException(exceptions\ENabuCoreException::ERROR_M)
                $this->errorLog("Database Test error: ".$this->main_database->getLastErrorMessage());
            }
        } else {
            throw new ENabuDBException(ENabuDBException::ERROR_NOT_CONNECTED);
        }
    }
914004
public function install()
    {
        $module = Core::app()->getModuleById($this->sModuleAlias);

        if (!$module)
        {
            // 1. add row to the modules table
            $moduleDir = RX_PATH.'/ruxon/modules/'.$this->sModuleAlias;

            $info = Loader::loadConfigFile($moduleDir, 'module');

            $module = array(
                'Name' => $info['Name'],
                'Description' => $info['Description'],
                'Version' => $info['Version'],
                'DbRevision' => '-1'
            );

            Core::app()->updateModuleById($this->sModuleAlias, $module);

            $sClassName = $this->sModuleAlias.'Module';
            $classNameWithNamespaces = '\ruxon\modules\\'.$this->sModuleAlias.'\classes\\'.$sClassName;
            Manager::getInstance()->setModule($this->sModuleAlias, class_exists($classNameWithNamespaces) ? new $classNameWithNamespaces : new $sClassName);

            // 2. create table structure
            $migrator = new MysqlDbMigrator($this->sModuleAlias);
            $migrator->migrateTo('last');


            // 3. copy default config to config folder
            $file1 = RX_PATH.'/ruxon/modules/'.$this->sModuleAlias.'/config/module.inc.php';
            $file2 = RX_PATH.'/ruxon/config/modules/'.$this->sModuleAlias.'.inc.php';
            if (file_exists($file1) && !file_exists($file2))
            {
                copy($file1, $file2);
            }

            return true;
        }

        return false;
    }
1151914
def _install_kraken_db(datadir, args):
    
    import requests
    kraken = os.path.join(datadir, "genomes/kraken")
    url = "https://ccb.jhu.edu/software/kraken/dl/minikraken.tgz"
    compress = os.path.join(kraken, os.path.basename(url))
    base, ext = utils.splitext_plus(os.path.basename(url))
    db = os.path.join(kraken, base)
    tooldir = args.tooldir or get_defaults()["tooldir"]
    requests.packages.urllib3.disable_warnings()
    last_mod = urllib.request.urlopen(url).info().get('Last-Modified')
    last_mod = dateutil.parser.parse(last_mod).astimezone(dateutil.tz.tzutc())
    if os.path.exists(os.path.join(tooldir, "bin", "kraken")):
        if not os.path.exists(db):
            is_new_version = True
        else:
            cur_file = glob.glob(os.path.join(kraken, "minikraken_*"))[0]
            cur_version = datetime.datetime.utcfromtimestamp(os.path.getmtime(cur_file))
            is_new_version = last_mod.date() > cur_version.date()
            if is_new_version:
                shutil.move(cur_file, cur_file.replace('minikraken', 'old'))
        if not os.path.exists(kraken):
            utils.safe_makedir(kraken)
        if is_new_version:
            if not os.path.exists(compress):
                subprocess.check_call(["wget", "-O", compress, url, "--no-check-certificate"])
            cmd = ["tar", "-xzvf", compress, "-C", kraken]
            subprocess.check_call(cmd)
            last_version = glob.glob(os.path.join(kraken, "minikraken_*"))
            utils.symlink_plus(os.path.join(kraken, last_version[0]), os.path.join(kraken, "minikraken"))
            utils.remove_safe(compress)
        else:
            print("You have the latest version %s." % last_mod)
    else:
        raise argparse.ArgumentTypeError("kraken not installed in tooldir %s." %
                                         os.path.join(tooldir, "bin", "kraken"))
669384
def gui(discord_token, discord_client_id):
    

    logger.info("Starting Modis in GUI")

    import tkinter as tk

    logger.debug("Loading packages")
    from modis.discord_modis import gui as discord_modis_gui
    from modis.reddit_modis import gui as reddit_modis_gui
    from modis.facebook_modis import gui as facebook_modis_gui

    logger.debug("Initialising window")

    # Setup the root window
    root = tk.Tk()
    root.minsize(width=800, height=400)
    root.geometry("800x600")
    root.title("Modis Control Panel")
    # Icon
    root.iconbitmap(r"{}/assets/modis.ico".format(file_dir))

    # Setup the notebook
    """notebook = ttk.Notebook(root)
    notebook.grid(column=0, row=0, padx=0, pady=0, sticky="W E N S")

    # Configure stretch ratios
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)
    notebook.columnconfigure(0, weight=1)
    notebook.rowconfigure(0, weight=1)

    # Add tabs
    logger.debug("Adding packages to window")
    notebook.add(
        discord_modis_gui.Frame(notebook, discord_token, discord_client_id),
        text="Discord")
    notebook.add(reddit_modis_gui.Frame(notebook), text="Reddit")
    notebook.add(facebook_modis_gui.Frame(notebook), text="Facebook")"""
    discord = discord_modis_gui.Frame(root, discord_token, discord_client_id)
    discord.grid(column=0, row=0, padx=0, pady=0, sticky="W E N S")
    # Configure stretch ratios
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)
    discord.columnconfigure(0, weight=1)
    discord.rowconfigure(0, weight=1)

    logger.debug("GUI initialised")

    # Run the window UI
    root.mainloop()
790713
def init_db(self):
    '''

    '''

    # Database Setup, use default if uri not provided
    if self.database == 'sqlite':
        db_path = os.path.join(EXPFACTORY_DATA, '%s.db' % EXPFACTORY_SUBID)
        self.database = 'sqlite:///%s' % db_path

    bot.info("Database located at %s" % self.database)
    self.engine = create_engine(self.database, convert_unicode=True)
    self.session = scoped_session(sessionmaker(autocommit=False,
                                               autoflush=False,
                                               bind=self.engine))
    
    Base.query = self.session.query_property()

    # import all modules here that might define models so that
    # they will be registered properly on the metadata.  Otherwise
    # you will have to import them first before calling init_db()
    import expfactory.database.models
    Base.metadata.create_all(bind=self.engine)
    self.Base = Base
516591
def update(connection, silent, hgnc_file_path, hcop_file_path, low_memory):
    """"""
    database.update(connection=connection,
                    silent=silent,
                    hgnc_file_path=hgnc_file_path,
                    hcop_file_path=hcop_file_path,
                    low_memory=low_memory)