示例#1
0
def getMWADBConn():
    global g_db_conn
    if (g_db_conn and (not g_db_conn.closed)):
        return g_db_conn

    config = ngamsJobMAN.getConfig()
    confSec = 'MWA DB'
    db_name = config.get(confSec, 'db')
    db_user = config.get(confSec, 'user')
    db_passwd = config.get(confSec, 'password')
    db_host = config.get(confSec, 'host')
    try:
        """
        g_db_conn = psycopg2.connect(database = db_name, user = db_user,
                            password = db_passwd.decode('base64'),
                            host = db_host)
        """
        g_db_conn = psycopg2.connect(database=None,
                                     user=None,
                                     password=''.decode('base64'),
                                     host=None)
        return g_db_conn
    except Exception as e:
        errStr = 'Cannot create MWA DB Connection: %s' % str(e)
        raise Exception(errStr)
示例#2
0
def getExternalArchiveURL(fileId=None):
    """
    Obtain the url of the external archive, which
    could be different based on the fileId. (e.g. EOR data all from Cortex, GEG from ICRAR, etc.)
    This function behaves like a URI resolution service
    """
    # just a dummy implementation for now:
    config = ngamsJobMAN.getConfig()
    return 'http://%s' % config.get('Archive Servers', 'LTA')
示例#3
0
def getLTADBConn():
    global l_db_conn
    if (l_db_conn and (not l_db_conn.closed)):
        return l_db_conn

    config = ngamsJobMAN.getConfig()
    confSec = 'LTA DB'
    ldb_name = config.get(confSec, 'db')
    ldb_user = config.get(confSec, 'user')
    ldb_passwd = config.get(confSec, 'password')
    ldb_host = config.get(confSec, 'host')
    try:
        l_db_conn = psycopg2.connect(database=ldb_name,
                                     user=ldb_user,
                                     password=ldb_passwd.decode('base64'),
                                     host=ldb_host)
        return l_db_conn
    except Exception as e:
        errStr = 'Cannot create LTA DB Connection: %s' % str(e)
        raise Exception(errStr)
示例#4
0
def getFornaxDBConn():
    global f_db_conn
    if (f_db_conn and (not f_db_conn.closed)):
        return f_db_conn

    config = ngamsJobMAN.getConfig()
    confSec = 'NGAS DB'
    fdb_name = config.get(confSec, 'db')
    fdb_user = config.get(confSec, 'user')
    fdb_passwd = config.get(confSec, 'password')
    fdb_host = config.get(confSec, 'host')
    try:
        f_db_conn = psycopg2.connect(database=fdb_name,
                                     user=fdb_user,
                                     password=fdb_passwd.decode('base64'),
                                     host=fdb_host)
        return f_db_conn
    except Exception as e:
        errStr = 'Cannot create Fornax DB Connection: %s' % str(e)
        raise Exception(errStr)
示例#5
0
def getClusterGateway():
    config = ngamsJobMAN.getConfig()
    return config.get('Archive Servers', 'ClusterGateway')