Skip to content
Snippets Groups Projects
Commit 9d670728 authored by Michael Reuscher's avatar Michael Reuscher
Browse files

new simrunner fix

parent d023d059
No related branches found
No related tags found
1 merge request!4Python driver and data analysis part
......@@ -8,12 +8,13 @@ import getpass
def parse_arguments():
main_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
default_sim_path = os.path.join(os.path.dirname(__file__), "../build/src/detsim")
current_user = getpass.getuser()
parser = argparse.ArgumentParser(description='Run a subprocess locally or on remote machines.')
parser.add_argument('-s', '--sim', type=str, default=default_sim_path,
help='Path to the detector simulation script default: ./')
parser.add_argument('-H', '--hosts', nargs='+', type=str,
help='Host addresses of remote machines default: lokal')
parser.add_argument('-u', '--user', type=str,
parser.add_argument('-u', '--user', type=str, default=current_user,
help='Username for SSH connection default: current user')
parser.add_argument('-f', '--function', choices=['various', 'long'], default='various',
help='Choose function to execute default: various')
......@@ -102,27 +103,15 @@ def run_sim(e_list, d_path, sim_path, st_path):
def start_process(program_path, arguments):
if args.hosts:
if args.user:
# Remote execution on multiple machines with specified user
for host in args.hosts:
ssh_command = f'{args.user}@{host}'
command = ["ssh", ssh_command] + arguments
print(command)
result = subprocess.run(command, capture_output=True, text=True)
output = result.stdout
errors = result.stderr
return output, errors, result.returncode
else:
# Remote execution on multiple machines with current user
current_user = getpass.getuser()
for host in args.hosts:
ssh_command = f'{current_user}@{host}'
command = ["ssh", ssh_command] + arguments
print(command)
result = subprocess.run(command, capture_output=True, text=True)
output = result.stdout
errors = result.stderr
return output, errors, result.returncode
# Remote execution on multiple machines with specified user
for host in args.hosts:
ssh_command = f'{args.user}@{host}'
command = ["ssh", ssh_command, program_path] + arguments
print(command)
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment