'runs an external script the will QSUB a new job.
The external script needs to be run with sudo, and will setuid() to the specified user.
Effectively, will QSUB as a different user (then the one used by Galaxy).'

def external_runjob(self, external_runjob_script, jobtemplate_filename, username):

    command = shlex.split(external_runjob_script)
    command.extend([str(username), jobtemplate_filename])
    log.info(('Running    command    %s' % command))
    p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (stdoutdata, stderrdata) = p.communicate()
    exitcode = p.returncode
    if (exitcode != 0):
        raise RuntimeError(('External_runjob    failed    (exit    code    %s)\nChild    process    reported    error:\n%s' % (str(exitcode), stderrdata)))
    if (not stdoutdata.strip()):
        raise RuntimeError(('External_runjob    did    return    the    job    id:    %s' % stdoutdata))
    jobId = stdoutdata
    return jobId
