Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
178de835
Commit
178de835
authored
5 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Restored configuration cache, broken by commit
c32f9657
parent
1cf8c911
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
utils.py
+23
-14
23 additions, 14 deletions
utils.py
with
23 additions
and
14 deletions
utils.py
+
23
−
14
View file @
178de835
...
...
@@ -20,6 +20,8 @@ DEFAULT_CONF_PATH = "global-conf.sh"
AUTO_CONF_PATH
=
"
auto-generated-conf.sh
"
CONF_PATH
=
"
conf.sh
"
_conf_cache
=
None
def
log
(
text
:
str
,
error
:
bool
=
False
):
"""
Output log message to stout or stderr.
...
...
@@ -27,7 +29,7 @@ def log(text: str, error: bool = False):
:param text: Message to log
:type text: str
:param error: Wether it should output to stderr or not, defaults to False
:
param
error: bool, optional
:
type
error: bool, optional
"""
fo
=
sys
.
stderr
if
error
else
sys
.
stdout
...
...
@@ -93,9 +95,9 @@ def exec_cmd(cmd: Any, log_output: bool = True, get_output: bool = True) -> tupl
:param cmd: Command to run
:type cmd: Any
:param log_output: Wether to log output or not, defaults to True
:
param
log_output: bool, optional
:
type
log_output: bool, optional
:param get_output: Wether to return output or not, defaults to True
:
param
get_output: bool, optional
:
type
get_output: bool, optional
:return: Return code and output
:rtype: tuple
"""
...
...
@@ -133,7 +135,7 @@ def check_cmd(cmd: Any, log_output: bool = False) -> int:
:param cmd: Command to execute
:type cmd: Any
:param log_output: Wether to log output or not, defaults to False
:
param
log_output: bool, optional
:
type
log_output: bool, optional
:return: Return code
:rtype: int
"""
...
...
@@ -192,6 +194,8 @@ def load_conf() -> dict:
log
(
"
Perhaps you forget to change the configuration.
"
)
log
(
"
Path of configuration file: %s
"
%
str
(
Path
(
base_dir
,
CONF_PATH
)))
log
(
"
Perhaps you want to quit this script to change the configuration?
\n
"
)
global
_conf_cache
_conf_cache
=
conf
return
conf
...
...
@@ -201,14 +205,16 @@ def get_conf(name: str, default: str = None) -> str:
:param name: Parameter name
:type name: str
:param default: Default parameter value, defaults to None
:
param
default: str, optional
:
type
default: str, optional
:return: Parameter value
:rtype: str
"""
conf
=
load_conf
()
global
_conf_cache
if
_conf_cache
is
None
:
load_conf
()
return
conf
.
get
(
name
,
default
)
return
_
conf
_cache
.
get
(
name
,
default
)
def
set_conf
(
key
:
str
,
value
:
str
,
override
:
bool
=
False
)
->
bool
:
...
...
@@ -219,7 +225,7 @@ def set_conf(key: str, value: str, override: bool = False) -> bool:
:param value: Option value
:type value: str
:param override: Wether to override the option if it already exists, defaults to False
:
param
override: bool, optional
:
type
override: bool, optional
:return: True if the option have changed, False otherwise
:rtype: bool
"""
...
...
@@ -238,15 +244,18 @@ def set_conf(key: str, value: str, override: bool = False) -> bool:
conf
=
regex
.
sub
(
"
{}=
'
{}
'"
.
format
(
key
.
upper
(),
str
(
value
)),
conf
)
with
open
(
conf_path
,
"
w
"
)
as
conf_fh
:
conf_fh
.
write
(
conf
)
return
True
success
=
True
elif
not
match
:
# add option
with
open
(
conf_path
,
"
a
"
)
as
conf_fh
:
conf_fh
.
write
(
"
\n
{}=
'
{}
'
\n
"
.
format
(
key
.
upper
(),
str
(
value
)))
return
True
success
=
True
else
:
# no match or no override
return
False
success
=
False
# reload conf
load_conf
()
return
success
def
run_commands
(
cmds
:
list
):
...
...
@@ -404,11 +413,11 @@ def mkcert(
:param domains: Domains for which the certificates will be self-signed
:type domains: list
:param ecc: Wether to use Elliptic Curve cryptography or not, defaults to True, if Fasle RSA is used
:
param
ecc: bool, optional
:
type
ecc: bool, optional
:param days: Validity lifetime of the certificate, defaults to 3650
:
param
days: int, optional
:
type
days: int, optional
:param config_tpl: OpenSSL config file template, defaults to OPENSSL_CONFIG_TEMPLATE
:
param
config_tpl: str, optional
:
type
config_tpl: str, optional
"""
# create certs dir
...
...
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