Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
d3596ac2
Commit
d3596ac2
authored
9 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Task #8899: Let DBCredentials::set accept Credentials objects
parent
ff7b0a18
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCS/PyCommon/dbcredentials.py
+25
-4
25 additions, 4 deletions
LCS/PyCommon/dbcredentials.py
with
25 additions
and
4 deletions
LCS/PyCommon/dbcredentials.py
+
25
−
4
View file @
d3596ac2
...
...
@@ -84,7 +84,25 @@ class Credentials:
class
DBCredentials
:
def
__init__
(
self
,
filepatterns
=
None
):
"""
Read database credentials from all configuration files matched by any of the patterns
Read database credentials from all configuration files matched by any of the patterns.
By default, the following files are read:
$LOFARROOT/etc/dbcredentials/*.ini
~/.lofar/dbcredentials/*.ini
The configuration files allow for any number of database sections:
[database:OTDB]
type = postgres # postgres, mysql, oracle, sqlite
host = localhost
port = 0 # 0 = use default port
user = paulus
password = boskabouter
database = LOFAR_4
These database credentials can subsequently be queried under their
symbolic name (
"
OTDB
"
in the example).
"""
if
filepatterns
is
None
:
filepatterns
=
[
...
...
@@ -136,9 +154,12 @@ class DBCredentials:
pass
# set or override credentials
for
k
,
v
in
credentials
.
iteritems
():
self
.
config
.
set
(
section
,
k
,
v
)
self
.
config
.
set
(
section
,
"
type
"
,
credentials
.
type
)
self
.
config
.
set
(
section
,
"
host
"
,
credentials
.
host
)
self
.
config
.
set
(
section
,
"
port
"
,
str
(
credentials
.
port
))
self
.
config
.
set
(
section
,
"
user
"
,
credentials
.
user
)
self
.
config
.
set
(
section
,
"
password
"
,
credentials
.
password
)
self
.
config
.
set
(
section
,
"
database
"
,
credentials
.
database
)
def
list
(
self
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment