Changeset 97e09f4 in flex_extract.git for python/tools.py


Ignore:
Timestamp:
Sep 2, 2018, 12:32:04 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
efa05d7
Parents:
f9f7b3f
Message:

completed testing and adaptations of ecacces job-submit and file-put functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tools.py

    r70a0bec r97e09f4  
    446446    '''
    447447    @Description:
    448         Uses the ecaccess command to send a file to the ECMWF servers.
    449         Catches and prints the error if it failed.
     448        Uses the ecaccess-file-put command to send a file to the ECMWF servers.
     449
     450        NOTE:
     451        The return value is just for testing reasons. It does not have
     452        to be used from the calling function since the whole error handling
     453        is done in here.
    450454
    451455    @Input:
    452456        ecd: string
    453             The path were the file is to be stored.
     457            The path were the file is stored.
    454458
    455459        filename: string
     
    457461
    458462        target: string
    459             The target where the file should be sent to, e.g. the queue.
     463            The target queue where the file should be sent to.
    460464
    461465        ecuid: string
     
    466470
    467471    @Return:
    468         <nothing>
     472        rcode: string
     473            Resulting code of command execution. If successful the string
     474            will be empty.
    469475    '''
    470476
    471477    try:
    472         subprocess.check_call(['ecaccess-file-put',
    473                                ecd + '/' + filename,
    474                                target + ':/home/ms/' +
    475                                ecgid + '/' + ecuid +
    476                                '/' + filename])
     478        rcode = subprocess.check_output(['ecaccess-file-put',
     479                                          ecd + '/' + filename,
     480                                          target + ':/home/ms/' +
     481                                          ecgid + '/' + ecuid +
     482                                          '/' + filename],
     483                                         stderr=subprocess.STDOUT)
    477484    except subprocess.CalledProcessError as e:
    478         print 'ERROR:'
    479         print e
    480         sys.exit('ecaccess-file-put failed!\n' + \
    481                  'Probably the eccert key has expired.')
    482 
    483     return
     485        print '... ERROR CODE:\n ... ', e.returncode
     486        print '... ERROR MESSAGE:\n ... ', e
     487        print '... COMMAND MESSAGE:\n ...', e.output
     488
     489        print '\nDo you have a valid eccert key?'
     490        sys.exit('... ECACCESS-FILE-PUT FAILED!')
     491
     492    return rcode
    484493
    485494def submit_job_to_ecserver(target, jobname):
    486495    '''
    487496    @Description:
    488         Uses ecaccess to submit a job to the ECMWF server.
    489         Catches and prints the error if one arise.
     497        Uses ecaccess-job-submit command to submit a job to the ECMWF server.
     498
     499        NOTE:
     500        The return value is just for testing reasons. It does not have
     501        to be used from the calling function since the whole error handling
     502        is done in here.
    490503
    491504    @Input:
     
    497510
    498511    @Return:
    499         rcode: integer
    500             Resulting code of subprocess.check_call.
     512        rcode: string
     513            Resulting code of command execution. If successful the string
     514            will contain an integer number, representing the id of the job
     515            at the ecmwf server.
    501516    '''
    502517
    503518    try:
    504         rcode = subprocess.check_call(['ecaccess-job-submit',
    505                                        '-queueName', target,
    506                                        jobname])
     519        rcode = subprocess.check_output(['ecaccess-job-submit',
     520                                         '-queueName', target,
     521                                         jobname])
    507522    except subprocess.CalledProcessError as e:
    508523        print '... ERROR CODE: ', e.returncode
     524        print '... ERROR MESSAGE:\n ... ', e
     525        print '... COMMAND MESSAGE:\n ...', e.output
     526
     527        print '\nDo you have a valid eccert key?'
    509528        sys.exit('... ECACCESS-JOB-SUBMIT FAILED!')
    510529
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG