Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DetectorWriteSim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
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
EWMSCP
DetectorWriteSim
Commits
9b38c15c
Commit
9b38c15c
authored
1 year ago
by
Michael Reuscher
Browse files
Options
Downloads
Patches
Plain Diff
SSH multi hosts works fine
parent
a584c0b6
No related branches found
No related tags found
1 merge request
!4
Python driver and data analysis part
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
simrunner/simrunner.py
+42
-42
42 additions, 42 deletions
simrunner/simrunner.py
with
42 additions
and
42 deletions
simrunner/simrunner.py
+
42
−
42
View file @
9b38c15c
...
...
@@ -81,47 +81,48 @@ def create_event_list():
return
e_list
def
run_sim
(
e_list
,
d_path
,
sim_path
,
st_path
):
def
run_sim
(
e_list
,
d_path
,
sim_path
,
main_path
):
stat_path
=
os
.
path
.
join
(
main_path
,
"
statistics
"
)
os
.
makedirs
(
stat_path
,
mode
=
0o777
,
exist_ok
=
True
)
for
event
in
e_list
:
folder_name
=
event
[
-
1
]
stat_file_name
=
"
statistics_
"
+
folder_name
output_path
=
os
.
path
.
join
(
d_path
,
folder_name
)
relativ_path_stat
=
os
.
path
.
join
(
st_path
,
stat_file_name
+
"
.dat
"
)
if
not
args
.
hosts
:
if
args
.
hosts
:
# Remote execution on multiple machines with specified user
for
host
in
args
.
hosts
:
ssh_target
=
f
'
{
args
.
user
}
@
{
host
}
'
remote_output
=
make_folders_remote
(
test_data_path
,
output_path
,
ssh_target
,
host
)
event
[
-
1
]
=
remote_output
command
=
[
"
ssh
"
,
ssh_target
,
sim_path
]
+
event
result
=
subprocess
.
run
(
command
,
capture_output
=
True
,
text
=
True
)
output
=
result
.
stdout
errors
=
result
.
stderr
terminal_output
(
output
,
errors
,
result
.
returncode
)
relativ_path_stat
=
os
.
path
.
join
(
stat_path
,
stat_file_name
+
f
"
_
{
host
}
.dat
"
)
with
open
(
relativ_path_stat
,
"
w
"
)
as
stat_file
:
stat_file
.
write
(
output
)
print
(
f
"
{
folder_name
}
_
{
host
}
done!
"
)
# Local execution
else
:
make_folders_lokal
(
test_data_path
,
output_path
)
event
[
-
1
]
=
output_path
arguments
=
event
output
,
errors
,
return_code
=
start_process
(
sim_path
,
arguments
,
test_data_path
,
output_path
)
print
(
output
)
with
open
(
relativ_path_stat
,
"
w
"
)
as
stat_file
:
stat_file
.
write
(
output
)
print
(
errors
)
if
return_code
>
0
:
print
(
"
return code:
"
,
return_code
)
print
(
folder_name
+
"
done!
"
)
def
start_process
(
program_path
,
arguments
,
test_path
,
output_path
):
if
args
.
hosts
:
# Remote execution on multiple machines with specified user
output
=
""
errors
=
""
result
=
""
for
host
in
args
.
hosts
:
ssh_target
=
f
'
{
args
.
user
}
@
{
host
}
'
remote_output
=
make_folders_remote
(
test_path
,
output_path
,
ssh_target
,
host
)
arguments
[
-
1
]
=
remote_output
command
=
[
"
ssh
"
,
ssh_target
,
program_path
]
+
arguments
command
=
[
sim_path
]
+
event
result
=
subprocess
.
run
(
command
,
capture_output
=
True
,
text
=
True
)
output
=
result
.
stdout
errors
=
result
.
stderr
return
output
,
errors
,
result
.
returncode
else
:
command
=
[
program_path
]
+
arguments
result
=
subprocess
.
run
(
command
,
capture_output
=
True
,
text
=
True
)
output
=
result
.
stdout
errors
=
result
.
stderr
return
output
,
errors
,
result
.
returncode
terminal_output
(
output
,
errors
,
result
.
returncode
)
relativ_path_stat
=
os
.
path
.
join
(
stat_path
,
stat_file_name
+
"
.dat
"
)
with
open
(
relativ_path_stat
,
"
w
"
)
as
stat_file
:
stat_file
.
write
(
output
)
print
(
f
"
{
folder_name
}
done!
"
)
def
terminal_output
(
output
,
errors
,
return_code
):
print
(
output
)
print
(
errors
)
if
return_code
>
0
:
print
(
"
return code:
"
,
return_code
)
def
make_folders_lokal
(
test_path
,
output_path
):
...
...
@@ -138,11 +139,12 @@ def make_folders_remote(test_path, output_path, ssh_target, host):
return
host_output
def
pull_data
(
remote_path
,
lokal_path
):
for
host
in
args
.
hosts
:
ssh_target
=
f
'
{
args
.
user
}
@
{
host
}
'
scp_cmd
=
f
'
scp -r
{
ssh_target
}
:
{
remote_path
}
{
lokal_path
}
'
subprocess
.
run
(
scp_cmd
,
shell
=
True
,
check
=
True
)
def
pull_data
(
source_path
,
desti_path
):
if
args
.
hosts
:
for
host
in
args
.
hosts
:
ssh_target
=
f
'
{
args
.
user
}
@
{
host
}
'
scp_cmd
=
f
'
scp -r
{
ssh_target
}
:
{
source_path
}
{
desti_path
}
'
subprocess
.
run
(
scp_cmd
,
shell
=
True
,
check
=
True
)
# --- MAIN ---
...
...
@@ -151,19 +153,17 @@ def pull_data(remote_path, lokal_path):
args
=
parse_arguments
()
# Setup all paths and folders
main_folder
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
main_folder
_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
simulation_path
=
args
.
sim
data_path
=
os
.
path
.
join
(
args
.
data
,
"
output
"
)
test_data_path
=
os
.
path
.
join
(
args
.
data
,
"
test_data
"
)
stat_path
=
os
.
path
.
join
(
main_folder
,
"
statistics
"
)
os
.
makedirs
(
stat_path
,
mode
=
0o777
,
exist_ok
=
True
)
# Setup arguments for Sim
event_list
=
create_event_list
()
# Run detectorSimulation
run_sim
(
event_list
,
data_path
,
simulation_path
,
stat
_path
)
run_sim
(
event_list
,
data_path
,
simulation_path
,
main_folder
_path
)
# Pull data for visualizer
pull_data
(
data_path
,
main_folder
)
pull_data
(
data_path
,
main_folder
_path
)
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