Example #1
0
def get_elem_configs(*args,**kw):
    datareqs,processors,outputs = [],[],[]

    kw = udict(kw)
    base = dirname(kw['__FILE'])

    # ... to acquire data
    d = kw.xget('DATAREQ')
    if d:
        pd = _i(d,base,options.process_path)
        if pd:
            datareqs.append(pd)
        else:
            logger.warn('Data Request file "%s" not exists',d)

    # ..to process 'em
    d = kw.xget('PROCESSORS')
    if d:
        pd = _i(d,base,options.process_path)
        if pd:
            processors.append(pd)
        else:
            logger.warn('Processor Conf file "%s" not exists',d)
            
    # Job Label
    # Use section name if not exists LABEL key
    l = kw.xget('LABEL',args[0].upper())

    #
    _os = kw.xget_list('OUTPUT')
    if _os:
        for d in _os:
            pd = _i(d,base,options.process_path)
            if pd:
                outputs.append(pd)
            else:
                logger.warn('Output Conf file "%s" not exists',d)
    
        for o in outputs:
            cfg = cfg2hash(o)
            jcfg = cfg.xget(l.upper())
            if jcfg:
                base = dirname(jcfg.xget('__FILE'))
                d = jcfg.xget('DATAREQ')
                pd = _i(d,base,options.process_path)
                if pd:
                    datareqs.append(pd)
                else:
                    logger.warn('*Data Request file "%s" not exists',d)

                d = jcfg.xget('PROCESSOR')
                if d:
                    pd = _i(d,base,options.process_path)
                    if pd:
                        processors.append(pd)
                    else:
                        logger.warn('*Processor Conf file "%s" not exists',d)


    return datareqs,processors,outputs
Example #2
0
def e4t_import_input_pages(pages,options):
    for page in pages:
        _from = expandvars(expanduser(page))
        if not isabs(page):
            base = join(options.process_path,'input')
            _from = _i(_from,base)
        _to = basename(_from)
        if exists(_to): os.unlink(_to)
        shutil.copyfile(_from,_to)
Example #3
0
File: LaTeX.py Project: exedre/e4t
 def setup_elements(self):
     pages = get_list(self['PAGES'])
     for page in pages:
         _from = expandvars(expanduser(page))
         if page[0]!="/":
             base = expandvars(expanduser("$SRISTAT/input"))
             _from = _i(_from,base)
         _to = basename(_from)
         shutil.copyfile(_from,_to)
     if not self.has_key('ELEMS'):
         return
     pages = get_list(self['ELEMS'])
     for page in pages:
         _from = expandvars(page)
         if page[0]!="/":
             base = expandvars("$SRISTAT/input")
             _from = _i(_from,base)
         _to = basename(_from)
         shutil.copyfile(_from,_to)
Example #4
0
def _acquire_file(kw, label, a_list, warn, base, exception=False):
    fname = kw.xget(label)
    if fname:
        path_plus_fname = _i(fname, base, OPTIONS.process_path)
        if pd:
            a_list.append(path_plus_fname)
        else:
            if not exception:
                LOGGER.warn('%s file "%s" not exists', warn, fname)
            else:
                raise E4tUserError(OPTIONS.job,
                                   '%s file "%s" not exists', warn, fname)
Example #5
0
 def setup_elements(self):
     pages = self.xget_list('PAGES')
     for page in pages:
         _from = expandvars(expanduser(page))
         if not isabs(page):
             base = join(self.options.process_path,'input')
             _from = _i(_from,base)
         _to = basename(_from)
         if exists(_to): os.unlink(_to)
         shutil.copyfile(_from,_to)
     if 'ELEMS' not in self:
         return
     pages = self.xget_list('ELEMS')
     for page in pages:
         _from = expandvars(page)
         if not isabs(page):
             base = join(self.options.process_path,'input')
             _from = _i(_from,base)
         _to = basename(_from)
         if exists(_to): os.unlink(_to)
         shutil.copyfile(_from,_to)
Example #6
0
def get_elem_configs(*args, **kw):
    """
    """

    (datareqs, processors, outputs) = ([], [], [])
    kw = udict(kw)
    base = dirname(kw['__FILE'])

    # ... to acquire data

    _acquire_file(kw, 'DATAREQ', datareqs, 'Data Reqyest', base)

    # ... to process 'em

    _acquire_file(kw, 'PROCESSOR', processors, 'Processor Configuration', base)


    # Job Label
    # Use section name if not exists LABEL key

    l = kw.xget('LABEL', args[0].upper())

    #
    _acquire_file(kw, 'OUTPUT', outputs, 'EC02:OUTPUT-KEY Output Conf', base, exception=True )

    for o in outputs:
        cfg = cfg2hash(o)
        jcfg = cfg.xget(l.upper())
        if jcfg:
            base = dirname(jcfg.xget('__FILE'))
            d = jcfg.xget('DATAREQ')
            if not d:
                continue
            pd = _i(d, base, OPTIONS.process_path)
            if pd:
                datareqs.append(pd)
            else:
                LOGGER.warn('*Data Request file "%s" not exists', d)

            _acquire_file(jcfg, 'PROCESSOR', processors, 'Processor Configuration', base)

    return (datareqs, processors, outputs)
Example #7
0
def check_conffile(icfg,options,conf,cfg,*args):
    logger.debug("{CONFFILE} %s",args[0])
    label = cfg.get('LABEL',cfg['__LABEL'])    
    base = dirname(cfg['__FILE'])
    results=[]
    for _n,(_f,_t) in args[0].items():
        if cfg.has_key(_n.upper()):
            fname= cfg[_n.upper()]
            conffile = _i(fname,base)
            if conffile:
                if re.search("\.req$",conffile,re.I):
                    logger.debug('{CONFFILE} req %s,%s',fname,conffile)                    
                    pass
                else:
                    logger.debug('{CONFFILE} conf %s,%s',fname,conffile)
                    ncfg = cfg2hash(conffile)
                    if _n=='processor':
                        label='PROCESSOR'
                    results.extend(check(options,label,ncfg,_t))
            else:
                kw = udict(cfg)
                kw.update({'OFFENDING':fname})
                results.append(('E:FILE:001',kw),)
    return results
Example #8
0
def check_file(icfg,options,conf,_value,_search): 
    if _search=='+':
        if not exists(_value) and not exists(_i(_value,basedir)):
            return ( 'E:FILE:001', _value ),
    return None