Ejemplo n.º 1
0
def print_errors_and_exit(parser, errors, errcode, print_help = True):
    if print_help:
        parser.print_help()
    errors.insert(0, '')
    errors.append('')
    for e in errors:
        colorprinter.error(e.replace('  ', ' '))

    if errcode:
        sys.exit(errcode)
    else:
        sys.exit(ERRCODE_ARGUMENTS)
Ejemplo n.º 2
0
def main():
    this_dir = os.path.dirname(os.path.realpath(__file__))
    make_fragments_script_path = os.path.join(this_dir, make_fragments_script)

    errors = [] #check_configuration_paths()
    if errors:
        colorprinter.error("There is an error in the configuration files:")
        for e in errors:
            print("")
            flname = e[0]
            es = e[1]
            colorprinter.warning(flname)
            for e in es:
                colorprinter.error(e)
        sys.exit(ERRCODE_CONFIG)

    options = parse_args()
    if options["outpath"] and options['job_inputs']:
        job_script = None
        try:
            cluster_job = ClusterEngine.FragmentsJob(make_fragments_script_path, options, test_mode = test_mode)
            job_script = cluster_job.script
        except JobInitializationException, e:
            colorprinter.error(str(e))
            sys.exit(ERRCODE_ARGUMENTS)

        submission_script = os.path.join(options["outpath"], 'submission_script.py')
        write_file(submission_script, job_script, 'w')

        try:
            send_mail = options['sendmail']
            username = None
            if send_mail:
                username = get_username()
            (jobid, output) = ClusterEngine.submit(submission_script, options["outpath"], send_mail = send_mail, username = username )
        except Exception, e:
            colorprinter.error("An exception occurred during submission to the cluster.")
            colorprinter.error(str(e))
            colorprinter.error(traceback.format_exc())
            sys.exit(ERRCODE_CLUSTER)