示例#1
0
def _load_lsg_credentials():
    """Read Life Science Grid Portal credentials from file and store in os.environ variables."""
    #Get path to credential file
    from divergence import resource_filename
    lsgp_credentials_file = resource_filename(__name__, 'credentials/lsg-portal.cfg')

    # Copy template config file to actual search path when file can not be found
    if not os.path.exists(lsgp_credentials_file):
        shutil.copy(lsgp_credentials_file + '.sample', lsgp_credentials_file)
        logging.info('Copied .sample file to %s', lsgp_credentials_file)

    logging.info('Credentials not found on path: Reading credentials from %s', lsgp_credentials_file)

    #Parse credential file
    from ConfigParser import SafeConfigParser
    parser = SafeConfigParser()
    parser.read(lsgp_credentials_file)
    os.environ['lsg_username'] = parser.defaults()['lsg_username']
    os.environ['lsg_password'] = parser.defaults()['lsg_password']
示例#2
0
def _load_lsg_credentials():
    """Read Life Science Grid Portal credentials from file and store in os.environ variables."""
    #Get path to credential file
    from divergence import resource_filename
    lsgp_credentials_file = resource_filename(__name__,
                                              'credentials/lsg-portal.cfg')

    # Copy template config file to actual search path when file can not be found
    if not os.path.exists(lsgp_credentials_file):
        shutil.copy(lsgp_credentials_file + '.sample', lsgp_credentials_file)
        logging.info('Copied .sample file to %s', lsgp_credentials_file)

    logging.info('Credentials not found on path: Reading credentials from %s',
                 lsgp_credentials_file)

    #Parse credential file
    from ConfigParser import SafeConfigParser
    parser = SafeConfigParser()
    parser.read(lsgp_credentials_file)
    os.environ['lsg_username'] = parser.defaults()['lsg_username']
    os.environ['lsg_password'] = parser.defaults()['lsg_password']
示例#3
0
def _get_root_credentials():
    """Retrieve MySQL credentials from orthomcl.config to an account that is allowed to create new databases."""
    orthomcl_credentials_file = resource_filename(__name__, 'credentials/orthomcl.cfg')

    # Copy template config file to actual search path when file can not be found
    if not os.path.exists(orthomcl_credentials_file):
        shutil.copy(orthomcl_credentials_file + '.sample', orthomcl_credentials_file)
        log.info('Copied .sample file to %s', orthomcl_credentials_file)

    # Parse configuration file
    config = SafeConfigParser()
    config.read(orthomcl_credentials_file)
    host = config.get('mysql', 'host')
    port = config.getint('mysql', 'port')
    user = config.get('mysql', 'user')
    passwd = config.get('mysql', 'pass')

    # Fall back to environment value for password when available
    if passwd == 'pass' and 'mysql_password' in os.environ:
        passwd = os.environ['mysql_password']

    return host, port, user, passwd