Exemplo n.º 1
0
def BalrogSystemCall(cmd, DerivedConfig, func=True):
    if func:
        msg = 'Doing Balrog as function: \n%s\n'%(' '.join(cmd[2:]))
        balrog.SysInfoPrint(DerivedConfig['setup'], msg, level='info')
        #balrog.BalrogFunction(args=cmd[3:], systemredirect=DerivedConfig['itlog'], excredirect=DerivedConfig['itlog'])
        ret = balrog.BalrogFunction(args=cmd[3:], syslog=DerivedConfig['itlog'])
    else:
        ret = balrog.SystemCall(args, setup=DerivedConfig['setup'])

    if (ret != 0):
        raise Exception('Balrog failed')
Exemplo n.º 2
0
def Wget(infile, file, setup, RunConfig, skip):
    if not skip:
        oscmd = [RunConfig['wget'], '--quiet', '--no-check-certificate', file, '-O', infile]
        done = False
        while not done:
            Remove(infile)
            balrog.SystemCall(oscmd, setup=setup, delfiles=[infile])

            with warnings.catch_warnings():
                warnings.filterwarnings('error')
                try:
                    f = pyfits.open(infile, checksum=True)
                    done = True
                except:
                    balrog.SysInfoPrint(setup, "wget failed checksum. Retrying")
Exemplo n.º 3
0
    def run(self, msg=None):
        args = [self.path, self.config['IMAGE']]
        for key in self.config.keys():
            if key == 'IMAGE':
                continue
            else:
                args.append('-%s' % key)
            args.append(str(self.config[key]))

        #cmd = ' '.join(args)
        cmd = args

        if msg is not None:
            balrog.SysInfoPrint(self.setup, msg, level='info')
        balrog.SystemCall(cmd, setup=self.setup)
Exemplo n.º 4
0
def Funpack(infile, setup, RunConfig, skip):
    ufile = infile.replace('.fits.fz', '.fits')
    if not skip:
        oscmd = [RunConfig['funpack'], '-O', ufile, infile]
        done = False
        while not done:
            Remove(ufile) 
            balrog.SystemCall(oscmd, setup=setup, delfiles=[ufile], keeps=[infile])

            with warnings.catch_warnings():
                warnings.filterwarnings('error')
                try:
                    f = pyfits.open(ufile, checksum=True)
                    done = True
                except:
                    balrog.SysInfoPrint(setup, "funpack failed checksum. Retrying")
    return ufile
Exemplo n.º 5
0
def FitsVerify(oscmd, outfile, str, setup, maxtries):
    done = False
    tries = 0
    while not done:
        Remove(outfile)
        #balrog.SystemCall(oscmd, setup=setup, delfiles=[outfile], timeout=(60*15))
        balrog.SystemCall(oscmd, setup=setup, delfiles=[outfile])
        with warnings.catch_warnings():
            warnings.filterwarnings('error')
            try:
                f = pyfits.open(outfile, checksum=True)
                done = True
            except:
                balrog.SysInfoPrint(setup, "Attempt %i: %s failed checksum."%(tries,str))
                tries += 1
        if tries >= maxtries:
            raise Exception('%s still failing after the maximum %i tries. Giving up.'%(str,maxtries) )