Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Lars Kruse
aura-engine
Commits
7157d90a
Commit
7157d90a
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Method to get database URI.
parent
401392ed
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/base/config.py
+31
-16
31 additions, 16 deletions
libraries/base/config.py
with
31 additions
and
16 deletions
libraries/base/config.py
+
31
−
16
View file @
7157d90a
...
...
@@ -62,27 +62,27 @@ class AuraConfig:
def
set
(
self
,
key
,
value
):
"""
Set
a
property
@type key: string
@param key: The Key
@type value: mixed
@param value: Beliebiger Wert
Set
ter for some specific config
property
.
Args:
key (String): key
default (*): value
"""
try
:
self
.
__dict__
[
key
]
=
int
(
value
)
except
:
self
.
__dict__
[
key
]
=
str
(
value
)
# ------------------------------------------------------------------------------------------ #
def
get
(
self
,
key
,
default
=
None
):
"""
get a loaded property
@type key: string
@param key: Der Key
@type default: mixed
@param default: Beliebiger Wert
"""
Getter for some specific config property.
Args:
key (String): key
default (*): value
"""
if
key
not
in
self
.
__dict__
:
if
default
:
self
.
set
(
key
,
default
)
...
...
@@ -109,21 +109,22 @@ class AuraConfig:
return
self
.
__dict__
[
key
]
# ------------------------------------------------------------------------------------------ #
def
load_config
(
self
):
"""
Set config defaults and load settings from file
:return:
"""
if
not
os
.
path
.
isfile
(
self
.
ini_path
):
self
.
logger
.
critical
(
self
.
ini_path
+
"
not found :(
"
)
sys
.
exit
(
1
)
#
INI einlesen
#
Read the file
f
=
open
(
self
.
ini_path
,
'
r
'
)
ini_str
=
f
.
read
()
f
.
close
()
# Parse the values
config_parser
=
ConfigParser
()
try
:
config_parser
.
read_string
(
ini_str
)
...
...
@@ -136,5 +137,19 @@ class AuraConfig:
v
=
config_parser
.
get
(
section
,
key
).
replace
(
'"'
,
''
).
strip
()
self
.
set
(
key
,
v
)
# Custom overrides
self
.
set
(
"
install_dir
"
,
os
.
path
.
realpath
(
__file__
+
"
../../../..
"
))
self
.
set
(
"
use_test_data
"
,
False
)
\ No newline at end of file
self
.
set
(
"
use_test_data
"
,
False
)
def
get_database_uri
(
self
):
"""
Retrieves the database connection string.
"""
db_name
=
self
.
get
(
"
db_name
"
)
db_user
=
self
.
get
(
"
db_user
"
)
db_pass
=
self
.
get
(
"
db_pass
"
)
db_host
=
self
.
get
(
"
db_host
"
)
db_charset
=
self
.
get
(
"
db_charset
"
,
"
utf8
"
)
return
"
mysql://
"
+
db_user
+
"
:
"
+
db_pass
+
"
@
"
+
db_host
+
"
/
"
+
db_name
+
"
?charset=
"
+
db_charset
\ No newline at end of file
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