author | Rémi Cardona <remi.cardona@logilab.fr> |
Mon, 20 Oct 2014 12:50:04 +0200 | |
changeset 10030 | e19c322ede4b |
parent 9928 | 0d831b40fa48 |
child 9990 | c84ad981fc4a |
permissions | -rw-r--r-- |
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5324
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
18 |
"""some utilities for cubicweb command line tools""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
21 |
||
2397
cdedc2a32b06
[shell] move toolsutils.confirm() to logilab.common.shellutils
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
22 |
# XXX move most of this in logilab.common (shellutils ?) |
cdedc2a32b06
[shell] move toolsutils.confirm() to logilab.common.shellutils
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2395
diff
changeset
|
23 |
|
0 | 24 |
import os, sys |
4554
2279ba039494
use subprocess instead of os.popen to run diff
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
4212
diff
changeset
|
25 |
import subprocess |
3115
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
26 |
from os import listdir, makedirs, environ, chmod, walk, remove |
0 | 27 |
from os.path import exists, join, abspath, normpath |
28 |
||
3115
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
29 |
try: |
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
30 |
from os import symlink |
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
31 |
except ImportError: |
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
32 |
def symlink(*args): |
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
33 |
raise NotImplementedError |
29262ba01464
minimal steps to have cw running on windows
Aurélien Campéas
parents:
2615
diff
changeset
|
34 |
|
6138
65f5e488f983
update to lgc.clcommands 0.51 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
35 |
from logilab.common.clcommands import Command as BaseCommand |
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2476
diff
changeset
|
36 |
from logilab.common.shellutils import ASK |
0 | 37 |
|
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
38 |
from cubicweb import warning # pylint: disable=E0611 |
0 | 39 |
from cubicweb import ConfigurationError, ExecutionError |
40 |
||
2790
968108e16066
move underline_title to toolsutils
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2615
diff
changeset
|
41 |
def underline_title(title, car='-'): |
968108e16066
move underline_title to toolsutils
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2615
diff
changeset
|
42 |
return title+'\n'+(car*len(title)) |
968108e16066
move underline_title to toolsutils
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2615
diff
changeset
|
43 |
|
0 | 44 |
def iter_dir(directory, condition_file=None, ignore=()): |
45 |
"""iterate on a directory""" |
|
46 |
for sub in listdir(directory): |
|
47 |
if sub in ('CVS', '.svn', '.hg'): |
|
48 |
continue |
|
49 |
if condition_file is not None and \ |
|
50 |
not exists(join(directory, sub, condition_file)): |
|
51 |
continue |
|
52 |
if sub in ignore: |
|
53 |
continue |
|
54 |
yield sub |
|
55 |
||
56 |
def create_dir(directory): |
|
57 |
"""create a directory if it doesn't exist yet""" |
|
58 |
try: |
|
59 |
makedirs(directory) |
|
7155
4bab50b02927
[cwctl] refactor ui messages aiming for consistency and simplicity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6495
diff
changeset
|
60 |
print '-> created directory %s' % directory |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7896
diff
changeset
|
61 |
except OSError as ex: |
0 | 62 |
import errno |
63 |
if ex.errno != errno.EEXIST: |
|
64 |
raise |
|
7155
4bab50b02927
[cwctl] refactor ui messages aiming for consistency and simplicity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6495
diff
changeset
|
65 |
print '-> no need to create existing directory %s' % directory |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
66 |
|
0 | 67 |
def create_symlink(source, target): |
68 |
"""create a symbolic link""" |
|
69 |
if exists(target): |
|
70 |
remove(target) |
|
71 |
symlink(source, target) |
|
72 |
print '[symlink] %s <-- %s' % (target, source) |
|
73 |
||
74 |
def create_copy(source, target): |
|
75 |
import shutil |
|
76 |
print '[copy] %s <-- %s' % (target, source) |
|
77 |
shutil.copy2(source, target) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
78 |
|
0 | 79 |
def rm(whatever): |
80 |
import shutil |
|
81 |
shutil.rmtree(whatever) |
|
2395
e3093fc12a00
[cw-ctl] improve dialog messages
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2388
diff
changeset
|
82 |
print '-> removed %s' % whatever |
0 | 83 |
|
84 |
def show_diffs(appl_file, ref_file, askconfirm=True): |
|
85 |
"""interactivly replace the old file with the new file according to |
|
86 |
user decision |
|
87 |
""" |
|
88 |
import shutil |
|
4554
2279ba039494
use subprocess instead of os.popen to run diff
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
4212
diff
changeset
|
89 |
pipe = subprocess.Popen(['diff', '-u', appl_file, ref_file], stdout=subprocess.PIPE) |
2279ba039494
use subprocess instead of os.popen to run diff
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
4212
diff
changeset
|
90 |
diffs = pipe.stdout.read() |
0 | 91 |
if diffs: |
92 |
if askconfirm: |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
93 |
print |
0 | 94 |
print diffs |
5324
449cc4fa9c42
[migration] makes Yes the default answer to replace configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4721
diff
changeset
|
95 |
action = ASK.ask('Replace ?', ('Y', 'n', 'q'), 'Y').lower() |
0 | 96 |
else: |
97 |
action = 'y' |
|
98 |
if action == 'y': |
|
99 |
try: |
|
100 |
shutil.copyfile(ref_file, appl_file) |
|
101 |
except IOError: |
|
102 |
os.system('chmod a+w %s' % appl_file) |
|
103 |
shutil.copyfile(ref_file, appl_file) |
|
104 |
print 'replaced' |
|
105 |
elif action == 'q': |
|
106 |
sys.exit(0) |
|
107 |
else: |
|
108 |
copy_file = appl_file + '.default' |
|
109 |
copy = file(copy_file, 'w') |
|
110 |
copy.write(open(ref_file).read()) |
|
111 |
copy.close() |
|
112 |
print 'keep current version, the new file has been written to', copy_file |
|
113 |
else: |
|
114 |
print 'no diff between %s and %s' % (appl_file, ref_file) |
|
115 |
||
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5021
diff
changeset
|
116 |
SKEL_EXCLUDE = ('*.py[co]', '*.orig', '*~', '*_flymake.py') |
0 | 117 |
def copy_skeleton(skeldir, targetdir, context, |
5184
955ee1b24756
[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5021
diff
changeset
|
118 |
exclude=SKEL_EXCLUDE, askconfirm=False): |
0 | 119 |
import shutil |
120 |
from fnmatch import fnmatch |
|
121 |
skeldir = normpath(skeldir) |
|
122 |
targetdir = normpath(targetdir) |
|
123 |
for dirpath, dirnames, filenames in walk(skeldir): |
|
124 |
tdirpath = dirpath.replace(skeldir, targetdir) |
|
125 |
create_dir(tdirpath) |
|
126 |
for fname in filenames: |
|
127 |
if any(fnmatch(fname, pat) for pat in exclude): |
|
128 |
continue |
|
129 |
fpath = join(dirpath, fname) |
|
130 |
if 'CUBENAME' in fname: |
|
131 |
tfpath = join(tdirpath, fname.replace('CUBENAME', context['cubename'])) |
|
132 |
elif 'DISTNAME' in fname: |
|
133 |
tfpath = join(tdirpath, fname.replace('DISTNAME', context['distname'])) |
|
134 |
else: |
|
135 |
tfpath = join(tdirpath, fname) |
|
136 |
if fname.endswith('.tmpl'): |
|
137 |
tfpath = tfpath[:-5] |
|
138 |
if not askconfirm or not exists(tfpath) or \ |
|
2615
1ea41b7c0836
F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2476
diff
changeset
|
139 |
ASK.confirm('%s exists, overwrite?' % tfpath): |
1138
22f634977c95
make pylint happy, fix some bugs on the way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
140 |
fill_templated_file(fpath, tfpath, context) |
0 | 141 |
print '[generate] %s <-- %s' % (tfpath, fpath) |
142 |
elif exists(tfpath): |
|
143 |
show_diffs(tfpath, fpath, askconfirm) |
|
144 |
else: |
|
145 |
shutil.copyfile(fpath, tfpath) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
146 |
|
0 | 147 |
def fill_templated_file(fpath, tfpath, context): |
148 |
fobj = file(tfpath, 'w') |
|
149 |
templated = file(fpath).read() |
|
150 |
fobj.write(templated % context) |
|
151 |
fobj.close() |
|
152 |
||
153 |
def restrict_perms_to_user(filepath, log=None): |
|
154 |
"""set -rw------- permission on the given file""" |
|
155 |
if log: |
|
7155
4bab50b02927
[cwctl] refactor ui messages aiming for consistency and simplicity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6495
diff
changeset
|
156 |
log('set permissions to 0600 for %s', filepath) |
0 | 157 |
else: |
7155
4bab50b02927
[cwctl] refactor ui messages aiming for consistency and simplicity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6495
diff
changeset
|
158 |
print '-> set permissions to 0600 for %s' % filepath |
0 | 159 |
chmod(filepath, 0600) |
160 |
||
7301
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
161 |
def read_config(config_file, raise_if_unreadable=False): |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
162 |
"""read some simple configuration from `config_file` and return it as a |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
163 |
dictionary. If `raise_if_unreadable` is false (the default), an empty |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
164 |
dictionary will be returned if the file is inexistant or unreadable, else |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
165 |
:exc:`ExecutionError` will be raised. |
0 | 166 |
""" |
167 |
from logilab.common.fileutils import lines |
|
168 |
config = current = {} |
|
169 |
try: |
|
170 |
for line in lines(config_file, comments='#'): |
|
171 |
try: |
|
172 |
option, value = line.split('=', 1) |
|
173 |
except ValueError: |
|
174 |
option = line.strip().lower() |
|
175 |
if option[0] == '[': |
|
176 |
# start a section |
|
177 |
section = option[1:-1] |
|
8697
574bb05e40a4
[toward py3k] rewrite has_key() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8695
diff
changeset
|
178 |
assert section not in config, \ |
0 | 179 |
'Section %s is defined more than once' % section |
180 |
config[section] = current = {} |
|
181 |
continue |
|
7896
4c954e1e73ef
[lint] remove uses of "print >> sys.stderr" (closes #1908571)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7879
diff
changeset
|
182 |
sys.stderr.write('ignoring malformed line\n%r\n' % line) |
0 | 183 |
continue |
184 |
option = option.strip().replace(' ', '_') |
|
185 |
value = value.strip() |
|
186 |
current[option] = value or None |
|
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7896
diff
changeset
|
187 |
except IOError as ex: |
7301
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
188 |
if raise_if_unreadable: |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
189 |
raise ExecutionError('%s. Are you logged with the correct user ' |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
190 |
'to use this instance?' % ex) |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
191 |
else: |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
192 |
warning('missing or non readable configuration file %s (%s)', |
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7155
diff
changeset
|
193 |
config_file, ex) |
0 | 194 |
return config |
195 |
||
196 |
||
197 |
_HDLRS = {} |
|
198 |
||
199 |
class metacmdhandler(type): |
|
200 |
def __new__(mcs, name, bases, classdict): |
|
201 |
cls = super(metacmdhandler, mcs).__new__(mcs, name, bases, classdict) |
|
202 |
if getattr(cls, 'cfgname', None) and getattr(cls, 'cmdname', None): |
|
203 |
_HDLRS.setdefault(cls.cmdname, []).append(cls) |
|
204 |
return cls |
|
205 |
||
206 |
||
207 |
class CommandHandler(object): |
|
208 |
"""configuration specific helper for cubicweb-ctl commands""" |
|
209 |
__metaclass__ = metacmdhandler |
|
210 |
def __init__(self, config): |
|
211 |
self.config = config |
|
212 |
||
213 |
class Command(BaseCommand): |
|
214 |
"""base class for cubicweb-ctl commands""" |
|
215 |
||
216 |
def config_helper(self, config, required=True, cmdname=None): |
|
217 |
if cmdname is None: |
|
218 |
cmdname = self.name |
|
219 |
for helpercls in _HDLRS.get(cmdname, ()): |
|
220 |
if helpercls.cfgname == config.name: |
|
221 |
return helpercls(config) |
|
222 |
if config.name == 'all-in-one': |
|
223 |
for helpercls in _HDLRS.get(cmdname, ()): |
|
224 |
if helpercls.cfgname == 'repository': |
|
225 |
return helpercls(config) |
|
226 |
if required: |
|
227 |
msg = 'No helper for command %s using %s configuration' % ( |
|
228 |
cmdname, config.name) |
|
229 |
raise ConfigurationError(msg) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
230 |
|
0 | 231 |
def fail(self, reason): |
232 |
print "command failed:", reason |
|
233 |
sys.exit(1) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
234 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
235 |
|
0 | 236 |
CONNECT_OPTIONS = ( |
237 |
("user", |
|
238 |
{'short': 'u', 'type' : 'string', 'metavar': '<user>', |
|
239 |
'help': 'connect as <user> instead of being prompted to give it.', |
|
240 |
} |
|
241 |
), |
|
242 |
("password", |
|
243 |
{'short': 'p', 'type' : 'password', 'metavar': '<password>', |
|
244 |
'help': 'automatically give <password> for authentication instead of \ |
|
245 |
being prompted to give it.', |
|
246 |
}), |
|
247 |
("host", |
|
248 |
{'short': 'H', 'type' : 'string', 'metavar': '<hostname>', |
|
541
0d75cfe50f83
fix default value of pyro ns host
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
249 |
'default': None, |
0 | 250 |
'help': 'specify the name server\'s host name. Will be detected by \ |
251 |
broadcast if not provided.', |
|
252 |
}), |
|
253 |
) |
|
254 |
||
255 |
def config_connect(appid, optconfig): |
|
256 |
from cubicweb.dbapi import connect |
|
257 |
from getpass import getpass |
|
258 |
user = optconfig.user |
|
259 |
if not user: |
|
260 |
user = raw_input('login: ') |
|
261 |
password = optconfig.password |
|
262 |
if not password: |
|
263 |
password = getpass('password: ') |
|
2388
fddb0fd11321
[api] update dbapi.connect() calls to match new prototype (user parameter is now named login)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
264 |
return connect(login=user, password=password, host=optconfig.host, database=appid) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1138
diff
changeset
|
265 |