author | Stephanie Marcu <stephanie.marcu@logilab.fr> |
Thu, 15 Apr 2010 16:20:20 +0200 | |
branch | stable |
changeset 5285 | 7be5878bc86c |
parent 5165 | e5efbcaa3011 |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
7 |
""" |
0 | 8 |
import os |
9 |
import pwd |
|
10 |
||
11 |
from logilab.common.pytest import PyTester |
|
12 |
||
13 |
def getlogin(): |
|
14 |
"""avoid usinng os.getlogin() because of strange tty / stdin problems |
|
15 |
(man 3 getlogin) |
|
16 |
Another solution would be to use $LOGNAME, $USER or $USERNAME |
|
17 |
""" |
|
18 |
return pwd.getpwuid(os.getuid())[0] |
|
19 |
||
20 |
||
21 |
def update_parser(parser): |
|
22 |
login = getlogin() |
|
23 |
parser.add_option('-r', '--rebuild-database', dest='rebuild_db', |
|
24 |
default=False, action="store_true", |
|
25 |
help="remove tmpdb and rebuilds the test database") |
|
26 |
parser.add_option('-u', '--dbuser', dest='dbuser', action='store', |
|
27 |
default=login, help="database user") |
|
28 |
parser.add_option('-w', '--dbpassword', dest='dbpassword', action='store', |
|
5165
e5efbcaa3011
fixed skeleton help strings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
4212
diff
changeset
|
29 |
default=login, help="database user's password") |
0 | 30 |
parser.add_option('-n', '--dbname', dest='dbname', action='store', |
31 |
default=None, help="database name") |
|
32 |
parser.add_option('--euser', dest='euser', action='store', |
|
5165
e5efbcaa3011
fixed skeleton help strings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
4212
diff
changeset
|
33 |
default=login, help="euser name") |
0 | 34 |
parser.add_option('--epassword', dest='epassword', action='store', |
35 |
default=login, help="euser's password' name") |
|
36 |
return parser |
|
37 |
||
38 |
||
39 |
class CustomPyTester(PyTester): |
|
40 |
def __init__(self, cvg, options): |
|
41 |
super(CustomPyTester, self).__init__(cvg, options) |
|
42 |
if options.rebuild_db: |
|
43 |
os.unlink('tmpdb') |
|
44 |
os.unlink('tmpdb-template') |