def remote_side_bash_executor(func, *args, **kwargs):
import os<EOL>import time<EOL>import subprocess<EOL>import logging<EOL>import parsl.app.errors as pe<EOL>logging.basicConfig(filename='<STR_LIT>'.format(time.time()), level=logging.DEBUG)<EOL>func_name = func.__name__<EOL>partial_cmdline = None<EOL>try:<EOL><INDENT>partial_cmdline = func(*args, **kwargs)<EOL>executable = partial_cmdline.format(*args, **kwargs)<EOL><DEDENT>except AttributeError as e:<EOL><INDENT>if partial_cmdline is not None:<EOL><INDENT>raise pe.AppBadFormatting("<STR_LIT>".format(func_name, e))<EOL><DEDENT>else:<EOL><INDENT>raise pe.BashAppNoReturn("<STR_LIT>".format(func_name, e), None)<EOL><DEDENT><DEDENT>except IndexError as e:<EOL><INDENT>raise pe.AppBadFormatting("<STR_LIT>".format(func_name, e))<EOL><DEDENT>except Exception as e:<EOL><INDENT>logging.error("<STR_LIT>".format(func_name, e))<EOL>raise e<EOL><DEDENT>logging.debug("<STR_LIT>", executable)<EOL>def open_std_fd(fdname):<EOL><INDENT>stdfspec = kwargs.get(fdname)  <EOL>if stdfspec is None:<EOL><INDENT>return None<EOL><DEDENT>elif isinstance(stdfspec, str):<EOL><INDENT>fname = stdfspec<EOL>mode = '<STR_LIT>'<EOL><DEDENT>elif isinstance(stdfspec, tuple):<EOL><INDENT>if len(stdfspec) != <NUM_LIT:2>:<EOL><INDENT>raise pe.BadStdStreamFile("<STR_LIT>" % (fdname, len(stdfspec)), TypeError('<STR_LIT>'))<EOL><DEDENT>fname, mode = stdfspec<EOL><DEDENT>else:<EOL><INDENT>raise pe.BadStdStreamFile("<STR_LIT>" % (fdname, str(type(stdfspec))), TypeError('<STR_LIT>'))<EOL><DEDENT>try:<EOL><INDENT>fd = open(fname, mode)<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise pe.BadStdStreamFile(fname, e)<EOL><DEDENT>return fd<EOL><DEDENT>std_out = open_std_fd('<STR_LIT>')<EOL>std_err = open_std_fd('<STR_LIT>')<EOL>timeout = kwargs.get('<STR_LIT>')<EOL>returncode = None<EOL>try:<EOL><INDENT>proc = subprocess.Popen(executable, stdout=std_out, stderr=std_err, shell=True, executable='<STR_LIT>')<EOL>proc.wait(timeout=timeout)<EOL>returncode = proc.returncode<EOL><DEDENT>except subprocess.TimeoutExpired:<EOL><INDENT>raise pe.AppTimeout("<STR_LIT>".format(func_name, timeout))<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise pe.AppException("<STR_LIT>".format(func_name, proc.returncode), e)<EOL><DEDENT>if returncode != <NUM_LIT:0>:<EOL><INDENT>raise pe.AppFailure("<STR_LIT>".format(func_name, proc.returncode), proc.returncode)<EOL><DEDENT>missing = []<EOL>for outputfile in kwargs.get('<STR_LIT>', []):<EOL><INDENT>fpath = outputfile<EOL>if type(outputfile) != str:<EOL><INDENT>fpath = outputfile.filepath<EOL><DEDENT>if not os.path.exists(fpath):<EOL><INDENT>missing.extend([outputfile])<EOL><DEDENT><DEDENT>if missing:<EOL><INDENT>raise pe.MissingOutputs("<STR_LIT>".format(func_name), missing)<EOL><DEDENT>return returncode<EOL>
Execute the bash app type function and return the command line string.

    This string is reformatted with the *args, and **kwargs
    from call time.