Example #1
0
def new_job(
    filename,
    client_id,
    configuration,
    forceddestination,
    returnjobid=False,
    ):
    """This function submits a file to the MiG system by assigning
    a unique name to the new job and sends it to the parser.
    It should be called by all other functions when a job should be submitted.
    New: function can now be called with returnjobid argument so new output
    model can get job_id seperately (instead of the return message string)
    """

    mig_server_id = configuration.mig_server_id

    counter = get_job_id(configuration)
    gmt = time.gmtime()
    timestamp = str(gmt[1]) + '_' + str(gmt[2]) + '_' + str(gmt[0])\
         + '__' + str(gmt[3]) + '_' + str(gmt[4]) + '_' + str(gmt[5])
    job_id = str(counter) + '_' + str(timestamp) + '_'\
         + str(mig_server_id)

    # Call the mRSL parser

    filename_spaces = filename.replace('\\ ', '\\\\\\ ')

    (parseresult, parsemsg) = parse(filename_spaces, job_id, client_id,
                                    forceddestination)

    if parseresult:
        if returnjobid:
            return (True, '%s is the job id assigned.' % job_id, job_id)
        else:
            return (True, '%s is the job id assigned.' % job_id)
    else:
        if returnjobid:
            return (False, '''parse failed, Error in mRSL file - or parser -
or subsystem :)\n%s''' % parsemsg, None)
        else:
            return (False, '''parse failed, Error in mRSL file - or parser -
or subsystem :)\n%s''' % parsemsg)
Example #2
0
def new_job(
    filename,
    client_id,
    configuration,
    forceddestination,
    returnjobid=False,
    ):
    """This function submits a file to the MiG system by assigning
    a unique name to the new job and sends it to the parser.
    It should be called by all other functions when a job should be submitted.
    New: function can now be called with returnjobid argument so new output
    model can get job_id seperately (instead of the return message string)
    """

    mig_server_id = configuration.mig_server_id

    counter = get_job_id(configuration)
    gmt = time.gmtime()
    timestamp = str(gmt[1]) + '_' + str(gmt[2]) + '_' + str(gmt[0])\
         + '__' + str(gmt[3]) + '_' + str(gmt[4]) + '_' + str(gmt[5])
    job_id = str(counter) + '_' + str(timestamp) + '_'\
         + str(mig_server_id)

    # Call the mRSL parser

    filename_spaces = filename.replace('\\ ', '\\\\\\ ')

    (parseresult, parsemsg) = parse(filename_spaces, job_id, client_id,
                                    forceddestination)

    if parseresult:
        if returnjobid:
            return (True, '%s is the job id assigned.' % job_id, job_id)
        else:
            return (True, '%s is the job id assigned.' % job_id)
    else:
        if returnjobid:
            return (False, '''parse failed, Error in mRSL file - or parser -
or subsystem :)\n%s''' % parsemsg, None)
        else:
            return (False, '''parse failed, Error in mRSL file - or parser -
or subsystem :)\n%s''' % parsemsg)
Example #3
0
    else:   
        return [list[1],list[0]]

if __name__ == '__main__':
    print 'starting translation test. Args: ' , len(sys.argv)
    logger.debug('translation for file ' + sys.argv[1] + ' starts')
    if len(sys.argv) > 1:
        fname = sys.argv[1]
        parsed = '.'.join([fname,'parsed'])
        translated = '.'.join([parsed,'xrsl'])

        try:
            import shared.mrslparser as p
            import shared.fileio as fileio

            (presult,errors) = p.parse(fname, 'test-id',
                                       '+No+Client+Id',None,parsed)
            if not presult:
                print 'Errors:\n%s' % errors
            else:
                print 'Parsing OK, now translating'
                mrsl_dict = fileio.unpickle(parsed,logger)
                (xrsl,script,name) = translate(mrsl_dict,'test-name')
                print '\n'.join(['Job name',name,'script',script,'XRSL'])
                fileio.write_file(script, "test-id.sh", logger)
                print (format_xrsl(xrsl))
                fileio.write_file("%s" % xrsl, translated, logger)
                print 'done'
        except Exception, err:
            print 'Error.'
            print err.__str__()
Example #4
0
def parse_lines(mrsl_text):
    """Wrap lines in IO object to allow parsing from list"""
    mrsl_buffer = StringIO.StringIO(mrsl_text)
    return parse(mrsl_buffer)
Example #5
0
                    try:
                        (filehandle, tmpfile) = \
                            tempfile.mkstemp(text=True)
                        os.write(filehandle, testprocedure)
                        os.close(filehandle)
                    except Exception, err:
                        status = False
                        msg += \
                            'Exception writing temporary testprocedure file. New runtime environment not created! %s'\
                             % err

                retmsg = ''
                if status:
                    from shared.mrslparser import parse
                    (status, retmsg) = parse(tmpfile, "testprocedure_job_id", "testprocedure_test_parse__cert_name_not_specified", False, outfile="%s.parsed" % tmpfile)
                    
                # remove temporary files no matter what happened

                if tmpfile:
                    try:
                        os.remove(tmpfile)
                        os.remove('%s.parsed' % tmpfile)
                    except Exception, err:
                        msg += \
                            'Exception removing temporary testprocedure file %s or %s, %s'\
                             % (tmpfile, '%s.parsed' % tmpfile, err)

                        # should we exit because of this? status = False

                if not status:
Example #6
0
    else:   
        return [list[1],list[0]]

if __name__ == '__main__':
    print 'starting translation test. Args: ' , len(sys.argv)
    logger.debug('translation for file ' + sys.argv[1] + ' starts')
    if len(sys.argv) > 1:
        fname = sys.argv[1]
        parsed = '.'.join([fname,'parsed'])
        translated = '.'.join([parsed,'xrsl'])

        try:
            import shared.mrslparser as p
            import shared.fileio as fileio

            (presult,errors) = p.parse(fname, 'test-id',
                                       '+No+Client+Id',None,parsed)
            if not presult:
                print 'Errors:\n%s' % errors
            else:
                print 'Parsing OK, now translating'
                mrsl_dict = fileio.unpickle(parsed,logger)
                (xrsl,script,name) = translate(mrsl_dict,'test-name')
                print '\n'.join(['Job name',name,'script',script,'XRSL'])
                fileio.write_file(script, "test-id.sh", logger)
                print (format_xrsl(xrsl))
                fileio.write_file("%s" % xrsl, translated, logger)
                print 'done'
        except Exception, err:
            print 'Error.'
            print err.__str__()