Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AMBS
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
Container registry
Model registry
Operate
Environments
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
esde
machine-learning
AMBS
Commits
0f3fb4e3
Commit
0f3fb4e3
authored
4 years ago
by
Michael Langguth
Browse files
Options
Downloads
Patches
Plain Diff
Integrate method which retireves the values of variables declared in a Bash-script.
parent
c1708e6b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
video_prediction_tools/config_runscripts/config_utils.py
+26
-0
26 additions, 0 deletions
video_prediction_tools/config_runscripts/config_utils.py
with
26 additions
and
0 deletions
video_prediction_tools/config_runscripts/config_utils.py
+
26
−
0
View file @
0f3fb4e3
...
...
@@ -168,6 +168,32 @@ class Config_runscript_base:
stat
=
True
return
stat
@staticmethod
#
# --------------------------------------------------------------------------------------------------------
#
def
get_variable_from_runscript
(
runscript_file
,
script_variable
):
'''
Search for the declaration of variable in a Shell script and returns its value.
:param runscript_file: path to shell script/runscript
:param script_variable: name of variable which is declared in shell script at hand
:return: value of script_variable
'''
script_variable
=
script_variable
+
"
=
"
found
=
False
with
open
(
runscript_file
)
as
runscript
:
# Skips text before the beginning of the interesting block:
for
line
in
runscript
:
if
script_variable
in
line
:
var_value
=
(
line
.
strip
(
script_variable
)).
replace
(
"
\n
"
,
""
)
found
=
True
break
if
not
found
:
raise
Exception
(
"
Could not find declaration of
'"
+
script_variable
+
"'
in
'"
+
runscript_file
+
"'
.
"
)
return
var_value
#
# -----------------------------------------------------------------------------------
#
...
...
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