in src/main/scripts/launcher.py [0:0]
def launch(global_config, study_config, sync, java_path, mode='', jar_folder=None, verbose=False, master=False):
"""
Entry point to workflow launching
"""
if verbose:
logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)
else:
logging.basicConfig(format=LOG_FORMAT)
if not jar_folder:
if os.environ.get('FONDA_HOME') is not None:
jar_folder = os.environ['FONDA_HOME'] if str(jar_folder).endswith("/") \
else os.environ['FONDA_HOME'] + '/'
else:
jar_folder = "{}/build/libs/".format(Path(__file__).parent.parent.parent.parent.absolute())
if not os.path.isfile('{}fonda-{}.jar'.format(jar_folder, Launcher.FONDA_VERSION)):
jar_folder = "{}/".format(Path(__file__).parent.parent.parent.absolute())
if not os.path.isfile('{}fonda-{}.jar'.format(jar_folder, Launcher.FONDA_VERSION)):
logging.error('Jar file was not found! Please put the jar file in a folder ' + jar_folder)
sys.exit(2)
elif jar_folder is not None and not str(jar_folder).endswith("/"):
jar_folder += "/"
sync = '-sync' if sync is None or sync == 'true' else ''
master_flag = '-master' if master else ''
cmd = "{} -jar {}fonda-{}.jar -global_config {} -study_config {} {} {} {} " \
.format(java_path, jar_folder, Launcher.FONDA_VERSION, global_config, study_config, sync, mode, master_flag)
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
output = proc.stdout.readline().decode()
if output == '' and proc.poll() is not None:
break
if output:
logging.debug(output.rstrip())
exit_code = proc.wait()
if exit_code != 0:
exec_err_msg = 'Command \'%s\' execution has failed.\n Exit code: %s' % (cmd, exit_code)
raise RuntimeError(exec_err_msg)
logging.debug('Exit code: ' + str(exit_code))