1 """cubicweb-ctl commands and command handlers specific to the server.serverconfig |
1 """cubicweb-ctl commands and command handlers specific to the server.serverconfig |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 __docformat__ = 'restructuredtext en' |
8 __docformat__ = 'restructuredtext en' |
9 |
9 |
27 """open and return a connection to the system database defined in the |
27 """open and return a connection to the system database defined in the |
28 given server.serverconfig |
28 given server.serverconfig |
29 """ |
29 """ |
30 from getpass import getpass |
30 from getpass import getpass |
31 from logilab.common.db import get_connection |
31 from logilab.common.db import get_connection |
32 dbhost = source['db-host'] |
32 dbhost = source.get('db-host') |
33 if dbname is None: |
33 if dbname is None: |
34 dbname = source['db-name'] |
34 dbname = source['db-name'] |
35 driver = source['db-driver'] |
35 driver = source['db-driver'] |
36 print '-> connecting to %s database %s@%s' % (driver, dbname, dbhost or 'localhost'), |
36 print '-> connecting to %s database' % driver, |
|
37 if dbhost: |
|
38 print '%s@%s' % (dbname, dbhost), |
|
39 else: |
|
40 print dbname, |
37 if not verbose or (not special_privs and source.get('db-user')): |
41 if not verbose or (not special_privs and source.get('db-user')): |
38 user = source['db-user'] |
42 user = source['db-user'] |
39 print 'as', user |
43 print 'as', user |
40 if source.get('db-password'): |
44 if source.get('db-password'): |
41 password = source['db-password'] |
45 password = source['db-password'] |