Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
allocbench
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
allocbench
Commits
f63ac8af
Commit
f63ac8af
authored
6 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
add function to prefix cmd with abspath using whereis
parent
53d42fdc
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
src/util.py
+18
-0
18 additions, 0 deletions
src/util.py
with
18 additions
and
0 deletions
src/util.py
+
18
−
0
View file @
f63ac8af
import
os
import
os
import
subprocess
import
sys
import
sys
import
src.globalvars
import
src.globalvars
...
@@ -23,6 +24,23 @@ def find_cmd(cmd):
...
@@ -23,6 +24,23 @@ def find_cmd(cmd):
return
None
return
None
def
prefix_cmd_with_abspath
(
cmd
):
"""
Prefix cmd with the abspath of the first word
Usefull if cmd should be executed by the loader of a custom glibc.
"""
binary_end
=
cmd
.
find
(
"
"
)
binary_end
=
None
if
binary_end
==
-
1
else
binary_end
cmd_start
=
len
(
cmd
)
if
binary_end
==
None
else
binary_end
binary_abspath
=
subprocess
.
run
([
"
whereis
"
,
cmd
[
0
:
binary_end
]],
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
True
).
stdout
.
split
()[
1
]
return
binary_abspath
+
"
"
+
cmd
[
binary_end
:]
def
allocbench_msg
(
color
,
*
objects
,
sep
=
'
'
,
end
=
'
\n
'
,
file
=
sys
.
stdout
):
def
allocbench_msg
(
color
,
*
objects
,
sep
=
'
'
,
end
=
'
\n
'
,
file
=
sys
.
stdout
):
if
src
.
globalvars
.
verbosity
<
0
:
if
src
.
globalvars
.
verbosity
<
0
:
return
return
...
...
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