# -*-Python-*-
# Created by bgrierson at 23 Feb 2018 11:03
"""
This script runs an executable on PPPL's portal
"""
if MainSettings['SERVER']['PPPL_username'] == '':
printe('You do not have PPPL_username setup')
OMFITx.End()
# Set up to only run this code on the localhost (i.e. your workstation or laptop)
serverPicker = 'portal'
serverOptions = SERVER[serverPicker]
server = serverOptions['server']
tunnel = serverOptions['tunnel']
remotedir = str(OMFITworkDir(root, serverPicker))
workdir = str(root['SETTINGS']['SETUP']['workDir'])
# Define the executable
executable = '''
pwd > pwd.txt'''
# Run the executable
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS'].setdefault('EXECUTABLE', OMFITtree())
root['OUTPUTS']['EXECUTABLE']['ex_portal'] = OMFITascii('./pwd.txt')
# Now a few stress tests
executable = '''#!/bin/bash
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_shebang_bash'] = OMFITascii('./pwd.txt')
executable = '''#!/bin/bash -l
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_shebang_bash_l'] = OMFITascii('./pwd.txt')
executable = '''
module list
module purge
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_module'] = OMFITascii('./pwd.txt')
executable = '''#!/bin/bash
module list
module purge
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_module_shebang_bash_module'] = OMFITascii('./pwd.txt')
executable = '''
module list
module purge
module load omfit/unstable
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_omfit'] = OMFITascii('./pwd.txt')
executable = '''#!/bin/bash
module list
module purge
module load omfit/unstable
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_shebang_bash_omfit'] = OMFITascii('./pwd.txt')
executable = '''#!/bin/bash -l
module list
module purge
module load omfit/unstable
pwd > pwd.txt'''
OMFITx.executable(
root, inputs=[], outputs=['pwd.txt'], executable=executable, tunnel=None, server=server, workdir=workdir, remotedir=remotedir
)
root['OUTPUTS']['EXECUTABLE']['ex_portal_shebang_bash_l_omfit'] = OMFITascii('./pwd.txt')