Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sot-talos-balance
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
loco-3d
sot-talos-balance
Commits
e6578c9d
Commit
e6578c9d
authored
6 years ago
by
Gabriele Buondonno
Browse files
Options
Downloads
Patches
Plain Diff
Manage verbosity of launch_script
parent
d689d00f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/sot_talos_balance/utils/run_test_utils.py
+23
-11
23 additions, 11 deletions
python/sot_talos_balance/utils/run_test_utils.py
with
23 additions
and
11 deletions
python/sot_talos_balance/utils/run_test_utils.py
+
23
−
11
View file @
e6578c9d
...
...
@@ -11,11 +11,23 @@ from std_srvs.srv import *
from
dynamic_graph_bridge.srv
import
*
from
dynamic_graph_bridge_msgs.srv
import
*
_
runCommandClient
=
rospy
.
ServiceProxy
(
'
run_command
'
,
RunCommand
)
runCommandClient
=
rospy
.
ServiceProxy
(
'
run_command
'
,
RunCommand
)
def
runCommandClient
(
code
):
out
=
_runCommandClient
(
code
)
if
out
.
standardoutput
or
out
.
standarderror
:
def
runVerboseCommandClient
(
code
,
verbosity
=
1
):
"""
Auxiliary function to manage the verbosity of runCommandClient
verbosity = 0: simply execute runCommandClient
verbosity = 1 (default): if runCommandClient returns something on the standard output or standard error, print it
verbosity = 2: print the whole answer returned by runCommandClient
"""
if
verbosity
>
1
:
print
(
code
)
out
=
runCommandClient
(
code
)
if
verbosity
>
1
:
print
(
out
)
elif
verbosity
==
1
and
(
out
.
standardoutput
or
out
.
standarderror
):
print
(
"
command:
"
+
code
)
if
out
.
standardoutput
:
print
(
"
standardoutput:
"
+
out
.
standardoutput
)
...
...
@@ -24,9 +36,13 @@ def runCommandClient(code):
return
out
def
evalCommandClient
(
code
):
"""
Auxiliary function to quickly extract return values from runCommandClient.
This will only work when the result in a plain object data type (such as an in or float) or a string
"""
return
eval
(
runCommandClient
(
code
).
result
)
def
launch_script
(
code
,
title
,
description
=
""
):
def
launch_script
(
code
,
title
,
description
=
""
,
verbosity
=
1
):
raw_input
(
title
+
'
:
'
+
description
)
rospy
.
loginfo
(
title
)
rospy
.
loginfo
(
code
)
...
...
@@ -38,20 +54,16 @@ def launch_script(code,title,description = ""):
codeblock
+=
'
\n
'
+
line
continue
else
:
print
(
codeblock
)
answer
=
runCommandClient
(
str
(
codeblock
))
answer
=
runVerboseCommandClient
(
str
(
codeblock
),
verbosity
)
rospy
.
logdebug
(
answer
)
print
(
answer
)
indenting
=
False
if
line
!=
''
and
line
[
0
]
!=
'
#
'
:
if
line
.
endswith
(
'
:
'
):
indenting
=
True
codeblock
=
line
else
:
# print(line)
answer
=
runCommandClient
(
str
(
line
))
answer
=
runVerboseCommandClient
(
str
(
line
),
verbosity
)
rospy
.
logdebug
(
answer
)
# print(answer)
rospy
.
loginfo
(
"
...done with
"
+
title
)
def
run_test
(
appli
):
...
...
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