Exemplo n.º 1
0
def create_db_conf(db_path):
    # create configuration in db
    if not os.path.exists(db_path):
        # create the db first
        from umit.icm.agent.utils import CreateDB
        CreateDB.create(db_path)

    from umit.icm.agent.db import DBKVPHelper
    db_kvp_helper = DBKVPHelper('sqlite')
    db_kvp_helper.connect(db_path)

    db_kvp_helper.write('application|auto_login_swittch', False)
    db_kvp_helper.write('application|auto_update', True)
    db_kvp_helper.write('application|startup_on_boot', True)
    db_kvp_helper.write('application|auto_update_test_mod', True)
    db_kvp_helper.write('application|auto_update', False)
    
    db_kvp_helper.write('logging|log_level', 'INFO')

    db_kvp_helper.write('network|max_speer_num', 10)
    db_kvp_helper.write('network|max_peer_num', 15)
    db_kvp_helper.write('network|max_conn_num', 100)
    db_kvp_helper.write('network|listen_port', 5895)

    db_kvp_helper.write('web|listen_port', 8080)

    db_kvp_helper.write('network|aggregator_url',
                        'http://alpha.openmonitor.org')
    db_kvp_helper.write('application|selected_tests', '')

    db_kvp_helper.close()
Exemplo n.º 2
0
def create_db_conf(db_path):
    # create configuration in db
    if not os.path.exists(db_path):
        # create the db first
        from umit.icm.agent.utils import CreateDB
        CreateDB.create(db_path)

    from umit.icm.agent.db import DBKVPHelper
    db_kvp_helper = DBKVPHelper('sqlite')
    db_kvp_helper.connect(db_path)

    db_kvp_helper.write('application|auto_login_swittch', False)
    db_kvp_helper.write('application|auto_update', True)
    db_kvp_helper.write('application|startup_on_boot', True)
    db_kvp_helper.write('application|auto_update_test_mod', True)
    db_kvp_helper.write('application|auto_update', False)
    
    db_kvp_helper.write('logging|log_level', 'INFO')

    db_kvp_helper.write('network|max_speer_num', 10)
    db_kvp_helper.write('network|max_peer_num', 15)
    db_kvp_helper.write('network|max_conn_num', 100)
    db_kvp_helper.write('network|listen_port', 5895)

    db_kvp_helper.write('web|listen_port', 8080)

    db_kvp_helper.write('network|aggregator_url',
                        'http://alpha.openmonitor.org')
    db_kvp_helper.write('application|selected_tests', '')

    db_kvp_helper.close()
Exemplo n.º 3
0
useFileConf = True
if useFileConf:
    try:
        g_config = FileConfig(CONFIG_PATH)
    except IOError:
        from umit.icm.agent.utils import CreateConf
        CreateConf.create_file_conf(CONFIG_PATH)
        g_config = FileConfig(CONFIG_PATH)
else:
    try:
        g_config = DBConfig(DB_PATH)
    except IOError:
        from umit.icm.agent.utils import CreateConf
        CreateConf.create_db_conf(DB_PATH)
        g_config = DBConfig(DB_PATH)

#----------------------------------------------------------------------
from umit.icm.agent.db import DBHelper

#---------
DB_NAME = g_config.get("database", "name")
DB_PATH = os.path.join(DB_DIR, DB_NAME)

try:
    g_db_helper = DBHelper('sqlite')
    g_db_helper.connect(DB_PATH)
except IOError:
    from umit.icm.agent.utils import CreateDB
    CreateDB.create(DB_PATH)
    g_db_helper.connect(DB_PATH)
useFileConf = True
if useFileConf:
    try:
        g_config = FileConfig(CONFIG_PATH)
    except IOError:
        from umit.icm.agent.utils import CreateConf
        CreateConf.create_file_conf(CONFIG_PATH)
        g_config = FileConfig(CONFIG_PATH)
else:
    try:
        g_config = DBConfig(DB_PATH)
    except IOError:
        from umit.icm.agent.utils import CreateConf
        CreateConf.create_db_conf(DB_PATH)
        g_config = DBConfig(DB_PATH)

#----------------------------------------------------------------------
from umit.icm.agent.db import DBHelper

#---------
DB_NAME = g_config.get("database","name")
DB_PATH = os.path.join(DB_DIR,DB_NAME)

try:
    g_db_helper = DBHelper('sqlite')
    g_db_helper.connect(DB_PATH)
except IOError:
    from umit.icm.agent.utils import CreateDB
    CreateDB.create(DB_PATH)
    g_db_helper.connect(DB_PATH)