server/serverctl.py
branchstable
changeset 4218 deb2dcffb301
parent 4212 ab6573088b4a
child 4252 6c4f109c2b03
equal deleted inserted replaced
4217:bf2811a17a17 4218:deb2dcffb301
    28     """open and return a connection to the system database defined in the
    28     """open and return a connection to the system database defined in the
    29     given server.serverconfig
    29     given server.serverconfig
    30     """
    30     """
    31     from getpass import getpass
    31     from getpass import getpass
    32     from logilab.common.db import get_connection
    32     from logilab.common.db import get_connection
    33     dbhost = source['db-host']
    33     dbhost = source.get('db-host')
    34     if dbname is None:
    34     if dbname is None:
    35         dbname = source['db-name']
    35         dbname = source['db-name']
    36     driver = source['db-driver']
    36     driver = source['db-driver']
    37     print '-> connecting to %s database %s@%s' % (driver, dbname, dbhost or 'localhost'),
    37     print '-> connecting to %s database' % driver,
       
    38     if dbhost:
       
    39         print '%s@%s' % (dbname, dbhost),
       
    40     else:
       
    41         print dbname,
    38     if not verbose or (not special_privs and source.get('db-user')):
    42     if not verbose or (not special_privs and source.get('db-user')):
    39         user = source['db-user']
    43         user = source['db-user']
    40         print 'as', user
    44         print 'as', user
    41         if source.get('db-password'):
    45         if source.get('db-password'):
    42             password = source['db-password']
    46             password = source['db-password']