[FIX] Don't use the hostname if it is in ('127.0.0.1', 'localhost')

lp bug: https://launchpad.net/bugs/319190 fixed

bzr revid: stephane@tinyerp.com-20090129002310-75wuum4qpx5s8ac4
This commit is contained in:
Stephane Wirtel 2009-01-29 01:23:10 +01:00
parent 2fdc099da6
commit e76c454794
2 changed files with 5 additions and 5 deletions

View File

@ -173,7 +173,7 @@ class db(netsvc.Service):
cmd = ['pg_dump', '--format=c']
if tools.config['db_user']:
cmd.append('--username=' + tools.config['db_user'])
if tools.config['db_host']:
if tools.config['db_host'] and tools.config['db_host'] not in ('127.0.0.1', 'localhost'):
cmd.append('--host=' + tools.config['db_host'])
if tools.config['db_port']:
cmd.append('--port=' + tools.config['db_port'])
@ -184,11 +184,9 @@ class db(netsvc.Service):
data = stdout.read()
res = stdout.close()
if res:
logger.notifyChannel("web-services", netsvc.LOG_ERROR,
'DUMP DB: %s failed\n%s' % (db_name, data))
logger.notifyChannel("web-services", netsvc.LOG_ERROR, 'DUMP DB: %s failed\n%s' % (db_name, data))
raise Exception, "Couldn't dump database"
logger.notifyChannel("web-services", netsvc.LOG_INFO,
'DUMP DB: %s' % (db_name))
logger.notifyChannel("web-services", netsvc.LOG_INFO, 'DUMP DB: %s' % (db_name))
return base64.encodestring(data)
def restore(self, password, db_name, data):

View File

@ -204,6 +204,8 @@ class PoolManager(object):
cls._dsn = ''
for p in ('host', 'port', 'user', 'password'):
cfg = tools.config['db_' + p]
if p == 'host' and cfg in ('127.0.0.1', 'localhost'):
continue
if cfg:
cls._dsn += '%s=%s ' % (p, cfg)
return '%s dbname=%s' % (cls._dsn, db_name)